Browse Source

首次提交

mq 4 years ago
commit
efeefd44a7
100 changed files with 7850 additions and 0 deletions
  1. 14 0
      .gitignore
  2. 134 0
      .idea/codeStyles/Project.xml
  3. 21 0
      .idea/gradle.xml
  4. 40 0
      .idea/jarRepositories.xml
  5. 9 0
      .idea/misc.xml
  6. 6 0
      .idea/vcs.xml
  7. BIN
      UHFlib.jar
  8. 1 0
      app/.gitignore
  9. 97 0
      app/build.gradle
  10. BIN
      app/intelhouse.jks
  11. BIN
      app/libs/mylib.jar
  12. 25 0
      app/proguard-rules.pro
  13. BIN
      app/release/app-release.apk
  14. 1 0
      app/release/output.json
  15. 43 0
      app/src/main/AndroidManifest.xml
  16. 22 0
      app/src/main/java/hf/lskj/com/carstockcount/ExportBean.java
  17. 183 0
      app/src/main/java/hf/lskj/com/carstockcount/MyApplication.java
  18. 31 0
      app/src/main/java/hf/lskj/com/carstockcount/RequestUtils.java
  19. 161 0
      app/src/main/java/hf/lskj/com/carstockcount/activity/BaseActivity.java
  20. 224 0
      app/src/main/java/hf/lskj/com/carstockcount/activity/CarListActivity.java
  21. 28 0
      app/src/main/java/hf/lskj/com/carstockcount/activity/LaunchActivity.java
  22. 193 0
      app/src/main/java/hf/lskj/com/carstockcount/activity/LoginActivity.java
  23. 206 0
      app/src/main/java/hf/lskj/com/carstockcount/activity/MainActivity.java
  24. 183 0
      app/src/main/java/hf/lskj/com/carstockcount/activity/RecordListActivity.java
  25. 173 0
      app/src/main/java/hf/lskj/com/carstockcount/adapter/CarListAdapter.java
  26. 119 0
      app/src/main/java/hf/lskj/com/carstockcount/adapter/CountRecordAdapter.java
  27. 95 0
      app/src/main/java/hf/lskj/com/carstockcount/adapter/VinAdapter.java
  28. 188 0
      app/src/main/java/hf/lskj/com/carstockcount/db/CarInfo.java
  29. 219 0
      app/src/main/java/hf/lskj/com/carstockcount/db/CarInfoDao.java
  30. 102 0
      app/src/main/java/hf/lskj/com/carstockcount/db/DaoMaster.java
  31. 76 0
      app/src/main/java/hf/lskj/com/carstockcount/db/DaoSession.java
  32. 19 0
      app/src/main/java/hf/lskj/com/carstockcount/db/InitData.java
  33. 123 0
      app/src/main/java/hf/lskj/com/carstockcount/db/MyDao.java
  34. 200 0
      app/src/main/java/hf/lskj/com/carstockcount/db/Record.java
  35. 374 0
      app/src/main/java/hf/lskj/com/carstockcount/db/RecordDao.java
  36. 69 0
      app/src/main/java/hf/lskj/com/carstockcount/db/User.java
  37. 174 0
      app/src/main/java/hf/lskj/com/carstockcount/db/UserDao.java
  38. 49 0
      app/src/main/java/hf/lskj/com/carstockcount/db/UserDaoUtils.java
  39. 13 0
      app/src/main/java/hf/lskj/com/carstockcount/event/BindEvent.java
  40. 11 0
      app/src/main/java/hf/lskj/com/carstockcount/event/ChooseCarEvent.java
  41. 11 0
      app/src/main/java/hf/lskj/com/carstockcount/event/ChooseRecordEvent.java
  42. 7 0
      app/src/main/java/hf/lskj/com/carstockcount/event/ExitEvent.java
  43. 74 0
      app/src/main/java/hf/lskj/com/carstockcount/fragment/BaseFragment.java
  44. 365 0
      app/src/main/java/hf/lskj/com/carstockcount/fragment/BindFragment.java
  45. 94 0
      app/src/main/java/hf/lskj/com/carstockcount/fragment/MeFragment.java
  46. 11 0
      app/src/main/java/hf/lskj/com/carstockcount/fragment/OnKeyDownInterface.java
  47. 472 0
      app/src/main/java/hf/lskj/com/carstockcount/fragment/StockCountFragment.java
  48. 66 0
      app/src/main/java/hf/lskj/com/carstockcount/utils/ActivityJump.java
  49. 44 0
      app/src/main/java/hf/lskj/com/carstockcount/utils/AppUtils.java
  50. 296 0
      app/src/main/java/hf/lskj/com/carstockcount/utils/Bimp.java
  51. 43 0
      app/src/main/java/hf/lskj/com/carstockcount/utils/DPUtils.java
  52. 86 0
      app/src/main/java/hf/lskj/com/carstockcount/utils/DateUtils.java
  53. 133 0
      app/src/main/java/hf/lskj/com/carstockcount/utils/FileUtils.java
  54. 54 0
      app/src/main/java/hf/lskj/com/carstockcount/utils/KeyBoardUtils.java
  55. 105 0
      app/src/main/java/hf/lskj/com/carstockcount/utils/LogUtils.java
  56. 63 0
      app/src/main/java/hf/lskj/com/carstockcount/utils/NetUtils.java
  57. 204 0
      app/src/main/java/hf/lskj/com/carstockcount/utils/NumberFormatUtil.java
  58. 126 0
      app/src/main/java/hf/lskj/com/carstockcount/utils/NumberToCN.java
  59. 84 0
      app/src/main/java/hf/lskj/com/carstockcount/utils/PreferencesUtils.java
  60. 43 0
      app/src/main/java/hf/lskj/com/carstockcount/utils/SDCardUtils.java
  61. 78 0
      app/src/main/java/hf/lskj/com/carstockcount/utils/ScreenUtils.java
  62. 596 0
      app/src/main/java/hf/lskj/com/carstockcount/utils/StringUtils.java
  63. 36 0
      app/src/main/java/hf/lskj/com/carstockcount/utils/TimeZoneUtil.java
  64. 42 0
      app/src/main/java/hf/lskj/com/carstockcount/utils/ToastUtils.java
  65. 219 0
      app/src/main/java/hf/lskj/com/carstockcount/utils/UHF/ShellUtils.java
  66. 56 0
      app/src/main/java/hf/lskj/com/carstockcount/utils/UHF/Sound.java
  67. 48 0
      app/src/main/java/hf/lskj/com/carstockcount/utils/UHF/UHFClient.java
  68. 47 0
      app/src/main/java/hf/lskj/com/carstockcount/utils/UHF/UHFUtils.java
  69. 13 0
      app/src/main/res/drawable/bg_block.xml
  70. 4 0
      app/src/main/res/drawable/bg_button.xml
  71. 6 0
      app/src/main/res/drawable/guanlian.xml
  72. 6 0
      app/src/main/res/drawable/pandian.xml
  73. 6 0
      app/src/main/res/drawable/user.xml
  74. 67 0
      app/src/main/res/layout/activity_car_list.xml
  75. 36 0
      app/src/main/res/layout/activity_count_list.xml
  76. 100 0
      app/src/main/res/layout/activity_login.xml
  77. 29 0
      app/src/main/res/layout/activity_main.xml
  78. 72 0
      app/src/main/res/layout/fragment_bind.xml
  79. 103 0
      app/src/main/res/layout/fragment_me.xml
  80. 128 0
      app/src/main/res/layout/fragment_stock_count.xml
  81. 71 0
      app/src/main/res/layout/item_car.xml
  82. 71 0
      app/src/main/res/layout/item_record.xml
  83. 9 0
      app/src/main/res/menu/car_list.xml
  84. BIN
      app/src/main/res/mipmap-hdpi/arrow_right.png
  85. BIN
      app/src/main/res/mipmap-hdpi/calendar.png
  86. BIN
      app/src/main/res/mipmap-hdpi/chuku_icon.png
  87. BIN
      app/src/main/res/mipmap-hdpi/guanlian.png
  88. BIN
      app/src/main/res/mipmap-hdpi/guanlian_xz.png
  89. BIN
      app/src/main/res/mipmap-hdpi/ic_launcher.png
  90. BIN
      app/src/main/res/mipmap-hdpi/pandian.png
  91. BIN
      app/src/main/res/mipmap-hdpi/pandian_xz.png
  92. BIN
      app/src/main/res/mipmap-hdpi/search_clear.png
  93. BIN
      app/src/main/res/mipmap-hdpi/user.png
  94. BIN
      app/src/main/res/mipmap-hdpi/user_xz.png
  95. BIN
      app/src/main/res/mipmap-hdpi/yidong_icon.png
  96. BIN
      app/src/main/res/mipmap-hdpi/zaiku_icon.png
  97. BIN
      app/src/main/res/mipmap-mdpi/index_logo.png
  98. BIN
      app/src/main/res/mipmap-xhdpi/ic_launcher.png
  99. BIN
      app/src/main/res/mipmap-xxhdpi/ic_launcher.png
  100. 0 0
      app/src/main/res/mipmap-xxhdpi/login_password.png

+ 14 - 0
.gitignore

@@ -0,0 +1,14 @@
1
+*.iml
2
+.gradle
3
+/local.properties
4
+/.idea/caches
5
+/.idea/libraries
6
+/.idea/modules.xml
7
+/.idea/workspace.xml
8
+/.idea/navEditor.xml
9
+/.idea/assetWizardSettings.xml
10
+.DS_Store
11
+/build
12
+/captures
13
+.externalNativeBuild
14
+.cxx

+ 134 - 0
.idea/codeStyles/Project.xml

@@ -0,0 +1,134 @@
1
+<component name="ProjectCodeStyleConfiguration">
2
+  <code_scheme name="Project" version="173">
3
+    <JetCodeStyleSettings>
4
+      <option name="PACKAGES_TO_USE_STAR_IMPORTS">
5
+        <value>
6
+          <package name="java.util" alias="false" withSubpackages="false" />
7
+          <package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
8
+          <package name="io.ktor" alias="false" withSubpackages="true" />
9
+        </value>
10
+      </option>
11
+      <option name="PACKAGES_IMPORT_LAYOUT">
12
+        <value>
13
+          <package name="" alias="false" withSubpackages="true" />
14
+          <package name="java" alias="false" withSubpackages="true" />
15
+          <package name="javax" alias="false" withSubpackages="true" />
16
+          <package name="kotlin" alias="false" withSubpackages="true" />
17
+          <package name="" alias="true" withSubpackages="true" />
18
+        </value>
19
+      </option>
20
+    </JetCodeStyleSettings>
21
+    <codeStyleSettings language="XML">
22
+      <indentOptions>
23
+        <option name="CONTINUATION_INDENT_SIZE" value="4" />
24
+      </indentOptions>
25
+      <arrangement>
26
+        <rules>
27
+          <section>
28
+            <rule>
29
+              <match>
30
+                <AND>
31
+                  <NAME>xmlns:android</NAME>
32
+                  <XML_ATTRIBUTE />
33
+                  <XML_NAMESPACE>^$</XML_NAMESPACE>
34
+                </AND>
35
+              </match>
36
+            </rule>
37
+          </section>
38
+          <section>
39
+            <rule>
40
+              <match>
41
+                <AND>
42
+                  <NAME>xmlns:.*</NAME>
43
+                  <XML_ATTRIBUTE />
44
+                  <XML_NAMESPACE>^$</XML_NAMESPACE>
45
+                </AND>
46
+              </match>
47
+              <order>BY_NAME</order>
48
+            </rule>
49
+          </section>
50
+          <section>
51
+            <rule>
52
+              <match>
53
+                <AND>
54
+                  <NAME>.*:id</NAME>
55
+                  <XML_ATTRIBUTE />
56
+                  <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
57
+                </AND>
58
+              </match>
59
+            </rule>
60
+          </section>
61
+          <section>
62
+            <rule>
63
+              <match>
64
+                <AND>
65
+                  <NAME>.*:name</NAME>
66
+                  <XML_ATTRIBUTE />
67
+                  <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
68
+                </AND>
69
+              </match>
70
+            </rule>
71
+          </section>
72
+          <section>
73
+            <rule>
74
+              <match>
75
+                <AND>
76
+                  <NAME>name</NAME>
77
+                  <XML_ATTRIBUTE />
78
+                  <XML_NAMESPACE>^$</XML_NAMESPACE>
79
+                </AND>
80
+              </match>
81
+            </rule>
82
+          </section>
83
+          <section>
84
+            <rule>
85
+              <match>
86
+                <AND>
87
+                  <NAME>style</NAME>
88
+                  <XML_ATTRIBUTE />
89
+                  <XML_NAMESPACE>^$</XML_NAMESPACE>
90
+                </AND>
91
+              </match>
92
+            </rule>
93
+          </section>
94
+          <section>
95
+            <rule>
96
+              <match>
97
+                <AND>
98
+                  <NAME>.*</NAME>
99
+                  <XML_ATTRIBUTE />
100
+                  <XML_NAMESPACE>^$</XML_NAMESPACE>
101
+                </AND>
102
+              </match>
103
+              <order>BY_NAME</order>
104
+            </rule>
105
+          </section>
106
+          <section>
107
+            <rule>
108
+              <match>
109
+                <AND>
110
+                  <NAME>.*</NAME>
111
+                  <XML_ATTRIBUTE />
112
+                  <XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
113
+                </AND>
114
+              </match>
115
+              <order>ANDROID_ATTRIBUTE_ORDER</order>
116
+            </rule>
117
+          </section>
118
+          <section>
119
+            <rule>
120
+              <match>
121
+                <AND>
122
+                  <NAME>.*</NAME>
123
+                  <XML_ATTRIBUTE />
124
+                  <XML_NAMESPACE>.*</XML_NAMESPACE>
125
+                </AND>
126
+              </match>
127
+              <order>BY_NAME</order>
128
+            </rule>
129
+          </section>
130
+        </rules>
131
+      </arrangement>
132
+    </codeStyleSettings>
133
+  </code_scheme>
134
+</component>

+ 21 - 0
.idea/gradle.xml

@@ -0,0 +1,21 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="GradleMigrationSettings" migrationVersion="1" />
4
+  <component name="GradleSettings">
5
+    <option name="linkedExternalProjectsSettings">
6
+      <GradleProjectSettings>
7
+        <option name="testRunner" value="PLATFORM" />
8
+        <option name="distributionType" value="DEFAULT_WRAPPED" />
9
+        <option name="externalProjectPath" value="$PROJECT_DIR$" />
10
+        <option name="gradleJvm" value="JDK" />
11
+        <option name="modules">
12
+          <set>
13
+            <option value="$PROJECT_DIR$" />
14
+            <option value="$PROJECT_DIR$/app" />
15
+          </set>
16
+        </option>
17
+        <option name="resolveModulePerSourceSet" value="false" />
18
+      </GradleProjectSettings>
19
+    </option>
20
+  </component>
21
+</project>

+ 40 - 0
.idea/jarRepositories.xml

@@ -0,0 +1,40 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="RemoteRepositoriesConfiguration">
4
+    <remote-repository>
5
+      <option name="id" value="central" />
6
+      <option name="name" value="Maven Central repository" />
7
+      <option name="url" value="https://repo1.maven.org/maven2" />
8
+    </remote-repository>
9
+    <remote-repository>
10
+      <option name="id" value="jboss.community" />
11
+      <option name="name" value="JBoss Community repository" />
12
+      <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
13
+    </remote-repository>
14
+    <remote-repository>
15
+      <option name="id" value="BintrayJCenter" />
16
+      <option name="name" value="BintrayJCenter" />
17
+      <option name="url" value="https://jcenter.bintray.com/" />
18
+    </remote-repository>
19
+    <remote-repository>
20
+      <option name="id" value="Google" />
21
+      <option name="name" value="Google" />
22
+      <option name="url" value="https://dl.google.com/dl/android/maven2/" />
23
+    </remote-repository>
24
+    <remote-repository>
25
+      <option name="id" value="E:\Program Files\AndroidSDK\SDK\extras\google\m2repository" />
26
+      <option name="name" value="E:\Program Files\AndroidSDK\SDK\extras\google\m2repository" />
27
+      <option name="url" value="file:/E:/Program%20Files/AndroidSDK/SDK/extras/google/m2repository" />
28
+    </remote-repository>
29
+    <remote-repository>
30
+      <option name="id" value="E:\Program Files\AndroidSDK\SDK\extras\android\m2repository" />
31
+      <option name="name" value="E:\Program Files\AndroidSDK\SDK\extras\android\m2repository" />
32
+      <option name="url" value="file:/E:/Program%20Files/AndroidSDK/SDK/extras/android/m2repository" />
33
+    </remote-repository>
34
+    <remote-repository>
35
+      <option name="id" value="E:\Program Files\AndroidSDK\SDK\extras\m2repository" />
36
+      <option name="name" value="E:\Program Files\AndroidSDK\SDK\extras\m2repository" />
37
+      <option name="url" value="file:/E:/Program%20Files/AndroidSDK/SDK/extras/m2repository" />
38
+    </remote-repository>
39
+  </component>
40
+</project>

+ 9 - 0
.idea/misc.xml

@@ -0,0 +1,9 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="JDK" project-jdk-type="JavaSDK">
4
+    <output url="file://$PROJECT_DIR$/build/classes" />
5
+  </component>
6
+  <component name="ProjectType">
7
+    <option name="id" value="Android" />
8
+  </component>
9
+</project>

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="VcsDirectoryMappings">
4
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+  </component>
6
+</project>

BIN
UHFlib.jar


+ 1 - 0
app/.gitignore

@@ -0,0 +1 @@
1
+/build

+ 97 - 0
app/build.gradle

@@ -0,0 +1,97 @@
1
+apply plugin: 'com.android.application'
2
+apply plugin: 'org.greenrobot.greendao'
3
+apply plugin: 'bugly'
4
+//设置发布的显示的版本号
5
+static def getVersionName() {
6
+    return new Date().format("yyyyMMddHHmm")
7
+}
8
+
9
+android {
10
+    compileSdkVersion 26
11
+    buildToolsVersion "26.0.2"
12
+    defaultConfig {
13
+        applicationId "hf.lskj.com.carstockcount"
14
+        minSdkVersion 19
15
+        targetSdkVersion 26
16
+        versionCode 1
17
+        versionName '1.0.0'
18
+//        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
19
+        //添加部分
20
+        javaCompileOptions {
21
+            annotationProcessorOptions {
22
+                includeCompileClasspath true
23
+            }
24
+        }
25
+    }
26
+    signingConfigs {
27
+        //配置keystore签名
28
+        release {
29
+            v1SigningEnabled true
30
+            v2SigningEnabled true
31
+            storeFile file('intelhouse.jks')
32
+            storePassword "intelhousePSW"
33
+            keyAlias "intelhousekey"
34
+            keyPassword "intelhousePSW"
35
+        }
36
+    }
37
+    buildTypes {
38
+        debug {}
39
+        release {
40
+            signingConfig signingConfigs.release
41
+            minifyEnabled false
42
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
43
+        }
44
+
45
+    }
46
+    sourceSets {
47
+        main {
48
+            jniLibs.srcDirs = ['libs']
49
+        }
50
+    }
51
+    //配置自定义打包名称
52
+//    applicationVariants.all { variant ->
53
+//        variant.outputs.each { output ->
54
+//            def outputFile = output.outputFile
55
+//            if (outputFile != null && outputFile.name.endsWith('.apk')) {
56
+//                if (variant.buildType.name.equals('release')) {
57
+//                    def originalName= outputFile.name.substring(0,outputFile.name.indexOf('.apk'))
58
+//                    variant.mergedFlavor.versionName = getVersionName()
59
+//                    def fileName = originalName+"${variant.mergedFlavor.versionName}.apk"
60
+//                    output.outputFile = new File(outputFile.parent, fileName)
61
+//                }
62
+//
63
+//            }
64
+//        }
65
+//    }
66
+    lintOptions {
67
+        checkReleaseBuilds false
68
+        abortOnError false
69
+    }
70
+    productFlavors {
71
+    }
72
+}
73
+bugly {
74
+    appId = 'c7b34b5874' // 注册时分配的App ID
75
+    appKey = '9663ec33-8e14-47e4-94cf-8939f9ea0e78' // 注册时分配的App Key
76
+}
77
+greendao {
78
+    schemaVersion 12 //指定数据库schema版本号
79
+    targetGenDir 'src/main/java'//生成数据库文件的目录
80
+}
81
+dependencies {
82
+    compile fileTree(include: ['*.jar'], dir: 'libs')
83
+    //    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
84
+    //        exclude group: 'com.android.support', module: 'support-annotations'
85
+    //    })
86
+    compile 'com.tencent.bugly:crashreport:latest.release'
87
+    compile 'org.greenrobot:eventbus:3.0.0'
88
+    compile 'com.android.support.constraint:constraint-layout:1.0.2'
89
+    compile 'com.android.support:appcompat-v7:26.0.2'
90
+    compile 'com.google.code.gson:gson:2.8.0'
91
+    compile 'com.jakewharton:butterknife:7.0.1'
92
+    compile 'org.greenrobot:greendao:3.2.2'
93
+    compile 'com.android.support:design:26.0.2'
94
+    compile 'com.android.support:support-v4:26.0.2'
95
+    compile 'com.squareup.okhttp3:okhttp:3.8.1'
96
+    //    testCompile 'junit:junit:4.12'
97
+}

BIN
app/intelhouse.jks


BIN
app/libs/mylib.jar


+ 25 - 0
app/proguard-rules.pro

@@ -0,0 +1,25 @@
1
+# Add project specific ProGuard rules here.
2
+# By default, the flags in this file are appended to flags specified
3
+# in C:\Users\yaoju\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt
4
+# You can edit the include path and order by changing the proguardFiles
5
+# directive in build.gradle.
6
+#
7
+# For more details, see
8
+#   http://developer.android.com/guide/developing/tools/proguard.html
9
+
10
+# Add any project specific keep options here:
11
+
12
+# If your project uses WebView with JS, uncomment the following
13
+# and specify the fully qualified class name to the JavaScript interface
14
+# class:
15
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16
+#   public *;
17
+#}
18
+
19
+# Uncomment this to preserve the line number information for
20
+# debugging stack traces.
21
+#-keepattributes SourceFile,LineNumberTable
22
+
23
+# If you keep the line number information, uncomment this to
24
+# hide the original source file name.
25
+#-renamesourcefileattribute SourceFile

BIN
app/release/app-release.apk


+ 1 - 0
app/release/output.json

@@ -0,0 +1 @@
1
+[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1},"path":"app-release.apk","properties":{"packageId":"hf.lskj.com.carstockcount","split":"","minSdkVersion":"19"}}]

+ 43 - 0
app/src/main/AndroidManifest.xml

@@ -0,0 +1,43 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
+    package="hf.lskj.com.carstockcount">
4
+
5
+    <!-- bugly -->
6
+    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
7
+    <uses-permission android:name="android.permission.INTERNET" />
8
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
9
+    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
10
+    <uses-permission android:name="android.permission.READ_LOGS" />
11
+    <!-- 向sd卡中创建与删除文件权限 -->
12
+    <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
13
+    <!-- 向sd卡中写入数据权限 -->
14
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
15
+    <!--扫描时的提示音-->
16
+    <uses-permission android:name="android.permission.VIBRATE" />
17
+    <application
18
+        android:name=".MyApplication"
19
+        android:allowBackup="true"
20
+        android:icon="@mipmap/ic_launcher"
21
+        android:label="@string/app_name"
22
+        android:supportsRtl="true"
23
+        android:theme="@style/AppTheme">
24
+        <activity android:name=".activity.LaunchActivity">
25
+            <intent-filter>
26
+                <action android:name="android.intent.action.MAIN" />
27
+
28
+                <category android:name="android.intent.category.LAUNCHER" />
29
+            </intent-filter>
30
+        </activity>
31
+        <activity android:name=".activity.MainActivity" />
32
+        <activity
33
+            android:name=".activity.LoginActivity"
34
+            android:windowSoftInputMode="adjustPan|stateHidden" />
35
+        <activity
36
+            android:name=".activity.RecordListActivity"
37
+            android:windowSoftInputMode="stateHidden" />
38
+        <activity
39
+            android:name=".activity.CarListActivity"
40
+            android:windowSoftInputMode="stateHidden" />
41
+    </application>
42
+
43
+</manifest>

+ 22 - 0
app/src/main/java/hf/lskj/com/carstockcount/ExportBean.java

@@ -0,0 +1,22 @@
1
+package hf.lskj.com.carstockcount;
2
+
3
+import java.util.List;
4
+
5
+import hf.lskj.com.carstockcount.db.CarInfo;
6
+import hf.lskj.com.carstockcount.db.Record;
7
+
8
+/**
9
+ * Created by yaoju on 2017/9/6.
10
+ */
11
+
12
+public class ExportBean {
13
+    public List<Record> records;
14
+    public List<CarInfo> cars;
15
+    public ExportBean(List<Record> records, List<CarInfo> cars) {
16
+        this.records = records;
17
+        this.cars = cars;
18
+    }
19
+
20
+    public ExportBean() {
21
+    }
22
+}

+ 183 - 0
app/src/main/java/hf/lskj/com/carstockcount/MyApplication.java

@@ -0,0 +1,183 @@
1
+package hf.lskj.com.carstockcount;
2
+
3
+import android.Manifest;
4
+import android.annotation.TargetApi;
5
+import android.app.Application;
6
+import android.content.pm.PackageManager;
7
+import android.database.sqlite.SQLiteDatabase;
8
+import android.os.Build;
9
+import android.os.Environment;
10
+import android.os.Handler;
11
+import android.text.format.DateFormat;
12
+import android.util.Log;
13
+
14
+import com.tencent.bugly.crashreport.CrashReport;
15
+
16
+import java.io.File;
17
+import java.io.FileWriter;
18
+import java.io.IOException;
19
+import java.io.PrintWriter;
20
+import java.util.Date;
21
+
22
+import hf.lskj.com.carstockcount.activity.MainActivity;
23
+import hf.lskj.com.carstockcount.db.DaoMaster;
24
+import hf.lskj.com.carstockcount.db.DaoSession;
25
+import hf.lskj.com.carstockcount.db.User;
26
+
27
+
28
+public class MyApplication extends Application {
29
+    private static MyApplication instance;
30
+    public static final boolean isDebugMode = BuildConfig.DEBUG;
31
+    private DaoMaster.DevOpenHelper mHelper;
32
+    private SQLiteDatabase db;
33
+    private DaoMaster mDaoMaster;
34
+    private DaoSession mDaoSession;
35
+    public static User currentUser;
36
+
37
+    public static class MyHandler extends Handler {
38
+
39
+    }
40
+
41
+    @Override
42
+    public void onCreate() {
43
+        super.onCreate();
44
+        instance = this;
45
+        CrashReport.initCrashReport(getApplicationContext(), "c7b34b5874", isDebugMode);
46
+        setDatabase();
47
+        Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
48
+            @Override
49
+            public void uncaughtException(Thread thread, Throwable ex) {
50
+                createLogs(ex);
51
+                MainActivity.closeUHF();
52
+                android.os.Process.killProcess(android.os.Process.myPid());
53
+            }
54
+        });
55
+    }
56
+
57
+    public static MyApplication getInstances() {
58
+        return instance;
59
+    }
60
+
61
+    /**
62
+     * 设置greenDao
63
+     */
64
+    private void setDatabase() {
65
+        // 通过 DaoMaster 的内部类 DevOpenHelper,你可以得到一个便利的 SQLiteOpenHelper 对象。
66
+        // 可能你已经注意到了,你并不需要去编写「CREATE TABLE」这样的 SQL 语句,因为 greenDAO 已经帮你做了。
67
+        // 注意:默认的 DaoMaster.DevOpenHelper 会在数据库升级时,删除所有的表,意味着这将导致数据的丢失。
68
+        // 所以,在正式的项目中,你还应该做一层封装,来实现数据库的安全升级。
69
+        mHelper = new DaoMaster.DevOpenHelper(this, "dbStockCount", null);
70
+        db = mHelper.getWritableDatabase();
71
+        // 注意:该数据库连接属于 DaoMaster,所以多个 Session 指的是相同的数据库连接。
72
+        mDaoMaster = new DaoMaster(db);
73
+        mDaoSession = mDaoMaster.newSession();
74
+    }
75
+
76
+    public DaoSession getDaoSession() {
77
+        return mDaoSession;
78
+    }
79
+
80
+    public SQLiteDatabase getDb() {
81
+        return db;
82
+    }
83
+
84
+
85
+    private final static String LOG_NAME_HEAD = "OCLog";
86
+    private final static String LOG_SAVE_FOLDER = "/log/";
87
+    private final static boolean SAVE_LOGS = true;
88
+
89
+    /**
90
+     * 创建日志文件
91
+     *
92
+     * @param throwable 要记录的异常
93
+     * @return 执行结果
94
+     */
95
+    private boolean createLogs(Throwable throwable) {
96
+        if (throwable == null || !SAVE_LOGS) {
97
+            return false;
98
+        }
99
+
100
+        if (Build.VERSION.SDK_INT >= 23 && !checkPermission()) {
101
+            Log.e("异常处理--保存日志", "保存失败 , Android 6.0+ 系统. 内存卡读写权限没有获取");
102
+            return false;
103
+        }
104
+
105
+        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
106
+            //如果内存卡或内置储存已经挂载
107
+
108
+            //创建储存目录
109
+            String savePath = Environment.getExternalStorageDirectory().getPath() + LOG_SAVE_FOLDER;
110
+            File file = new File(savePath);
111
+            file.mkdirs();
112
+
113
+            if (file.canWrite()) {
114
+                //如果目录可以写入
115
+
116
+                FileWriter fileWriter;
117
+                PrintWriter printWriter;
118
+
119
+                //得到当前的日期与时间 , 精确到秒
120
+                String exceptionTime = DateFormat.format("yyyy-MM-dd hh:mm:ss", new Date()).toString();
121
+
122
+                //创建日志文件对象
123
+                file = new File(savePath + LOG_NAME_HEAD + "  " + exceptionTime + "  .log");
124
+                try {
125
+                    if (file.createNewFile()) {
126
+                        //如果文件创建成功 , 则写入文件
127
+                        fileWriter = new FileWriter(file, true);
128
+                        printWriter = new PrintWriter(fileWriter);
129
+                        printWriter.println("Date:" + exceptionTime + "\n");
130
+                        printWriter.println("Exception Class Name: ");
131
+                        printWriter.println(throwable.getStackTrace()[0].getClassName());
132
+                        printWriter.println("");
133
+                        printWriter.println("Exception Class Position: ");
134
+                        printWriter.println("Line number: " + throwable.getStackTrace()[0].getLineNumber());
135
+                        printWriter.println("");
136
+                        printWriter.println("Exception Cause: ");
137
+                        printWriter.println(throwable.getCause());
138
+                        printWriter.println("");
139
+                        printWriter.println("-----------------------------------\nException Message: \n");
140
+                        for (int i = 0; i < throwable.getStackTrace().length; i++) {
141
+                            printWriter.println(throwable.getStackTrace()[i]);
142
+                        }
143
+                        //清空与关闭用到的流
144
+                        printWriter.flush();
145
+                        fileWriter.flush();
146
+                        printWriter.close();
147
+                        fileWriter.close();
148
+                        Log.w("异常处理--保存日志", "日志保存成功");
149
+                        return true;
150
+                    } else {
151
+                        Log.e("异常处理--保存日志", "保存失败 , 存在相同名称的日志文件");
152
+                        return false;
153
+                    }
154
+                } catch (IOException e) {
155
+                    Log.e("异常处理--保存日志", "保存失败 , 无法创建日志文件或写入流失败");
156
+                    return false;
157
+                }
158
+
159
+            } else {
160
+                //目录不可写入 , 操作失败
161
+                Log.e("异常处理--保存日志", "保存失败 , 无法写入目录");
162
+                file = null;
163
+                return false;
164
+            }
165
+
166
+        } else {
167
+            Log.e("异常处理--保存日志", "保存失败 , 储存未挂载");
168
+            return false;
169
+        }
170
+
171
+    }
172
+
173
+    /**
174
+     * 检查内存卡读写权限 针对Android 6.0+
175
+     *
176
+     * @return 是否有权限
177
+     */
178
+    @TargetApi(23)
179
+    private boolean checkPermission() {
180
+        return checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
181
+    }
182
+
183
+}

+ 31 - 0
app/src/main/java/hf/lskj/com/carstockcount/RequestUtils.java

@@ -0,0 +1,31 @@
1
+package hf.lskj.com.carstockcount;
2
+
3
+import java.io.IOException;
4
+
5
+import okhttp3.Call;
6
+import okhttp3.Callback;
7
+import okhttp3.MediaType;
8
+import okhttp3.OkHttpClient;
9
+import okhttp3.Request;
10
+import okhttp3.RequestBody;
11
+import okhttp3.Response;
12
+
13
+/**
14
+ * Created by yaoju on 2017/8/1.
15
+ */
16
+
17
+public class RequestUtils {
18
+    public static final MediaType JSON
19
+            = MediaType.parse("application/json; charset=utf-8");
20
+
21
+    static OkHttpClient client = new OkHttpClient();
22
+
23
+    public static void post(String url, String json,Callback callback){
24
+        RequestBody body = RequestBody.create(JSON, json);
25
+        Request request = new Request.Builder()
26
+                .url(url)
27
+                .post(body)
28
+                .build();
29
+        client.newCall(request).enqueue(callback);
30
+    }
31
+}

+ 161 - 0
app/src/main/java/hf/lskj/com/carstockcount/activity/BaseActivity.java

@@ -0,0 +1,161 @@
1
+package hf.lskj.com.carstockcount.activity;
2
+
3
+
4
+import android.app.ProgressDialog;
5
+import android.content.Context;
6
+import android.content.Intent;
7
+import android.content.pm.ActivityInfo;
8
+import android.os.Bundle;
9
+import android.support.v7.app.AppCompatActivity;
10
+import android.view.MenuItem;
11
+import android.view.MotionEvent;
12
+import android.view.View;
13
+import android.view.inputmethod.InputMethodManager;
14
+import android.widget.EditText;
15
+
16
+import org.greenrobot.eventbus.Subscribe;
17
+
18
+import hf.lskj.com.carstockcount.event.ExitEvent;
19
+import hf.lskj.com.carstockcount.utils.KeyBoardUtils;
20
+import hf.lskj.com.carstockcount.utils.LogUtils;
21
+
22
+/*
23
+Activity公共基类
24
+封装ActionBar的常用方法
25
+提供ProgressDialog
26
+ */
27
+public class BaseActivity extends AppCompatActivity {
28
+    protected ProgressDialog sPd;
29
+    protected final String TAG = getClass().getSimpleName();
30
+
31
+    @Override
32
+    protected void onCreate(Bundle savedInstanceState) {
33
+        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
34
+        super.onCreate(savedInstanceState);
35
+
36
+        sPd = new ProgressDialog(this);
37
+        sPd.setCanceledOnTouchOutside(false);
38
+        KeyBoardUtils.closeKeybord(this);
39
+
40
+    }
41
+
42
+    @Override
43
+    protected void onStop() {
44
+        super.onStop();
45
+    }
46
+
47
+    protected static void startActivity(Context context, Class<?> cls) {
48
+        Intent intent = new Intent(context, cls);
49
+        context.startActivity(intent);
50
+    }
51
+
52
+    @Override
53
+    public void setTitle(CharSequence title) {
54
+        super.setTitle(title);
55
+        setTitle(title, true);
56
+    }
57
+
58
+    protected void setTitle(CharSequence title, boolean displayHomeAsUp) {
59
+        if (getSupportActionBar() != null) {
60
+            getSupportActionBar().setTitle(title);
61
+            getSupportActionBar().setDisplayHomeAsUpEnabled(displayHomeAsUp);
62
+            getSupportActionBar().setDisplayShowHomeEnabled(displayHomeAsUp);
63
+        }
64
+    }
65
+
66
+
67
+    @Override
68
+    protected void onResume() {
69
+        super.onResume();
70
+        /*
71
+          设置为竖屏
72
+         */
73
+        if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
74
+            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
75
+        }
76
+        LogUtils.i("className", getClass().getName());
77
+    }
78
+
79
+    @Override
80
+    protected void onPause() {
81
+        super.onPause();
82
+        KeyBoardUtils.closeKeybord(this);
83
+    }
84
+
85
+    @Override
86
+    public boolean onOptionsItemSelected(MenuItem item) {
87
+        switch (item.getItemId()) {
88
+            case android.R.id.home:
89
+                finish();
90
+                break;
91
+        }
92
+        return super.onOptionsItemSelected(item);
93
+    }
94
+
95
+    public void showPd(String msg) {
96
+        if (sPd == null) {
97
+            return;
98
+        }
99
+        if (sPd.isShowing()) {
100
+            return;
101
+        }
102
+        sPd.setMessage(msg);
103
+        sPd.show();
104
+    }
105
+
106
+    public void showPd() {
107
+        showPd("请稍候...");
108
+    }
109
+
110
+    public void cancelPd() {
111
+        if (sPd == null) {
112
+            return;
113
+        }
114
+        sPd.cancel();
115
+    }
116
+
117
+    @Subscribe()
118
+    public void onMessageEvent(ExitEvent event) {
119
+        finish();
120
+    }
121
+
122
+    @Override
123
+    public boolean dispatchTouchEvent(MotionEvent ev) {
124
+        if (ev.getAction() == MotionEvent.ACTION_DOWN) {
125
+            View v = getCurrentFocus();
126
+            if (isShouldHideInput(v, ev)) {
127
+
128
+                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
129
+                if (imm != null) {
130
+                    imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
131
+                }
132
+            }
133
+            return super.dispatchTouchEvent(ev);
134
+        }
135
+        // 必不可少,否则所有的组件都不会有TouchEvent了
136
+        if (getWindow().superDispatchTouchEvent(ev)) {
137
+            return true;
138
+        }
139
+        return onTouchEvent(ev);
140
+    }
141
+
142
+    public boolean isShouldHideInput(View v, MotionEvent event) {
143
+        if (v != null && (v instanceof EditText)) {
144
+            int[] leftTop = {0, 0};
145
+            //获取输入框当前的location位置
146
+            v.getLocationInWindow(leftTop);
147
+            int left = leftTop[0];
148
+            int top = leftTop[1];
149
+            int bottom = top + v.getHeight();
150
+            int right = left + v.getWidth();
151
+            if (event.getX() > left && event.getX() < right
152
+                    && event.getY() > top && event.getY() < bottom) {
153
+                // 点击的是输入框区域,保留点击EditText的事件
154
+                return false;
155
+            } else {
156
+                return true;
157
+            }
158
+        }
159
+        return false;
160
+    }
161
+}

+ 224 - 0
app/src/main/java/hf/lskj/com/carstockcount/activity/CarListActivity.java

@@ -0,0 +1,224 @@
1
+package hf.lskj.com.carstockcount.activity;
2
+
3
+import android.content.DialogInterface;
4
+import android.database.sqlite.SQLiteConstraintException;
5
+import android.graphics.Color;
6
+import android.os.Bundle;
7
+import android.os.Environment;
8
+import android.support.v7.app.AlertDialog;
9
+import android.support.v7.widget.AppCompatSpinner;
10
+import android.text.TextUtils;
11
+import android.view.Menu;
12
+import android.view.MenuInflater;
13
+import android.view.MenuItem;
14
+import android.view.View;
15
+import android.widget.AdapterView;
16
+import android.widget.ArrayAdapter;
17
+import android.widget.ListView;
18
+import android.widget.SearchView;
19
+import android.widget.TextView;
20
+import android.widget.Toast;
21
+
22
+import com.google.gson.Gson;
23
+import com.google.gson.JsonSyntaxException;
24
+import com.google.gson.reflect.TypeToken;
25
+
26
+import org.greenrobot.eventbus.EventBus;
27
+import org.greenrobot.greendao.query.QueryBuilder;
28
+
29
+import java.io.FileReader;
30
+import java.util.ArrayList;
31
+import java.util.List;
32
+
33
+import butterknife.Bind;
34
+import butterknife.ButterKnife;
35
+import hf.lskj.com.carstockcount.MyApplication;
36
+import hf.lskj.com.carstockcount.R;
37
+import hf.lskj.com.carstockcount.adapter.CarListAdapter;
38
+import hf.lskj.com.carstockcount.db.CarInfo;
39
+import hf.lskj.com.carstockcount.db.CarInfoDao;
40
+import hf.lskj.com.carstockcount.db.Record;
41
+import hf.lskj.com.carstockcount.event.ChooseCarEvent;
42
+import hf.lskj.com.carstockcount.utils.FileUtils;
43
+import hf.lskj.com.carstockcount.utils.PreferencesUtils;
44
+
45
+public class CarListActivity extends BaseActivity {
46
+
47
+    @Bind(R.id.searchView)
48
+    SearchView searchView;
49
+    @Bind(R.id.spi_status)
50
+    AppCompatSpinner spiStatus;
51
+    @Bind(R.id.lv_cars)
52
+    ListView lvCars;
53
+    @Bind(R.id.view_root)
54
+    View rootView;
55
+    @Bind(R.id.tv_total)
56
+    TextView tvTotal;
57
+    @Bind(R.id.tv_checked)
58
+    TextView tvChecked;
59
+    @Bind(R.id.tv_not_checked)
60
+    TextView tvNotChecked;
61
+    private String[] statuses = new String[]{"全部", CarInfo.STATUS_IN, CarInfo.STATUS_MOVE, CarInfo.STATUS_WEIPANDAO};
62
+    private CarInfoDao carInfoDao;
63
+    CarListAdapter adapter;
64
+    List<CarInfo> cars = new ArrayList<>();
65
+    private static final String FIRST_IMPORT = "first_import";
66
+
67
+    @Override
68
+    protected void onCreate(Bundle savedInstanceState) {
69
+        super.onCreate(savedInstanceState);
70
+        setContentView(R.layout.activity_car_list);
71
+        ButterKnife.bind(this);
72
+        setTitle("库存列表");
73
+        carInfoDao = MyApplication.getInstances().getDaoSession().getCarInfoDao();
74
+        searchView.setSubmitButtonEnabled(true);//显示搜索按钮
75
+        searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
76
+            @Override
77
+            public boolean onQueryTextSubmit(String query) {
78
+                return true;
79
+            }
80
+
81
+            @Override
82
+            public boolean onQueryTextChange(String newText) {
83
+                if (TextUtils.isEmpty(newText)) {
84
+                    lvCars.clearTextFilter();
85
+                } else {
86
+                    lvCars.setFilterText(newText);//该方法会通过Adapter得到Filter,然后调用Filter.filter(filterText)
87
+                }
88
+                return false;
89
+            }
90
+        });
91
+        int id = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
92
+        TextView textView = (TextView) searchView.findViewById(id);
93
+        textView.setTextColor(Color.BLACK);
94
+        textView.setHintTextColor(Color.parseColor("#CCCCCC"));
95
+        spiStatus.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, statuses));
96
+        spiStatus.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
97
+            @Override
98
+            public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
99
+                getData(i == 0 ? "" : statuses[i]);
100
+                rootView.requestFocus();
101
+            }
102
+
103
+            @Override
104
+            public void onNothingSelected(AdapterView<?> adapterView) {
105
+
106
+            }
107
+        });
108
+        adapter = new CarListAdapter(this, cars);
109
+        lvCars.setTextFilterEnabled(true);
110
+        lvCars.setAdapter(adapter);
111
+        lvCars.setOnItemClickListener(new AdapterView.OnItemClickListener() {
112
+            @Override
113
+            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
114
+                ChooseCarEvent event = new ChooseCarEvent();
115
+                event.carInfo = adapter.getItem(i);
116
+                EventBus.getDefault().post(event);
117
+                finish();
118
+            }
119
+        });
120
+        getData("");
121
+    }
122
+
123
+    private void getData(String status) {
124
+
125
+        QueryBuilder<CarInfo> queryBuilder = carInfoDao.queryBuilder();
126
+        if (!TextUtils.isEmpty(status)) {
127
+            queryBuilder = queryBuilder.where(CarInfoDao.Properties.Status.eq(status));
128
+        }
129
+        List<CarInfo> list = queryBuilder.orderAsc(CarInfoDao.Properties.StockCountTime).list();
130
+        cars.clear();
131
+        cars.addAll(list);
132
+        if (TextUtils.isEmpty(status)) {
133
+            int checked = 0;
134
+            for (CarInfo carInfo : list) {
135
+                if (Record.TYPE_PANDIAN.equals(carInfo.getStockCountType())) {
136
+                    checked++;
137
+                }
138
+            }
139
+            tvTotal.setText("库存:" + list.size());
140
+            tvChecked.setText("已盘点:" + checked);
141
+            tvNotChecked.setText("未盘点:" + (list.size() - checked));
142
+        }
143
+        adapter.notifyDataSetChanged();
144
+    }
145
+
146
+    @Override
147
+    public boolean onCreateOptionsMenu(Menu menu) {
148
+        new MenuInflater(this).inflate(R.menu.car_list, menu);
149
+        return super.onCreateOptionsMenu(menu);
150
+    }
151
+
152
+    @Override
153
+    public boolean onOptionsItemSelected(MenuItem item) {
154
+        switch (item.getItemId()) {
155
+            case R.id.input:
156
+                if (PreferencesUtils.getBoolean(CarListActivity.this, FIRST_IMPORT, true)) {
157
+                    //第一次导入时本地没有数据,无需提示
158
+                    importData();
159
+                    rootView.requestFocus();
160
+                } else {
161
+                    new AlertDialog.Builder(this)
162
+                            .setTitle("导入")
163
+                            .setMessage("此操作将覆盖本地数据,是否继续")
164
+                            .setNegativeButton("取消", new DialogInterface.OnClickListener() {
165
+                                @Override
166
+                                public void onClick(DialogInterface dialog, int which) {
167
+                                    rootView.requestFocus();
168
+                                }
169
+                            })
170
+                            .setPositiveButton("确定", new DialogInterface.OnClickListener() {
171
+                                @Override
172
+                                public void onClick(DialogInterface dialog, int which) {
173
+                                    importData();
174
+                                    rootView.requestFocus();
175
+                                }
176
+                            }).show();
177
+                }
178
+                break;
179
+        }
180
+        return super.onOptionsItemSelected(item);
181
+    }
182
+
183
+    private void importData() {
184
+        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
185
+            String fileName = Environment.getExternalStorageDirectory().getAbsolutePath() + "/"+ FileUtils.FILE_CARS;
186
+            try (FileReader fileReader = new FileReader(fileName)) {
187
+                Gson gson = new Gson();
188
+                List<CarInfo> inputCars = gson.fromJson(fileReader, new TypeToken<List<CarInfo>>() {
189
+                }.getType());
190
+                if (inputCars == null) {
191
+                    Toast.makeText(this, "导入失败!", Toast.LENGTH_SHORT).show();
192
+                    return;
193
+                }
194
+                carInfoDao.deleteAll();
195
+                int count = 0;
196
+                for (CarInfo inputCar : inputCars) {
197
+                    try {
198
+                        if (carInfoDao.insert(inputCar) > 0) {
199
+                            count++;
200
+                        }
201
+                    } catch (SQLiteConstraintException e) {
202
+                        e.printStackTrace();
203
+                    }
204
+                }
205
+                PreferencesUtils.putBoolean(this, FIRST_IMPORT, false);
206
+                Toast.makeText(this, "成功导入" + count + "条数据", Toast.LENGTH_SHORT).show();
207
+                if (spiStatus.getSelectedItemPosition() == 0) {
208
+                    getData("");
209
+                } else {
210
+                    spiStatus.setSelection(0);
211
+                }
212
+                searchView.setQuery("", false);
213
+            } catch (JsonSyntaxException e) {
214
+                e.printStackTrace();
215
+                Toast.makeText(this, "导入失败,数据格式不正确", Toast.LENGTH_SHORT).show();
216
+            } catch (Exception e) {
217
+                e.printStackTrace();
218
+                Toast.makeText(this, "导入失败,请检查是否有初始化文件,以及文件存放路径、文件名是否正确", Toast.LENGTH_SHORT).show();
219
+            }
220
+        } else {
221
+            Toast.makeText(this, "导入失败,无法读取SD卡!", Toast.LENGTH_SHORT).show();
222
+        }
223
+    }
224
+}

+ 28 - 0
app/src/main/java/hf/lskj/com/carstockcount/activity/LaunchActivity.java

@@ -0,0 +1,28 @@
1
+package hf.lskj.com.carstockcount.activity;
2
+
3
+import android.content.Intent;
4
+import android.os.Bundle;
5
+import android.text.TextUtils;
6
+
7
+import hf.lskj.com.carstockcount.MyApplication;
8
+import hf.lskj.com.carstockcount.db.User;
9
+import hf.lskj.com.carstockcount.db.UserDaoUtils;
10
+
11
+public class LaunchActivity extends BaseActivity {
12
+    @Override
13
+    protected void onCreate(Bundle savedInstanceState) {
14
+        super.onCreate(savedInstanceState);
15
+        UserDaoUtils userDaoUtils=new UserDaoUtils(this);
16
+        User current = userDaoUtils.loadCurrent();
17
+        if (current==null|| TextUtils.isEmpty(current.getLoginId())){
18
+            startActivity(new Intent(this, LoginActivity.class));
19
+            finish();
20
+        }else {
21
+            MyApplication.currentUser=current;
22
+            startActivity(new Intent(this, MainActivity.class));
23
+            finish();
24
+        }
25
+    }
26
+
27
+
28
+}

+ 193 - 0
app/src/main/java/hf/lskj/com/carstockcount/activity/LoginActivity.java

@@ -0,0 +1,193 @@
1
+package hf.lskj.com.carstockcount.activity;
2
+
3
+import android.Manifest;
4
+import android.app.Dialog;
5
+import android.content.DialogInterface;
6
+import android.content.Intent;
7
+import android.content.pm.PackageManager;
8
+import android.os.Build;
9
+import android.os.Bundle;
10
+import android.os.Environment;
11
+import android.support.annotation.NonNull;
12
+import android.support.v4.app.ActivityCompat;
13
+import android.support.v4.content.ContextCompat;
14
+import android.support.v7.app.AlertDialog;
15
+import android.view.KeyEvent;
16
+import android.view.View;
17
+import android.view.inputmethod.EditorInfo;
18
+import android.widget.Button;
19
+import android.widget.EditText;
20
+import android.widget.TextView;
21
+import android.widget.Toast;
22
+
23
+import com.google.gson.Gson;
24
+import com.google.gson.JsonSyntaxException;
25
+import com.google.gson.reflect.TypeToken;
26
+
27
+import java.io.FileReader;
28
+import java.util.List;
29
+
30
+import hf.lskj.com.carstockcount.MyApplication;
31
+import hf.lskj.com.carstockcount.R;
32
+import hf.lskj.com.carstockcount.db.User;
33
+import hf.lskj.com.carstockcount.db.UserDaoUtils;
34
+import hf.lskj.com.carstockcount.utils.FileUtils;
35
+import hf.lskj.com.carstockcount.utils.LogUtils;
36
+
37
+public class LoginActivity extends BaseActivity {
38
+    EditText etLoginName;
39
+    EditText etPassword;
40
+    Button btLogin;
41
+    Button btInit;
42
+    final int REQUEST_WRITE = 1;//申请权限的请求码
43
+
44
+    @Override
45
+    protected void onCreate(Bundle savedInstanceState) {
46
+        super.onCreate(savedInstanceState);
47
+        setContentView(R.layout.activity_login);
48
+        setTitle("登录", false);
49
+        if (getSupportActionBar() != null) {
50
+            getSupportActionBar().hide();
51
+        }
52
+        initView();
53
+        initListener();
54
+
55
+    }
56
+
57
+    private void initView() {
58
+        etLoginName = (EditText) findViewById(R.id.et_uid);
59
+        etPassword = (EditText) findViewById(R.id.et_password);
60
+        btLogin = (Button) findViewById(R.id.bt_login);
61
+        btInit = (Button) findViewById(R.id.bt_init);
62
+    }
63
+
64
+    private void initListener() {
65
+        etPassword.setOnEditorActionListener(new TextView.OnEditorActionListener() {
66
+            @Override
67
+            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
68
+                if (actionId == EditorInfo.IME_ACTION_GO || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
69
+                    btLogin.callOnClick();
70
+                    return true;
71
+                }
72
+                return false;
73
+            }
74
+        });
75
+
76
+        btInit.setOnClickListener(new View.OnClickListener() {
77
+            @Override
78
+            public void onClick(View v) {
79
+                if (Build.VERSION.SDK_INT >= 23) {
80
+                    if (ContextCompat.checkSelfPermission(LoginActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
81
+                        //第一请求权限被取消显示的判断,一般可以不写
82
+                        if (ActivityCompat.shouldShowRequestPermissionRationale(LoginActivity.this,
83
+                                Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
84
+                            showAlert();
85
+                        } else {
86
+                            //2、申请权限: 参数二:权限的数组;参数三:请求码
87
+                            ActivityCompat.requestPermissions(LoginActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_WRITE);
88
+                        }
89
+                    } else {
90
+                        init();
91
+                    }
92
+                } else {
93
+                    init();
94
+                }
95
+            }
96
+        });
97
+
98
+
99
+        btLogin.setOnClickListener(new View.OnClickListener() {
100
+            @Override
101
+            public void onClick(View v) {
102
+                if (etLoginName.getText().length() == 0) {
103
+                    etLoginName.setError("请输入登录名");
104
+                } else if (etPassword.getText().length() == 0) {
105
+                    etPassword.setError("请输入密码");
106
+                } else {
107
+                    UserDaoUtils userDaoUtils = new UserDaoUtils(LoginActivity.this);
108
+                    List<User> users = userDaoUtils.queryByKey(etLoginName.getText().toString());
109
+                    if (users.size() == 0) {
110
+                        if (userDaoUtils.dao.count() == 0) {
111
+                            Toast.makeText(LoginActivity.this, "请先初始化数据", Toast.LENGTH_SHORT).show();
112
+                        } else {
113
+                            Toast.makeText(LoginActivity.this, "此账号不存在", Toast.LENGTH_SHORT).show();
114
+                        }
115
+                    } else {
116
+                        User currentUser = users.get(0);
117
+                        if (!currentUser.getPassword().equals(etPassword.getText().toString())) {
118
+                            Toast.makeText(LoginActivity.this, "密码不正确", Toast.LENGTH_SHORT).show();
119
+                        } else {
120
+                            currentUser.setCurrent(true);
121
+                            userDaoUtils.update(currentUser);
122
+                            MyApplication.currentUser = currentUser;
123
+                            startActivity(new Intent(LoginActivity.this, MainActivity.class));
124
+                            finish();
125
+                        }
126
+                    }
127
+                }
128
+            }
129
+        });
130
+    }
131
+
132
+    private void init() {
133
+        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
134
+            String fileName = Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + FileUtils.FILE_INIT;
135
+            LogUtils.i(fileName);
136
+            try (FileReader fileReader = new FileReader(fileName)) {
137
+                Gson gson = new Gson();
138
+                List<User> initData = gson.fromJson(fileReader, new TypeToken<List<User>>() {
139
+                }.getType());
140
+                if (initData == null || initData.size() == 0) {
141
+                    Toast.makeText(LoginActivity.this, "初始化失败!", Toast.LENGTH_SHORT).show();
142
+                    return;
143
+                }
144
+                UserDaoUtils userDaoUtils = new UserDaoUtils(LoginActivity.this);
145
+                userDaoUtils.dao.deleteAll();
146
+                for (User user : initData) {
147
+                    userDaoUtils.insert(user);
148
+                }
149
+                Toast.makeText(LoginActivity.this, "初始化成功", Toast.LENGTH_SHORT).show();
150
+            } catch (JsonSyntaxException e) {
151
+                e.printStackTrace();
152
+                Toast.makeText(this, "导入失败,数据格式不正确", Toast.LENGTH_SHORT).show();
153
+            } catch (Exception e) {
154
+                e.printStackTrace();
155
+                Toast.makeText(LoginActivity.this, "初始化失败,请检查是否有初始化文件,以及文件存放路径、文件名是否正确", Toast.LENGTH_SHORT).show();
156
+            }
157
+        } else {
158
+            Toast.makeText(LoginActivity.this, "初始化失败,无法读取SD卡!", Toast.LENGTH_SHORT).show();
159
+        }
160
+    }
161
+
162
+    private void showAlert() {
163
+        Dialog alertDialog = new AlertDialog.Builder(this).
164
+                setTitle("权限说明").
165
+                setMessage("我们需要这个权限来初始化APP运行所必要的数据").
166
+                setIcon(R.mipmap.ic_launcher).
167
+                setPositiveButton("确定", new DialogInterface.OnClickListener() {
168
+
169
+                    @Override
170
+                    public void onClick(DialogInterface dialog, int which) {
171
+                        //2、申请权限: 参数二:权限的数组;参数三:请求码
172
+                        ActivityCompat.requestPermissions(LoginActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_WRITE);
173
+                    }
174
+                }).
175
+                setNegativeButton("取消", new DialogInterface.OnClickListener() {
176
+
177
+                    @Override
178
+                    public void onClick(DialogInterface dialog, int which) {
179
+                    }
180
+                }).
181
+                create();
182
+        alertDialog.show();
183
+    }
184
+
185
+    @Override
186
+    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
187
+        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
188
+        if (requestCode == REQUEST_WRITE && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
189
+            init();
190
+        }
191
+
192
+    }
193
+}

+ 206 - 0
app/src/main/java/hf/lskj/com/carstockcount/activity/MainActivity.java

@@ -0,0 +1,206 @@
1
+package hf.lskj.com.carstockcount.activity;
2
+
3
+import android.media.AudioManager;
4
+import android.support.design.widget.TabLayout;
5
+import android.support.v4.app.Fragment;
6
+import android.support.v4.app.FragmentPagerAdapter;
7
+import android.support.v4.view.ViewPager;
8
+import android.os.Bundle;
9
+import android.text.TextUtils;
10
+import android.util.Log;
11
+import android.view.KeyEvent;
12
+
13
+import org.greenrobot.eventbus.EventBus;
14
+import org.greenrobot.eventbus.Subscribe;
15
+
16
+import hf.lskj.com.carstockcount.R;
17
+import hf.lskj.com.carstockcount.event.ChooseCarEvent;
18
+import hf.lskj.com.carstockcount.event.ChooseRecordEvent;
19
+import hf.lskj.com.carstockcount.event.ExitEvent;
20
+import hf.lskj.com.carstockcount.fragment.BindFragment;
21
+import hf.lskj.com.carstockcount.fragment.MeFragment;
22
+import hf.lskj.com.carstockcount.fragment.StockCountFragment;
23
+import hf.lskj.com.carstockcount.utils.ToastUtils;
24
+import hf.lskj.com.carstockcount.utils.UHF.ShellUtils;
25
+import hf.lskj.com.carstockcount.utils.UHF.UHFClient;
26
+
27
+public class MainActivity extends BaseActivity {
28
+    public static String open_1 = "echo 1 > /sys/devices/soc.0/xt_dev.68/xt_uhf_en";
29
+    public static String open_2 = "echo 0 >/sys/devices/soc.0/xt_dev.68/xt_uart_a";
30
+    public static String open_3 = "echo 1 >/sys/devices/soc.0/xt_dev.68/xt_uart_b";
31
+
32
+    public static String close_1 = "echo 0 > /sys/devices/soc.0/xt_dev.68/xt_uhf_en";
33
+    public static String close_2 = "echo 0 >/sys/devices/soc.0/xt_dev.68/xt_uart_a";
34
+    public static String close_3 = "echo 0 >/sys/devices/soc.0/xt_dev.68/xt_uart_b";
35
+    private FragmentPagerAdapter pagerAdapter;
36
+    private ViewPager mViewPager;
37
+    private TabLayout.Tab one, two, three;
38
+    private StockCountFragment stockCountFragment;
39
+    private BindFragment bindFragment;
40
+
41
+    @Override
42
+    protected void onCreate(Bundle savedInstanceState) {
43
+        super.onCreate(savedInstanceState);
44
+        setContentView(R.layout.activity_main);
45
+        setTitle("RFID智能盘库管理", false);
46
+        initViews();
47
+        Boolean ret = ShellUtils.checkRootPermission();
48
+        Log.e("rfid", "ret=" + ret);
49
+        ShellUtils.execCommand(open_1, ret);
50
+        ShellUtils.execCommand(open_2, ret);
51
+        ShellUtils.execCommand(open_3, ret);
52
+        setVolumeControlStream(AudioManager.STREAM_MUSIC);
53
+    }
54
+
55
+    @Override
56
+    protected void onPause() {
57
+        super.onPause();
58
+
59
+    }
60
+
61
+    private void initViews() {
62
+        TabLayout mTablayout = (TabLayout) findViewById(R.id.tabLayout);
63
+        mViewPager = (ViewPager) findViewById(R.id.viewPager);
64
+        pagerAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
65
+
66
+            private String[] mTitles = new String[]{"关联标签", "盘点", "我"};
67
+
68
+            @Override
69
+            public Fragment getItem(int position) {
70
+                if (position == 1) {
71
+                    stockCountFragment = new StockCountFragment();
72
+                    return stockCountFragment;
73
+                } else if (position == 2) {
74
+                    return new MeFragment();
75
+                } else {
76
+                    bindFragment = new BindFragment();
77
+                    return bindFragment;
78
+                }
79
+            }
80
+
81
+            @Override
82
+            public int getCount() {
83
+                return mTitles.length;
84
+            }
85
+
86
+            @Override
87
+            public CharSequence getPageTitle(int position) {
88
+                return mTitles[position];
89
+            }
90
+
91
+        };
92
+        mViewPager.setAdapter(pagerAdapter);
93
+
94
+        mTablayout.setupWithViewPager(mViewPager);
95
+
96
+        one = mTablayout.getTabAt(0);
97
+        two = mTablayout.getTabAt(1);
98
+        if (two != null) {
99
+            two.select();
100
+        }
101
+        three = mTablayout.getTabAt(2);
102
+
103
+        one.setIcon(getResources().getDrawable(R.drawable.guanlian));
104
+        two.setIcon(getResources().getDrawable(R.drawable.pandian));
105
+        three.setIcon(getResources().getDrawable(R.drawable.user));
106
+        mTablayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
107
+            @Override
108
+            public void onTabSelected(TabLayout.Tab tab) {
109
+
110
+            }
111
+
112
+            @Override
113
+            public void onTabUnselected(TabLayout.Tab tab) {
114
+
115
+            }
116
+
117
+            @Override
118
+            public void onTabReselected(TabLayout.Tab tab) {
119
+                if (tab.getPosition() == 1) {
120
+                    stockCountFragment.setCountRecord(null);
121
+                }
122
+            }
123
+        });
124
+    }
125
+
126
+    @Override
127
+    protected void onStart() {
128
+        super.onStart();
129
+        if (!EventBus.getDefault().isRegistered(this)) {
130
+            EventBus.getDefault().register(this);
131
+        }
132
+    }
133
+
134
+    private long exitTime = 0;
135
+
136
+    @Override
137
+    protected void onDestroy() {
138
+        super.onDestroy();
139
+        EventBus.getDefault().unregister(this);
140
+        closeUHF();
141
+    }
142
+
143
+    /**
144
+     * 断开连接 关闭电源
145
+     **/
146
+    public static void closeUHF() {
147
+        UHFClient.Disconnect();
148
+        Boolean ret = ShellUtils.checkRootPermission();
149
+        Log.e("TAG", "ret=" + ret);
150
+        ShellUtils.execCommand(close_1, ret);
151
+        ShellUtils.execCommand(close_2, ret);
152
+        ShellUtils.execCommand(close_3, ret);
153
+    }
154
+
155
+    @Override
156
+    public boolean onKeyDown(int keyCode, KeyEvent event) {
157
+        if (event.getAction() == KeyEvent.ACTION_DOWN) {
158
+            switch (keyCode) {
159
+                case KeyEvent.KEYCODE_BACK:
160
+                    if ((System.currentTimeMillis() - exitTime) > 1500) {
161
+                        ToastUtils.showShort("再按一次退出程序");
162
+                        exitTime = System.currentTimeMillis();
163
+                    } else {
164
+                        EventBus.getDefault().post(new ExitEvent());
165
+                    }
166
+                    return true;
167
+                case 224://scan键
168
+                    switch (mViewPager.getCurrentItem()) {
169
+                        case 0:
170
+                            bindFragment.onKeyDown(keyCode, event);
171
+                            break;
172
+                        case 1:
173
+                            stockCountFragment.onKeyDown(keyCode, event);
174
+                            break;
175
+                    }
176
+                    break;
177
+                case 131://F1
178
+                    break;
179
+                case 132://F2
180
+                    break;
181
+            }
182
+        }
183
+        return super.onKeyDown(keyCode, event);
184
+    }
185
+
186
+    @Subscribe()
187
+    public void onMessageEvent(ChooseRecordEvent event) {
188
+        if (event.record != null) {
189
+            two.select();
190
+            stockCountFragment.setCountRecord(event.record);//查看盘点记录
191
+        }
192
+    }
193
+
194
+    @Subscribe()
195
+    public void onMessageEvent(ChooseCarEvent event) {
196
+        if (event.carInfo != null) {
197
+            if (TextUtils.isEmpty(event.carInfo.getRfid())) {
198
+                one.select();
199
+                bindFragment.setCarInfo(event.carInfo);//去关联标签
200
+            } else {
201
+                two.select();
202
+                stockCountFragment.setCarInfo(event.carInfo);//去做异常盘点
203
+            }
204
+        }
205
+    }
206
+}

+ 183 - 0
app/src/main/java/hf/lskj/com/carstockcount/activity/RecordListActivity.java

@@ -0,0 +1,183 @@
1
+package hf.lskj.com.carstockcount.activity;
2
+
3
+import android.app.DatePickerDialog;
4
+import android.os.Bundle;
5
+import android.os.Environment;
6
+import android.support.v7.widget.AppCompatSpinner;
7
+import android.text.TextUtils;
8
+import android.view.Menu;
9
+import android.view.MenuItem;
10
+import android.view.View;
11
+import android.widget.AdapterView;
12
+import android.widget.ArrayAdapter;
13
+import android.widget.DatePicker;
14
+import android.widget.ListView;
15
+import android.widget.TextView;
16
+import android.widget.Toast;
17
+
18
+import com.google.gson.Gson;
19
+
20
+import org.greenrobot.eventbus.EventBus;
21
+import org.greenrobot.greendao.query.QueryBuilder;
22
+
23
+import java.io.FileWriter;
24
+import java.io.IOException;
25
+import java.util.ArrayList;
26
+import java.util.Calendar;
27
+import java.util.List;
28
+
29
+import butterknife.Bind;
30
+import butterknife.ButterKnife;
31
+import hf.lskj.com.carstockcount.ExportBean;
32
+import hf.lskj.com.carstockcount.MyApplication;
33
+import hf.lskj.com.carstockcount.R;
34
+import hf.lskj.com.carstockcount.adapter.CountRecordAdapter;
35
+import hf.lskj.com.carstockcount.db.MyDao;
36
+import hf.lskj.com.carstockcount.db.CarInfo;
37
+import hf.lskj.com.carstockcount.db.CarInfoDao;
38
+import hf.lskj.com.carstockcount.db.Record;
39
+import hf.lskj.com.carstockcount.db.RecordDao;
40
+import hf.lskj.com.carstockcount.event.ChooseRecordEvent;
41
+import hf.lskj.com.carstockcount.utils.DateUtils;
42
+import hf.lskj.com.carstockcount.utils.FileUtils;
43
+import hf.lskj.com.carstockcount.utils.ToastUtils;
44
+
45
+public class RecordListActivity extends BaseActivity {
46
+
47
+    @Bind(R.id.tv_date)
48
+    TextView tvDate;
49
+    @Bind(R.id.lv_records)
50
+    ListView lvRecords;
51
+    @Bind(R.id.spi_status)
52
+    AppCompatSpinner spiStatus;
53
+    @Bind(R.id.view_root)
54
+    View rootView;
55
+    private Calendar calendar;
56
+    private List<Record> records = new ArrayList<>();
57
+    private CountRecordAdapter adapter;
58
+    private String[] statuses = new String[]{"全部", Record.TYPE_PANDIAN, Record.TYPE_BANGDING, Record.TYPE_JIEBANG};
59
+
60
+    @Override
61
+    protected void onCreate(Bundle savedInstanceState) {
62
+        super.onCreate(savedInstanceState);
63
+        setContentView(R.layout.activity_count_list);
64
+        ButterKnife.bind(this);
65
+        setTitle("操作记录");
66
+        calendar = Calendar.getInstance();
67
+        tvDate.setText(DateUtils.formatDate(calendar.getTime()));
68
+        setListener();
69
+        adapter = new CountRecordAdapter(this, records);
70
+        lvRecords.setAdapter(adapter);
71
+        getRecords();
72
+    }
73
+
74
+    private void setListener() {
75
+        tvDate.setOnClickListener(new View.OnClickListener() {
76
+            @Override
77
+            public void onClick(View view) {
78
+                DatePickerDialog dialog = new DatePickerDialog(RecordListActivity.this,
79
+                        new DatePickerDialog.OnDateSetListener() {
80
+                            @Override
81
+                            public void onDateSet(DatePicker datePicker, int i, int i1, int i2) {
82
+                                tvDate.setText(i + "-" + (i1 + 1) + "-" + i2);
83
+                                calendar.set(i, i1, i2);
84
+                                getRecords();
85
+
86
+                            }
87
+                        }, calendar.get(Calendar.YEAR),
88
+                        calendar.get(Calendar.MONTH),
89
+                        calendar.get(Calendar.DAY_OF_MONTH));
90
+                dialog.show();
91
+            }
92
+        });
93
+        lvRecords.setOnItemClickListener(new AdapterView.OnItemClickListener() {
94
+            @Override
95
+            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
96
+                ChooseRecordEvent event = new ChooseRecordEvent();
97
+                event.record = adapter.getItem(i);
98
+                EventBus.getDefault().post(event);
99
+                finish();
100
+            }
101
+        });
102
+        spiStatus.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, statuses));
103
+        spiStatus.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
104
+            @Override
105
+            public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
106
+                getRecords();
107
+                rootView.requestFocus();
108
+            }
109
+
110
+            @Override
111
+            public void onNothingSelected(AdapterView<?> adapterView) {
112
+
113
+            }
114
+        });
115
+    }
116
+
117
+    private void getRecords() {
118
+        String status = spiStatus.getSelectedItemPosition() == 0 ? "" : statuses[spiStatus.getSelectedItemPosition()];
119
+        Calendar temp = (Calendar) calendar.clone();
120
+        temp.set(Calendar.HOUR_OF_DAY, 0);
121
+        temp.set(Calendar.MINUTE, 0);
122
+        String startTime = temp.getTimeInMillis() + "";
123
+        temp.add(Calendar.DAY_OF_MONTH, 1);
124
+        String endTime = temp.getTimeInMillis() + "";
125
+        RecordDao recordDao = MyApplication.getInstances().getDaoSession().getRecordDao();
126
+        QueryBuilder<Record> queryBuilder = recordDao.queryBuilder();
127
+        if (!TextUtils.isEmpty(status)) {
128
+            queryBuilder = queryBuilder.where(RecordDao.Properties.Type.eq(status));
129
+        }
130
+        List<Record> list = queryBuilder
131
+                .where(RecordDao.Properties.CreateTime.between(startTime, endTime))
132
+                .orderDesc(RecordDao.Properties.CreateTime)
133
+                .list();
134
+        records.clear();
135
+        records.addAll(list);
136
+        adapter.notifyDataSetChanged();
137
+    }
138
+
139
+    @Override
140
+    public boolean onCreateOptionsMenu(Menu menu) {
141
+        menu.add("导出").setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
142
+        return super.onCreateOptionsMenu(menu);
143
+    }
144
+
145
+    @Override
146
+    public boolean onOptionsItemSelected(MenuItem item) {
147
+        if (item.getTitle() != null && item.getTitle().equals("导出")) {
148
+            if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
149
+                showPd("正在导出...");
150
+                String fileName = Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + FileUtils.FILE_RECORD;
151
+                try (FileWriter fileWriter = new FileWriter(fileName, false)) {
152
+                    CarInfoDao carInfoDao = MyApplication.getInstances().getDaoSession().getCarInfoDao();
153
+                    List<CarInfo> cars = carInfoDao.loadAll();
154
+                    List<Record> tmpRecords=new ArrayList<>(records);
155
+                    boolean b = MyDao.saveToDb(cars, tmpRecords);
156
+                    if (b) {
157
+                        ExportBean exportBean = new ExportBean(tmpRecords, cars);
158
+                        String data = new Gson().toJson(exportBean);
159
+                        fileWriter.write(data);
160
+                        records.clear();
161
+                        records.addAll(tmpRecords);
162
+                        adapter.notifyDataSetChanged();
163
+                        FileUtils.fileScan(fileName);
164
+                        cancelPd();
165
+                        Toast.makeText(RecordListActivity.this, "导出成功", Toast.LENGTH_SHORT).show();
166
+                    }else{
167
+                        ToastUtils.showShort("导出失败,本地数据保存失败");
168
+                    }
169
+                } catch (IOException e) {
170
+                    cancelPd();
171
+                    e.printStackTrace();
172
+                    Toast.makeText(RecordListActivity.this, "导出失败!", Toast.LENGTH_SHORT).show();
173
+                }
174
+            } else {
175
+                Toast.makeText(RecordListActivity.this, "导出失败,无法读取SD卡!", Toast.LENGTH_SHORT).show();
176
+            }
177
+            return true;
178
+        }
179
+        return super.onOptionsItemSelected(item);
180
+    }
181
+
182
+
183
+}

+ 173 - 0
app/src/main/java/hf/lskj/com/carstockcount/adapter/CarListAdapter.java

@@ -0,0 +1,173 @@
1
+package hf.lskj.com.carstockcount.adapter;
2
+
3
+import android.content.Context;
4
+import android.graphics.Color;
5
+import android.graphics.drawable.Drawable;
6
+import android.text.TextUtils;
7
+import android.view.LayoutInflater;
8
+import android.view.View;
9
+import android.view.ViewGroup;
10
+import android.widget.BaseAdapter;
11
+import android.widget.Filter;
12
+import android.widget.Filterable;
13
+import android.widget.TextView;
14
+
15
+import java.util.ArrayList;
16
+import java.util.List;
17
+
18
+import butterknife.Bind;
19
+import butterknife.ButterKnife;
20
+import hf.lskj.com.carstockcount.R;
21
+import hf.lskj.com.carstockcount.db.CarInfo;
22
+import hf.lskj.com.carstockcount.db.Record;
23
+import hf.lskj.com.carstockcount.utils.DateUtils;
24
+
25
+import static hf.lskj.com.carstockcount.db.CarInfo.STATUS_MOVE;
26
+import static hf.lskj.com.carstockcount.db.CarInfo.STATUS_WEIPANDAO;
27
+
28
+/**
29
+ * Created by yaoju on 2017/8/2.
30
+ */
31
+
32
+public class CarListAdapter extends BaseAdapter implements Filterable {
33
+    private Context mContext;
34
+    private List<CarInfo> mCarList;//这个数据是会改变的,所以要有个变量来备份一下原始数据
35
+    private List<CarInfo> backData;//用来备份原始数据
36
+    private LayoutInflater mInflater;
37
+    private MyFilter mFilter;
38
+    private Drawable drawableIn, drawableOut, drawableMove;
39
+
40
+    public CarListAdapter(Context context, List<CarInfo> mCarList) {
41
+        this.mContext = context;
42
+        this.mCarList = mCarList;
43
+        backData = mCarList;
44
+        mInflater = LayoutInflater.from(context);
45
+        drawableIn = context.getResources().getDrawable(R.mipmap.zaiku_icon);
46
+        drawableOut = context.getResources().getDrawable(R.mipmap.chuku_icon);
47
+        drawableMove = context.getResources().getDrawable(R.mipmap.yidong_icon);
48
+        drawableIn.setBounds(0, 0, drawableIn.getMinimumWidth(), drawableIn.getMinimumHeight());
49
+        drawableOut.setBounds(0, 0, drawableOut.getMinimumWidth(), drawableOut.getMinimumHeight());
50
+        drawableMove.setBounds(0, 0, drawableMove.getMinimumWidth(), drawableMove.getMinimumHeight());
51
+    }
52
+
53
+    @Override
54
+    public int getCount() {
55
+        return mCarList.size();
56
+    }
57
+
58
+    @Override
59
+    public CarInfo getItem(int i) {
60
+        return mCarList.get(i);
61
+    }
62
+
63
+    @Override
64
+    public long getItemId(int i) {
65
+        return 0;
66
+    }
67
+
68
+    @Override
69
+    public View getView(int i, View view, ViewGroup viewGroup) {
70
+        ViewHolder viewHolder;
71
+        if (view == null) {
72
+            view = mInflater.inflate(R.layout.item_car, viewGroup, false);
73
+            viewHolder = new ViewHolder(view);
74
+            view.setTag(viewHolder);
75
+        } else {
76
+            viewHolder = (ViewHolder) view.getTag();
77
+        }
78
+        CarInfo carInfo = getItem(i);
79
+        viewHolder.tvVin.setText(carInfo.getVin());
80
+        viewHolder.tvRfid.setText(carInfo.getRfid());
81
+        viewHolder.tvTime.setText(DateUtils.format(carInfo.getStockCountTime()));
82
+        viewHolder.tvStatus.setText(carInfo.getStatus());
83
+        switch (carInfo.getStatus()) {
84
+            case STATUS_MOVE:
85
+                viewHolder.tvStatus.setCompoundDrawables(null, drawableMove, null, null);
86
+                viewHolder.tvStatus.setTextColor(mContext.getResources().getColor(R.color.car_move));
87
+                break;
88
+            case STATUS_WEIPANDAO:
89
+                viewHolder.tvStatus.setCompoundDrawables(null, drawableOut, null, null);
90
+                viewHolder.tvStatus.setTextColor(mContext.getResources().getColor(R.color.car_out));
91
+                break;
92
+            default://在库
93
+                viewHolder.tvStatus.setCompoundDrawables(null, drawableIn, null, null);
94
+                viewHolder.tvStatus.setTextColor(mContext.getResources().getColor(R.color.car_in));
95
+                break;
96
+        }
97
+        if (Record.TYPE_PANDIAN.equals(carInfo.getStockCountType())){
98
+            view.setBackgroundColor(Color.parseColor("#E6EFFF"));
99
+        }else{
100
+            view.setBackgroundResource(android.R.color.transparent);
101
+        }
102
+        return view;
103
+    }
104
+
105
+    //当ListView调用setTextFilter()方法的时候,便会调用该方法
106
+    @Override
107
+    public Filter getFilter() {
108
+        if (null == mFilter) {
109
+            mFilter = new MyFilter();
110
+        }
111
+        return mFilter;
112
+    }
113
+
114
+    // 自定义Filter类
115
+    private class MyFilter extends Filter {
116
+        @Override
117
+        // 该方法在子线程中执行
118
+        // 自定义过滤规则
119
+        protected FilterResults performFiltering(CharSequence constraint) {
120
+            FilterResults results = new FilterResults();
121
+            List<CarInfo> newValues = new ArrayList<>();
122
+            // 如果搜索框内容为空,就恢复原始数据
123
+            if (TextUtils.isEmpty(constraint)) {
124
+                newValues = backData;
125
+            } else {
126
+                String filterString = constraint.toString().trim()
127
+                        .toLowerCase();
128
+                if (filterString.equals("")) {
129
+                    newValues = backData;
130
+                } else {
131
+                    // 过滤出新数据
132
+                    for (CarInfo str : backData) {
133
+                        if (str.getVin().contains(constraint)) {
134
+                            newValues.add(str);
135
+                        }
136
+                    }
137
+                }
138
+            }
139
+
140
+            results.values = newValues;
141
+            results.count = newValues.size();
142
+
143
+            return results;
144
+        }
145
+
146
+        //在publishResults方法中告诉适配器更新界面
147
+        @Override
148
+        protected void publishResults(CharSequence constraint,
149
+                                      FilterResults results) {
150
+            mCarList = (List<CarInfo>) results.values;
151
+            if (results.count > 0) {
152
+                notifyDataSetChanged();//通知数据发生了改变
153
+            } else {
154
+                notifyDataSetInvalidated();//通知数据失效
155
+            }
156
+        }
157
+    }
158
+
159
+    static class ViewHolder {
160
+        @Bind(R.id.tv_status)
161
+        TextView tvStatus;
162
+        @Bind(R.id.tv_vin)
163
+        TextView tvVin;
164
+        @Bind(R.id.tv_rfid)
165
+        TextView tvRfid;
166
+        @Bind(R.id.tv_time)
167
+        TextView tvTime;
168
+
169
+        ViewHolder(View view) {
170
+            ButterKnife.bind(this, view);
171
+        }
172
+    }
173
+}

+ 119 - 0
app/src/main/java/hf/lskj/com/carstockcount/adapter/CountRecordAdapter.java

@@ -0,0 +1,119 @@
1
+package hf.lskj.com.carstockcount.adapter;
2
+
3
+import android.content.Context;
4
+import android.graphics.drawable.Drawable;
5
+import android.view.LayoutInflater;
6
+import android.view.View;
7
+import android.view.ViewGroup;
8
+import android.widget.BaseAdapter;
9
+import android.widget.TextView;
10
+
11
+import java.util.List;
12
+
13
+import butterknife.Bind;
14
+import butterknife.ButterKnife;
15
+import hf.lskj.com.carstockcount.R;
16
+import hf.lskj.com.carstockcount.db.Record;
17
+import hf.lskj.com.carstockcount.utils.DateUtils;
18
+
19
+import static hf.lskj.com.carstockcount.db.CarInfo.STATUS_MOVE;
20
+import static hf.lskj.com.carstockcount.db.CarInfo.STATUS_WEIPANDAO;
21
+
22
+/**
23
+ * Created by yaoju on 2017/8/1.
24
+ */
25
+
26
+public class CountRecordAdapter extends BaseAdapter {
27
+    private Context mContext;
28
+    private List<Record> mRecords;
29
+    private LayoutInflater inflater;
30
+
31
+    private Drawable drawableIn, drawableOut, drawableMove;
32
+
33
+    public CountRecordAdapter(Context context, List<Record> records) {
34
+        this.mContext = context;
35
+        this.mRecords = records;
36
+        inflater = LayoutInflater.from(mContext);
37
+        drawableIn = context.getResources().getDrawable(R.mipmap.zaiku_icon);
38
+        drawableOut = context.getResources().getDrawable(R.mipmap.chuku_icon);
39
+        drawableMove = context.getResources().getDrawable(R.mipmap.yidong_icon);
40
+        drawableIn.setBounds(0, 0, drawableIn.getMinimumWidth(), drawableIn.getMinimumHeight());
41
+        drawableOut.setBounds(0, 0, drawableOut.getMinimumWidth(), drawableOut.getMinimumHeight());
42
+        drawableMove.setBounds(0, 0, drawableMove.getMinimumWidth(), drawableMove.getMinimumHeight());
43
+    }
44
+
45
+    @Override
46
+    public int getCount() {
47
+        return mRecords.size();
48
+    }
49
+
50
+    @Override
51
+    public Record getItem(int i) {
52
+        return mRecords.get(i);
53
+    }
54
+
55
+    @Override
56
+    public long getItemId(int i) {
57
+        return 0;
58
+    }
59
+
60
+    @Override
61
+    public View getView(int i, View view, ViewGroup viewGroup) {
62
+        ViewHolder viewHolder;
63
+        if (view == null) {
64
+            view = inflater.inflate(R.layout.item_record, viewGroup, false);
65
+            viewHolder = new ViewHolder(view);
66
+            view.setTag(viewHolder);
67
+        } else {
68
+            viewHolder = (ViewHolder) view.getTag();
69
+        }
70
+        Record record = getItem(i);
71
+        viewHolder.tvVin.setText(record.getVin());
72
+        viewHolder.tvRfid.setText(record.getRfid());
73
+        viewHolder.tvTime.setText(DateUtils.format(record.getCreateTime()));
74
+        viewHolder.tvStatus.setText(record.getStatus());
75
+        switch (record.getStatus()) {
76
+            case STATUS_MOVE:
77
+                viewHolder.tvStatus.setCompoundDrawables(null, drawableMove, null, null);
78
+                viewHolder.tvStatus.setTextColor(mContext.getResources().getColor(R.color.car_move));
79
+                break;
80
+            case STATUS_WEIPANDAO:
81
+                viewHolder.tvStatus.setCompoundDrawables(null, drawableOut, null, null);
82
+                viewHolder.tvStatus.setTextColor(mContext.getResources().getColor(R.color.car_out));
83
+                break;
84
+            default:
85
+                viewHolder.tvStatus.setCompoundDrawables(null, drawableIn, null, null);
86
+                viewHolder.tvStatus.setTextColor(mContext.getResources().getColor(R.color.car_in));
87
+                break;
88
+        }
89
+        switch (record.getType()){
90
+            case Record.TYPE_BANGDING:
91
+                viewHolder.tvTimeTitle.setText("绑定时间:");
92
+                break;
93
+            case Record.TYPE_JIEBANG:
94
+                viewHolder.tvTimeTitle.setText("解绑时间:");
95
+                break;
96
+            default:
97
+                viewHolder.tvTimeTitle.setText("盘点时间:");
98
+                break;
99
+        }
100
+        return view;
101
+    }
102
+
103
+    class ViewHolder {
104
+        @Bind(R.id.tv_status)
105
+        TextView tvStatus;
106
+        @Bind(R.id.tv_vin)
107
+        TextView tvVin;
108
+        @Bind(R.id.tv_rfid)
109
+        TextView tvRfid;
110
+        @Bind(R.id.tv_time_title)
111
+        TextView tvTimeTitle;
112
+        @Bind(R.id.tv_time)
113
+        TextView tvTime;
114
+
115
+        ViewHolder(View view) {
116
+            ButterKnife.bind(this, view);
117
+        }
118
+    }
119
+}

+ 95 - 0
app/src/main/java/hf/lskj/com/carstockcount/adapter/VinAdapter.java

@@ -0,0 +1,95 @@
1
+package hf.lskj.com.carstockcount.adapter;
2
+
3
+import android.content.Context;
4
+import android.support.annotation.LayoutRes;
5
+import android.support.annotation.NonNull;
6
+import android.support.annotation.Nullable;
7
+import android.text.TextUtils;
8
+import android.view.View;
9
+import android.view.ViewGroup;
10
+import android.widget.ArrayAdapter;
11
+import android.widget.Filter;
12
+
13
+import java.util.ArrayList;
14
+import java.util.List;
15
+
16
+import hf.lskj.com.carstockcount.db.CarInfo;
17
+
18
+/**
19
+ * Created by yaoju on 2017/8/3.
20
+ */
21
+
22
+public class VinAdapter extends ArrayAdapter<String> {
23
+
24
+    private MyFilter mFilter;
25
+    private List<String> mVinList;
26
+    private List<String> backData;
27
+
28
+    public VinAdapter(@NonNull Context context, @LayoutRes int resource, @NonNull List<String> vinList) {
29
+        super(context, resource, vinList);
30
+        mVinList = vinList;
31
+        backData = mVinList;
32
+    }
33
+
34
+    @Override
35
+    public int getCount() {
36
+        return mVinList.size();
37
+    }
38
+
39
+    @Nullable
40
+    @Override
41
+    public String getItem(int position) {
42
+        return mVinList.get(position);
43
+    }
44
+
45
+    @Override
46
+    public Filter getFilter() {
47
+        if (mFilter == null) {
48
+            mFilter = new MyFilter();
49
+        }
50
+        return mFilter;
51
+    }
52
+
53
+    // 自定义Filter类
54
+    private class MyFilter extends Filter {
55
+        @Override
56
+        // 该方法在子线程中执行
57
+        // 自定义过滤规则
58
+        protected FilterResults performFiltering(CharSequence constraint) {
59
+            FilterResults results = new FilterResults();
60
+            List<String> newValues = new ArrayList<>();
61
+            // 如果搜索框内容为空,就恢复原始数据
62
+            if (TextUtils.isEmpty(constraint)) {
63
+                newValues = backData;
64
+            } else {
65
+                String filterString = constraint.toString().trim()
66
+                        .toLowerCase();
67
+                if (filterString.equals("")) {
68
+                    newValues = backData;
69
+                } else {
70
+                    // 过滤出新数据
71
+                    for (String str : backData) {
72
+                        if (str.contains(constraint)) {
73
+                            newValues.add(str);
74
+                        }
75
+                    }
76
+                }
77
+            }
78
+            results.values = newValues;
79
+            results.count = newValues.size();
80
+            return results;
81
+        }
82
+
83
+        //在publishResults方法中告诉适配器更新界面
84
+        @Override
85
+        protected void publishResults(CharSequence constraint,
86
+                                      FilterResults results) {
87
+            mVinList = (List<String>) results.values;
88
+            if (results.count > 0) {
89
+                notifyDataSetChanged();//通知数据发生了改变
90
+            } else {
91
+                notifyDataSetInvalidated();//通知数据失效
92
+            }
93
+        }
94
+    }
95
+}

+ 188 - 0
app/src/main/java/hf/lskj/com/carstockcount/db/CarInfo.java

@@ -0,0 +1,188 @@
1
+package hf.lskj.com.carstockcount.db;
2
+
3
+import org.greenrobot.greendao.annotation.Entity;
4
+import org.greenrobot.greendao.annotation.Id;
5
+
6
+import java.io.Serializable;
7
+import java.util.List;
8
+
9
+import org.greenrobot.greendao.annotation.Generated;
10
+import org.greenrobot.greendao.annotation.OrderBy;
11
+import org.greenrobot.greendao.annotation.ToMany;
12
+import org.greenrobot.greendao.DaoException;
13
+import org.greenrobot.greendao.annotation.Transient;
14
+
15
+/**
16
+ * Created by yaoju on 2017/7/31.
17
+ */
18
+@Entity
19
+public class CarInfo implements Serializable {
20
+    static final long serialVersionUID = 42L;
21
+    public static final String STATUS_IN="在库";
22
+    public static final String STATUS_MOVE="移动";
23
+    public static final String STATUS_WEIPANDAO="未盘到";
24
+    @Id
25
+    private String vin;
26
+    private String rfid;
27
+    /*4s店Id*/
28
+    private String storeId;
29
+    private String color;
30
+    /*车型*/
31
+    private String type;
32
+    /*在库 移动 未盘到*/
33
+    private String status;
34
+    private String stockCountTime;
35
+    /*操作类型: 绑定 盘点 解绑*/
36
+    private String stockCountType;
37
+    /*用于盘点导出,记录导出盘点时操作员的登录id*/
38
+    @Transient
39
+    private String operatorId;
40
+    @ToMany(referencedJoinProperty = "vin")
41
+    @OrderBy("createTime DESC")
42
+    private List<Record> records;
43
+    /** Used to resolve relations */
44
+    @Generated(hash = 2040040024)
45
+    private transient DaoSession daoSession;
46
+    /** Used for active entity operations. */
47
+    @Generated(hash = 1794384882)
48
+    private transient CarInfoDao myDao;
49
+    @Generated(hash = 1914507928)
50
+    public CarInfo(String vin, String rfid, String storeId, String color, String type, String status,
51
+            String stockCountTime, String stockCountType) {
52
+        this.vin = vin;
53
+        this.rfid = rfid;
54
+        this.storeId = storeId;
55
+        this.color = color;
56
+        this.type = type;
57
+        this.status = status;
58
+        this.stockCountTime = stockCountTime;
59
+        this.stockCountType = stockCountType;
60
+    }
61
+    @Generated(hash = 850322869)
62
+    public CarInfo() {
63
+    }
64
+
65
+    public String getOperatorId() {
66
+        return operatorId;
67
+    }
68
+
69
+    public void setOperatorId(String operatorId) {
70
+        this.operatorId = operatorId;
71
+    }
72
+
73
+    public String getVin() {
74
+        return this.vin;
75
+    }
76
+    public void setVin(String vin) {
77
+        this.vin = vin;
78
+    }
79
+    public String getRfid() {
80
+        return this.rfid;
81
+    }
82
+    public void setRfid(String rfid) {
83
+        this.rfid = rfid;
84
+    }
85
+    public String getStoreId() {
86
+        return this.storeId;
87
+    }
88
+    public void setStoreId(String storeId) {
89
+        this.storeId = storeId;
90
+    }
91
+    public String getColor() {
92
+        return this.color;
93
+    }
94
+    public void setColor(String color) {
95
+        this.color = color;
96
+    }
97
+    public String getType() {
98
+        return this.type;
99
+    }
100
+    public void setType(String type) {
101
+        this.type = type;
102
+    }
103
+    public String getStatus() {
104
+        return this.status;
105
+    }
106
+    public void setStatus(String status) {
107
+        this.status = status;
108
+    }
109
+    public String getStockCountTime() {
110
+        return this.stockCountTime;
111
+    }
112
+    public void setStockCountTime(String stockCountTime) {
113
+        this.stockCountTime = stockCountTime;
114
+    }
115
+    public String getStockCountType() {
116
+        return this.stockCountType;
117
+    }
118
+    public void setStockCountType(String stockCountType) {
119
+        this.stockCountType = stockCountType;
120
+    }
121
+    /**
122
+     * To-many relationship, resolved on first access (and after reset).
123
+     * Changes to to-many relations are not persisted, make changes to the target entity.
124
+     */
125
+    @Generated(hash = 1485909093)
126
+    public List<Record> getRecords() {
127
+        if (records == null) {
128
+            final DaoSession daoSession = this.daoSession;
129
+            if (daoSession == null) {
130
+                throw new DaoException("Entity is detached from DAO context");
131
+            }
132
+            RecordDao targetDao = daoSession.getRecordDao();
133
+            List<Record> recordsNew = targetDao._queryCarInfo_Records(vin);
134
+            synchronized (this) {
135
+                if (records == null) {
136
+                    records = recordsNew;
137
+                }
138
+            }
139
+        }
140
+        return records;
141
+    }
142
+    /** Resets a to-many relationship, making the next get call to query for a fresh result. */
143
+    @Generated(hash = 3024737)
144
+    public synchronized void resetRecords() {
145
+        records = null;
146
+    }
147
+    /**
148
+     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
149
+     * Entity must attached to an entity context.
150
+     */
151
+    @Generated(hash = 128553479)
152
+    public void delete() {
153
+        if (myDao == null) {
154
+            throw new DaoException("Entity is detached from DAO context");
155
+        }
156
+        myDao.delete(this);
157
+    }
158
+    /**
159
+     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
160
+     * Entity must attached to an entity context.
161
+     */
162
+    @Generated(hash = 1942392019)
163
+    public void refresh() {
164
+        if (myDao == null) {
165
+            throw new DaoException("Entity is detached from DAO context");
166
+        }
167
+        myDao.refresh(this);
168
+    }
169
+    /**
170
+     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
171
+     * Entity must attached to an entity context.
172
+     */
173
+    @Generated(hash = 713229351)
174
+    public void update() {
175
+        if (myDao == null) {
176
+            throw new DaoException("Entity is detached from DAO context");
177
+        }
178
+        myDao.update(this);
179
+    }
180
+    /** called by internal mechanisms, do not call yourself. */
181
+    @Generated(hash = 139986679)
182
+    public void __setDaoSession(DaoSession daoSession) {
183
+        this.daoSession = daoSession;
184
+        myDao = daoSession != null ? daoSession.getCarInfoDao() : null;
185
+    }
186
+
187
+
188
+}

+ 219 - 0
app/src/main/java/hf/lskj/com/carstockcount/db/CarInfoDao.java

@@ -0,0 +1,219 @@
1
+package hf.lskj.com.carstockcount.db;
2
+
3
+import android.database.Cursor;
4
+import android.database.sqlite.SQLiteStatement;
5
+
6
+import org.greenrobot.greendao.AbstractDao;
7
+import org.greenrobot.greendao.Property;
8
+import org.greenrobot.greendao.internal.DaoConfig;
9
+import org.greenrobot.greendao.database.Database;
10
+import org.greenrobot.greendao.database.DatabaseStatement;
11
+
12
+// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
13
+/** 
14
+ * DAO for table "CAR_INFO".
15
+*/
16
+public class CarInfoDao extends AbstractDao<CarInfo, String> {
17
+
18
+    public static final String TABLENAME = "CAR_INFO";
19
+
20
+    /**
21
+     * Properties of entity CarInfo.<br/>
22
+     * Can be used for QueryBuilder and for referencing column names.
23
+     */
24
+    public static class Properties {
25
+        public final static Property Vin = new Property(0, String.class, "vin", true, "VIN");
26
+        public final static Property Rfid = new Property(1, String.class, "rfid", false, "RFID");
27
+        public final static Property StoreId = new Property(2, String.class, "storeId", false, "STORE_ID");
28
+        public final static Property Color = new Property(3, String.class, "color", false, "COLOR");
29
+        public final static Property Type = new Property(4, String.class, "type", false, "TYPE");
30
+        public final static Property Status = new Property(5, String.class, "status", false, "STATUS");
31
+        public final static Property StockCountTime = new Property(6, String.class, "stockCountTime", false, "STOCK_COUNT_TIME");
32
+        public final static Property StockCountType = new Property(7, String.class, "stockCountType", false, "STOCK_COUNT_TYPE");
33
+    }
34
+
35
+    private DaoSession daoSession;
36
+
37
+
38
+    public CarInfoDao(DaoConfig config) {
39
+        super(config);
40
+    }
41
+    
42
+    public CarInfoDao(DaoConfig config, DaoSession daoSession) {
43
+        super(config, daoSession);
44
+        this.daoSession = daoSession;
45
+    }
46
+
47
+    /** Creates the underlying database table. */
48
+    public static void createTable(Database db, boolean ifNotExists) {
49
+        String constraint = ifNotExists? "IF NOT EXISTS ": "";
50
+        db.execSQL("CREATE TABLE " + constraint + "\"CAR_INFO\" (" + //
51
+                "\"VIN\" TEXT PRIMARY KEY NOT NULL ," + // 0: vin
52
+                "\"RFID\" TEXT," + // 1: rfid
53
+                "\"STORE_ID\" TEXT," + // 2: storeId
54
+                "\"COLOR\" TEXT," + // 3: color
55
+                "\"TYPE\" TEXT," + // 4: type
56
+                "\"STATUS\" TEXT," + // 5: status
57
+                "\"STOCK_COUNT_TIME\" TEXT," + // 6: stockCountTime
58
+                "\"STOCK_COUNT_TYPE\" TEXT);"); // 7: stockCountType
59
+    }
60
+
61
+    /** Drops the underlying database table. */
62
+    public static void dropTable(Database db, boolean ifExists) {
63
+        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"CAR_INFO\"";
64
+        db.execSQL(sql);
65
+    }
66
+
67
+    @Override
68
+    protected final void bindValues(DatabaseStatement stmt, CarInfo entity) {
69
+        stmt.clearBindings();
70
+ 
71
+        String vin = entity.getVin();
72
+        if (vin != null) {
73
+            stmt.bindString(1, vin);
74
+        }
75
+ 
76
+        String rfid = entity.getRfid();
77
+        if (rfid != null) {
78
+            stmt.bindString(2, rfid);
79
+        }
80
+ 
81
+        String storeId = entity.getStoreId();
82
+        if (storeId != null) {
83
+            stmt.bindString(3, storeId);
84
+        }
85
+ 
86
+        String color = entity.getColor();
87
+        if (color != null) {
88
+            stmt.bindString(4, color);
89
+        }
90
+ 
91
+        String type = entity.getType();
92
+        if (type != null) {
93
+            stmt.bindString(5, type);
94
+        }
95
+ 
96
+        String status = entity.getStatus();
97
+        if (status != null) {
98
+            stmt.bindString(6, status);
99
+        }
100
+ 
101
+        String stockCountTime = entity.getStockCountTime();
102
+        if (stockCountTime != null) {
103
+            stmt.bindString(7, stockCountTime);
104
+        }
105
+ 
106
+        String stockCountType = entity.getStockCountType();
107
+        if (stockCountType != null) {
108
+            stmt.bindString(8, stockCountType);
109
+        }
110
+    }
111
+
112
+    @Override
113
+    protected final void bindValues(SQLiteStatement stmt, CarInfo entity) {
114
+        stmt.clearBindings();
115
+ 
116
+        String vin = entity.getVin();
117
+        if (vin != null) {
118
+            stmt.bindString(1, vin);
119
+        }
120
+ 
121
+        String rfid = entity.getRfid();
122
+        if (rfid != null) {
123
+            stmt.bindString(2, rfid);
124
+        }
125
+ 
126
+        String storeId = entity.getStoreId();
127
+        if (storeId != null) {
128
+            stmt.bindString(3, storeId);
129
+        }
130
+ 
131
+        String color = entity.getColor();
132
+        if (color != null) {
133
+            stmt.bindString(4, color);
134
+        }
135
+ 
136
+        String type = entity.getType();
137
+        if (type != null) {
138
+            stmt.bindString(5, type);
139
+        }
140
+ 
141
+        String status = entity.getStatus();
142
+        if (status != null) {
143
+            stmt.bindString(6, status);
144
+        }
145
+ 
146
+        String stockCountTime = entity.getStockCountTime();
147
+        if (stockCountTime != null) {
148
+            stmt.bindString(7, stockCountTime);
149
+        }
150
+ 
151
+        String stockCountType = entity.getStockCountType();
152
+        if (stockCountType != null) {
153
+            stmt.bindString(8, stockCountType);
154
+        }
155
+    }
156
+
157
+    @Override
158
+    protected final void attachEntity(CarInfo entity) {
159
+        super.attachEntity(entity);
160
+        entity.__setDaoSession(daoSession);
161
+    }
162
+
163
+    @Override
164
+    public String readKey(Cursor cursor, int offset) {
165
+        return cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0);
166
+    }    
167
+
168
+    @Override
169
+    public CarInfo readEntity(Cursor cursor, int offset) {
170
+        CarInfo entity = new CarInfo( //
171
+            cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // vin
172
+            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // rfid
173
+            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // storeId
174
+            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // color
175
+            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // type
176
+            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // status
177
+            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // stockCountTime
178
+            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // stockCountType
179
+        );
180
+        return entity;
181
+    }
182
+     
183
+    @Override
184
+    public void readEntity(Cursor cursor, CarInfo entity, int offset) {
185
+        entity.setVin(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0));
186
+        entity.setRfid(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
187
+        entity.setStoreId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
188
+        entity.setColor(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
189
+        entity.setType(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
190
+        entity.setStatus(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
191
+        entity.setStockCountTime(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
192
+        entity.setStockCountType(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
193
+     }
194
+    
195
+    @Override
196
+    protected final String updateKeyAfterInsert(CarInfo entity, long rowId) {
197
+        return entity.getVin();
198
+    }
199
+    
200
+    @Override
201
+    public String getKey(CarInfo entity) {
202
+        if(entity != null) {
203
+            return entity.getVin();
204
+        } else {
205
+            return null;
206
+        }
207
+    }
208
+
209
+    @Override
210
+    public boolean hasKey(CarInfo entity) {
211
+        return entity.getVin() != null;
212
+    }
213
+
214
+    @Override
215
+    protected final boolean isEntityUpdateable() {
216
+        return true;
217
+    }
218
+    
219
+}

+ 102 - 0
app/src/main/java/hf/lskj/com/carstockcount/db/DaoMaster.java

@@ -0,0 +1,102 @@
1
+package hf.lskj.com.carstockcount.db;
2
+
3
+import android.content.Context;
4
+import android.database.sqlite.SQLiteDatabase;
5
+import android.database.sqlite.SQLiteDatabase.CursorFactory;
6
+import android.util.Log;
7
+
8
+import org.greenrobot.greendao.AbstractDaoMaster;
9
+import org.greenrobot.greendao.database.StandardDatabase;
10
+import org.greenrobot.greendao.database.Database;
11
+import org.greenrobot.greendao.database.DatabaseOpenHelper;
12
+import org.greenrobot.greendao.identityscope.IdentityScopeType;
13
+
14
+
15
+// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
16
+/**
17
+ * Master of DAO (schema version 12): knows all DAOs.
18
+ */
19
+public class DaoMaster extends AbstractDaoMaster {
20
+    public static final int SCHEMA_VERSION = 12;
21
+
22
+    /** Creates underlying database table using DAOs. */
23
+    public static void createAllTables(Database db, boolean ifNotExists) {
24
+        CarInfoDao.createTable(db, ifNotExists);
25
+        RecordDao.createTable(db, ifNotExists);
26
+        UserDao.createTable(db, ifNotExists);
27
+    }
28
+
29
+    /** Drops underlying database table using DAOs. */
30
+    public static void dropAllTables(Database db, boolean ifExists) {
31
+        CarInfoDao.dropTable(db, ifExists);
32
+        RecordDao.dropTable(db, ifExists);
33
+        UserDao.dropTable(db, ifExists);
34
+    }
35
+
36
+    /**
37
+     * WARNING: Drops all table on Upgrade! Use only during development.
38
+     * Convenience method using a {@link DevOpenHelper}.
39
+     */
40
+    public static DaoSession newDevSession(Context context, String name) {
41
+        Database db = new DevOpenHelper(context, name).getWritableDb();
42
+        DaoMaster daoMaster = new DaoMaster(db);
43
+        return daoMaster.newSession();
44
+    }
45
+
46
+    public DaoMaster(SQLiteDatabase db) {
47
+        this(new StandardDatabase(db));
48
+    }
49
+
50
+    public DaoMaster(Database db) {
51
+        super(db, SCHEMA_VERSION);
52
+        registerDaoClass(CarInfoDao.class);
53
+        registerDaoClass(RecordDao.class);
54
+        registerDaoClass(UserDao.class);
55
+    }
56
+
57
+    public DaoSession newSession() {
58
+        return new DaoSession(db, IdentityScopeType.Session, daoConfigMap);
59
+    }
60
+
61
+    public DaoSession newSession(IdentityScopeType type) {
62
+        return new DaoSession(db, type, daoConfigMap);
63
+    }
64
+
65
+    /**
66
+     * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} -
67
+     */
68
+    public static abstract class OpenHelper extends DatabaseOpenHelper {
69
+        public OpenHelper(Context context, String name) {
70
+            super(context, name, SCHEMA_VERSION);
71
+        }
72
+
73
+        public OpenHelper(Context context, String name, CursorFactory factory) {
74
+            super(context, name, factory, SCHEMA_VERSION);
75
+        }
76
+
77
+        @Override
78
+        public void onCreate(Database db) {
79
+            Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION);
80
+            createAllTables(db, false);
81
+        }
82
+    }
83
+
84
+    /** WARNING: Drops all table on Upgrade! Use only during development. */
85
+    public static class DevOpenHelper extends OpenHelper {
86
+        public DevOpenHelper(Context context, String name) {
87
+            super(context, name);
88
+        }
89
+
90
+        public DevOpenHelper(Context context, String name, CursorFactory factory) {
91
+            super(context, name, factory);
92
+        }
93
+
94
+        @Override
95
+        public void onUpgrade(Database db, int oldVersion, int newVersion) {
96
+            Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables");
97
+            dropAllTables(db, true);
98
+            onCreate(db);
99
+        }
100
+    }
101
+
102
+}

+ 76 - 0
app/src/main/java/hf/lskj/com/carstockcount/db/DaoSession.java

@@ -0,0 +1,76 @@
1
+package hf.lskj.com.carstockcount.db;
2
+
3
+import java.util.Map;
4
+
5
+import org.greenrobot.greendao.AbstractDao;
6
+import org.greenrobot.greendao.AbstractDaoSession;
7
+import org.greenrobot.greendao.database.Database;
8
+import org.greenrobot.greendao.identityscope.IdentityScopeType;
9
+import org.greenrobot.greendao.internal.DaoConfig;
10
+
11
+import hf.lskj.com.carstockcount.db.CarInfo;
12
+import hf.lskj.com.carstockcount.db.Record;
13
+import hf.lskj.com.carstockcount.db.User;
14
+
15
+import hf.lskj.com.carstockcount.db.CarInfoDao;
16
+import hf.lskj.com.carstockcount.db.RecordDao;
17
+import hf.lskj.com.carstockcount.db.UserDao;
18
+
19
+// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
20
+
21
+/**
22
+ * {@inheritDoc}
23
+ * 
24
+ * @see org.greenrobot.greendao.AbstractDaoSession
25
+ */
26
+public class DaoSession extends AbstractDaoSession {
27
+
28
+    private final DaoConfig carInfoDaoConfig;
29
+    private final DaoConfig recordDaoConfig;
30
+    private final DaoConfig userDaoConfig;
31
+
32
+    private final CarInfoDao carInfoDao;
33
+    private final RecordDao recordDao;
34
+    private final UserDao userDao;
35
+
36
+    public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig>
37
+            daoConfigMap) {
38
+        super(db);
39
+
40
+        carInfoDaoConfig = daoConfigMap.get(CarInfoDao.class).clone();
41
+        carInfoDaoConfig.initIdentityScope(type);
42
+
43
+        recordDaoConfig = daoConfigMap.get(RecordDao.class).clone();
44
+        recordDaoConfig.initIdentityScope(type);
45
+
46
+        userDaoConfig = daoConfigMap.get(UserDao.class).clone();
47
+        userDaoConfig.initIdentityScope(type);
48
+
49
+        carInfoDao = new CarInfoDao(carInfoDaoConfig, this);
50
+        recordDao = new RecordDao(recordDaoConfig, this);
51
+        userDao = new UserDao(userDaoConfig, this);
52
+
53
+        registerDao(CarInfo.class, carInfoDao);
54
+        registerDao(Record.class, recordDao);
55
+        registerDao(User.class, userDao);
56
+    }
57
+    
58
+    public void clear() {
59
+        carInfoDaoConfig.clearIdentityScope();
60
+        recordDaoConfig.clearIdentityScope();
61
+        userDaoConfig.clearIdentityScope();
62
+    }
63
+
64
+    public CarInfoDao getCarInfoDao() {
65
+        return carInfoDao;
66
+    }
67
+
68
+    public RecordDao getRecordDao() {
69
+        return recordDao;
70
+    }
71
+
72
+    public UserDao getUserDao() {
73
+        return userDao;
74
+    }
75
+
76
+}

+ 19 - 0
app/src/main/java/hf/lskj/com/carstockcount/db/InitData.java

@@ -0,0 +1,19 @@
1
+package hf.lskj.com.carstockcount.db;
2
+
3
+import java.util.List;
4
+
5
+/**
6
+ * Created by yaoju on 2017/7/31.
7
+ */
8
+
9
+public class InitData {
10
+    private List<User> users;
11
+
12
+    public List<User> getUsers() {
13
+        return users;
14
+    }
15
+
16
+    public void setUsers(List<User> users) {
17
+        this.users = users;
18
+    }
19
+}

+ 123 - 0
app/src/main/java/hf/lskj/com/carstockcount/db/MyDao.java

@@ -0,0 +1,123 @@
1
+package hf.lskj.com.carstockcount.db;
2
+
3
+import android.content.Context;
4
+
5
+import org.greenrobot.greendao.DaoException;
6
+
7
+import java.util.Calendar;
8
+import java.util.List;
9
+
10
+import hf.lskj.com.carstockcount.MyApplication;
11
+import hf.lskj.com.carstockcount.utils.UHF.Sound;
12
+
13
+/**
14
+ * Created by yaoju on 2018/5/3.
15
+ * 自定义的数据库操作方法
16
+ */
17
+
18
+public class MyDao {
19
+
20
+    private static RecordDao mRecordDao = MyApplication.getInstances().getDaoSession().getRecordDao();
21
+    private static CarInfoDao mCarInfoDao = MyApplication.getInstances().getDaoSession().getCarInfoDao();
22
+
23
+    private static String[] getTime() {
24
+        String startTime, endTime;
25
+        Calendar midday = Calendar.getInstance();
26
+        midday.set(Calendar.HOUR_OF_DAY, 12);
27
+        midday.set(Calendar.MINUTE, 0);
28
+        Calendar current = Calendar.getInstance();
29
+        if (current.getTimeInMillis() > midday.getTimeInMillis()) {
30
+            //下午 12-24点
31
+            startTime = midday.getTimeInMillis() + "";
32
+            midday.set(Calendar.HOUR_OF_DAY, 24);
33
+            endTime = midday.getTimeInMillis() + "";
34
+        } else {
35
+            //上午 6-12点
36
+            endTime = midday.getTimeInMillis() + "";
37
+            midday.set(Calendar.HOUR_OF_DAY, 6);
38
+            startTime = midday.getTimeInMillis() + "";
39
+        }
40
+        return new String[]{startTime, endTime};
41
+    }
42
+
43
+
44
+    public static boolean saveToDb(Context context, CarInfo carInfo, Record entity) {
45
+        Sound mSound = new Sound(context);
46
+        //根据当前时间判断是否已盘点
47
+        String[] timePoints = getTime();
48
+        Record dbEntity = mRecordDao.queryBuilder()
49
+                .where(RecordDao.Properties.Rfid.eq(entity.getRfid()),
50
+                        RecordDao.Properties.CreateTime.between(timePoints[0], timePoints[1]),
51
+                        RecordDao.Properties.Type.eq(Record.TYPE_PANDIAN)).unique();
52
+        if (dbEntity != null) {
53
+            //如已盘点则update
54
+            entity.setId(dbEntity.getId());
55
+        }
56
+        MyApplication.getInstances().getDb().beginTransaction();
57
+        boolean success = false;
58
+        if (mRecordDao.insertOrReplace(entity) > 0) {
59
+            carInfo.setStatus(entity.getStatus());
60
+            carInfo.setStockCountType(Record.TYPE_PANDIAN);
61
+            carInfo.setStockCountTime(entity.getCreateTime());
62
+            if (mCarInfoDao.insertOrReplace(carInfo) > 0) {
63
+                mSound.callAlarm(true, 0);
64
+                success = true;
65
+                MyApplication.getInstances().getDb().setTransactionSuccessful();
66
+            }
67
+        }
68
+        MyApplication.getInstances().getDb().endTransaction();
69
+        return success;
70
+    }
71
+
72
+    //适用于导出盘点记录
73
+    public static boolean saveToDb(List<CarInfo> cars, List<Record> records) {
74
+        boolean success = true;
75
+        String[] timePoints = getTime();
76
+        MyApplication.getInstances().getDb().beginTransaction();
77
+        for (CarInfo car : cars) {
78
+            if (!Record.TYPE_PANDIAN.equals(car.getStockCountType())) {
79
+                car.setStatus(CarInfo.STATUS_WEIPANDAO);
80
+                car.setOperatorId(MyApplication.currentUser.getLoginId());
81
+                car.setStockCountTime(System.currentTimeMillis() + "");
82
+                Record dbEntity;
83
+                try {
84
+                    dbEntity = mRecordDao.queryBuilder()
85
+                            .where(RecordDao.Properties.Vin.eq(car.getVin()),
86
+                                    RecordDao.Properties.CreateTime.between(timePoints[0], timePoints[1]),
87
+                                    RecordDao.Properties.Type.eq(Record.TYPE_PANDIAN)).unique();
88
+                } catch (DaoException e) {
89
+                    e.printStackTrace();
90
+                    success = false;
91
+                    break;
92
+                }
93
+                if (dbEntity == null) {
94
+                    //新增“未盘到”的盘点记录
95
+                    Record record = new Record();
96
+                    record.setRfid(car.getRfid());
97
+                    record.setRemark("");
98
+                    record.setVin(car.getVin());
99
+                    record.setStatus(car.getStatus());
100
+                    record.setCreateTime(car.getStockCountTime());
101
+                    record.setOperatorId(MyApplication.currentUser.getLoginId());
102
+                    record.setStoreId(car.getStoreId());
103
+                    record.setColor(car.getColor());
104
+                    record.setCarType(car.getType());
105
+                    record.setType(Record.TYPE_PANDIAN);
106
+                    records.add(record);
107
+                }
108
+            }
109
+        }
110
+        if (success) {
111
+            try {
112
+                mRecordDao.insertOrReplaceInTx(records);
113
+                mCarInfoDao.insertOrReplaceInTx(cars);
114
+                MyApplication.getInstances().getDb().setTransactionSuccessful();
115
+            } catch (Exception e) {
116
+                e.printStackTrace();
117
+                success = false;
118
+            }
119
+        }
120
+        MyApplication.getInstances().getDb().endTransaction();
121
+        return success;
122
+    }
123
+}

+ 200 - 0
app/src/main/java/hf/lskj/com/carstockcount/db/Record.java

@@ -0,0 +1,200 @@
1
+package hf.lskj.com.carstockcount.db;
2
+
3
+import org.greenrobot.greendao.annotation.Entity;
4
+import org.greenrobot.greendao.annotation.Id;
5
+import org.greenrobot.greendao.annotation.OrderBy;
6
+import org.greenrobot.greendao.annotation.ToOne;
7
+import org.greenrobot.greendao.annotation.Transient;
8
+
9
+import java.io.Serializable;
10
+import org.greenrobot.greendao.annotation.Generated;
11
+import org.greenrobot.greendao.DaoException;
12
+
13
+/**
14
+ * Created by yaoju on 2017/7/31.
15
+ * 记录表 包含盘点记录 绑定记录 解绑记录
16
+ */
17
+@Entity
18
+public class Record implements Serializable{
19
+    static final long serialVersionUID = 43L;
20
+    public static final String TYPE_BANGDING="绑定";
21
+    public static final String TYPE_JIEBANG="解绑";
22
+    public static final String TYPE_PANDIAN="盘点";
23
+    @Id
24
+    private Long id;
25
+    private String rfid;
26
+    private String vin;
27
+    private String status="";
28
+    private String remark;
29
+    private String createTime;
30
+    /*用户的登录名*/
31
+    private String operatorId;
32
+    private String type;
33
+    private String storeId;
34
+    private String color;
35
+    private String carType;
36
+    /**
37
+     * 本表的vin字段关联CarInfo的主键
38
+     */
39
+    @ToOne(joinProperty = "vin")
40
+    public CarInfo carInfo;
41
+    /** Used to resolve relations */
42
+    @Generated(hash = 2040040024)
43
+    private transient DaoSession daoSession;
44
+    /** Used for active entity operations. */
45
+    @Generated(hash = 765166123)
46
+    private transient RecordDao myDao;
47
+    @Generated(hash = 1983733318)
48
+    public Record(Long id, String rfid, String vin, String status, String remark, String createTime,
49
+            String operatorId, String type, String storeId, String color, String carType) {
50
+        this.id = id;
51
+        this.rfid = rfid;
52
+        this.vin = vin;
53
+        this.status = status;
54
+        this.remark = remark;
55
+        this.createTime = createTime;
56
+        this.operatorId = operatorId;
57
+        this.type = type;
58
+        this.storeId = storeId;
59
+        this.color = color;
60
+        this.carType = carType;
61
+    }
62
+    @Generated(hash = 477726293)
63
+    public Record() {
64
+    }
65
+    public Long getId() {
66
+        return this.id;
67
+    }
68
+    public void setId(Long id) {
69
+        this.id = id;
70
+    }
71
+    public String getRfid() {
72
+        return this.rfid;
73
+    }
74
+    public void setRfid(String rfid) {
75
+        this.rfid = rfid;
76
+    }
77
+    public String getVin() {
78
+        return this.vin;
79
+    }
80
+    public void setVin(String vin) {
81
+        this.vin = vin;
82
+    }
83
+    public String getStatus() {
84
+        return this.status;
85
+    }
86
+    public void setStatus(String status) {
87
+        this.status = status;
88
+    }
89
+    public String getRemark() {
90
+        return this.remark;
91
+    }
92
+    public void setRemark(String remark) {
93
+        this.remark = remark;
94
+    }
95
+    public String getCreateTime() {
96
+        return this.createTime;
97
+    }
98
+    public void setCreateTime(String createTime) {
99
+        this.createTime = createTime;
100
+    }
101
+    public String getOperatorId() {
102
+        return this.operatorId;
103
+    }
104
+    public void setOperatorId(String operatorId) {
105
+        this.operatorId = operatorId;
106
+    }
107
+    public String getType() {
108
+        return this.type;
109
+    }
110
+    public void setType(String type) {
111
+        this.type = type;
112
+    }
113
+    public String getStoreId() {
114
+        return this.storeId;
115
+    }
116
+    public void setStoreId(String storeId) {
117
+        this.storeId = storeId;
118
+    }
119
+    @Generated(hash = 2118934479)
120
+    private transient String carInfo__resolvedKey;
121
+    /** To-one relationship, resolved on first access. */
122
+    @Generated(hash = 1787003779)
123
+    public CarInfo getCarInfo() {
124
+        String __key = this.vin;
125
+        if (carInfo__resolvedKey == null || carInfo__resolvedKey != __key) {
126
+            final DaoSession daoSession = this.daoSession;
127
+            if (daoSession == null) {
128
+                throw new DaoException("Entity is detached from DAO context");
129
+            }
130
+            CarInfoDao targetDao = daoSession.getCarInfoDao();
131
+            CarInfo carInfoNew = targetDao.load(__key);
132
+            synchronized (this) {
133
+                carInfo = carInfoNew;
134
+                carInfo__resolvedKey = __key;
135
+            }
136
+        }
137
+        return carInfo;
138
+    }
139
+    /** called by internal mechanisms, do not call yourself. */
140
+    @Generated(hash = 1808670039)
141
+    public void setCarInfo(CarInfo carInfo) {
142
+        synchronized (this) {
143
+            this.carInfo = carInfo;
144
+            vin = carInfo == null ? null : carInfo.getVin();
145
+            carInfo__resolvedKey = vin;
146
+        }
147
+    }
148
+    /**
149
+     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
150
+     * Entity must attached to an entity context.
151
+     */
152
+    @Generated(hash = 128553479)
153
+    public void delete() {
154
+        if (myDao == null) {
155
+            throw new DaoException("Entity is detached from DAO context");
156
+        }
157
+        myDao.delete(this);
158
+    }
159
+    /**
160
+     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
161
+     * Entity must attached to an entity context.
162
+     */
163
+    @Generated(hash = 1942392019)
164
+    public void refresh() {
165
+        if (myDao == null) {
166
+            throw new DaoException("Entity is detached from DAO context");
167
+        }
168
+        myDao.refresh(this);
169
+    }
170
+    /**
171
+     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
172
+     * Entity must attached to an entity context.
173
+     */
174
+    @Generated(hash = 713229351)
175
+    public void update() {
176
+        if (myDao == null) {
177
+            throw new DaoException("Entity is detached from DAO context");
178
+        }
179
+        myDao.update(this);
180
+    }
181
+    /** called by internal mechanisms, do not call yourself. */
182
+    @Generated(hash = 1505145191)
183
+    public void __setDaoSession(DaoSession daoSession) {
184
+        this.daoSession = daoSession;
185
+        myDao = daoSession != null ? daoSession.getRecordDao() : null;
186
+    }
187
+    public String getColor() {
188
+        return this.color;
189
+    }
190
+    public void setColor(String color) {
191
+        this.color = color;
192
+    }
193
+    public String getCarType() {
194
+        return this.carType;
195
+    }
196
+    public void setCarType(String carType) {
197
+        this.carType = carType;
198
+    }
199
+   
200
+}

+ 374 - 0
app/src/main/java/hf/lskj/com/carstockcount/db/RecordDao.java

@@ -0,0 +1,374 @@
1
+package hf.lskj.com.carstockcount.db;
2
+
3
+import java.util.List;
4
+import java.util.ArrayList;
5
+import android.database.Cursor;
6
+import android.database.sqlite.SQLiteStatement;
7
+
8
+import org.greenrobot.greendao.AbstractDao;
9
+import org.greenrobot.greendao.Property;
10
+import org.greenrobot.greendao.internal.SqlUtils;
11
+import org.greenrobot.greendao.internal.DaoConfig;
12
+import org.greenrobot.greendao.database.Database;
13
+import org.greenrobot.greendao.database.DatabaseStatement;
14
+import org.greenrobot.greendao.query.Query;
15
+import org.greenrobot.greendao.query.QueryBuilder;
16
+
17
+// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
18
+/** 
19
+ * DAO for table "RECORD".
20
+*/
21
+public class RecordDao extends AbstractDao<Record, Long> {
22
+
23
+    public static final String TABLENAME = "RECORD";
24
+
25
+    /**
26
+     * Properties of entity Record.<br/>
27
+     * Can be used for QueryBuilder and for referencing column names.
28
+     */
29
+    public static class Properties {
30
+        public final static Property Id = new Property(0, Long.class, "id", true, "_id");
31
+        public final static Property Rfid = new Property(1, String.class, "rfid", false, "RFID");
32
+        public final static Property Vin = new Property(2, String.class, "vin", false, "VIN");
33
+        public final static Property Status = new Property(3, String.class, "status", false, "STATUS");
34
+        public final static Property Remark = new Property(4, String.class, "remark", false, "REMARK");
35
+        public final static Property CreateTime = new Property(5, String.class, "createTime", false, "CREATE_TIME");
36
+        public final static Property OperatorId = new Property(6, String.class, "operatorId", false, "OPERATOR_ID");
37
+        public final static Property Type = new Property(7, String.class, "type", false, "TYPE");
38
+        public final static Property StoreId = new Property(8, String.class, "storeId", false, "STORE_ID");
39
+        public final static Property Color = new Property(9, String.class, "color", false, "COLOR");
40
+        public final static Property CarType = new Property(10, String.class, "carType", false, "CAR_TYPE");
41
+    }
42
+
43
+    private DaoSession daoSession;
44
+
45
+    private Query<Record> carInfo_RecordsQuery;
46
+
47
+    public RecordDao(DaoConfig config) {
48
+        super(config);
49
+    }
50
+    
51
+    public RecordDao(DaoConfig config, DaoSession daoSession) {
52
+        super(config, daoSession);
53
+        this.daoSession = daoSession;
54
+    }
55
+
56
+    /** Creates the underlying database table. */
57
+    public static void createTable(Database db, boolean ifNotExists) {
58
+        String constraint = ifNotExists? "IF NOT EXISTS ": "";
59
+        db.execSQL("CREATE TABLE " + constraint + "\"RECORD\" (" + //
60
+                "\"_id\" INTEGER PRIMARY KEY ," + // 0: id
61
+                "\"RFID\" TEXT," + // 1: rfid
62
+                "\"VIN\" TEXT," + // 2: vin
63
+                "\"STATUS\" TEXT," + // 3: status
64
+                "\"REMARK\" TEXT," + // 4: remark
65
+                "\"CREATE_TIME\" TEXT," + // 5: createTime
66
+                "\"OPERATOR_ID\" TEXT," + // 6: operatorId
67
+                "\"TYPE\" TEXT," + // 7: type
68
+                "\"STORE_ID\" TEXT," + // 8: storeId
69
+                "\"COLOR\" TEXT," + // 9: color
70
+                "\"CAR_TYPE\" TEXT);"); // 10: carType
71
+    }
72
+
73
+    /** Drops the underlying database table. */
74
+    public static void dropTable(Database db, boolean ifExists) {
75
+        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"RECORD\"";
76
+        db.execSQL(sql);
77
+    }
78
+
79
+    @Override
80
+    protected final void bindValues(DatabaseStatement stmt, Record entity) {
81
+        stmt.clearBindings();
82
+ 
83
+        Long id = entity.getId();
84
+        if (id != null) {
85
+            stmt.bindLong(1, id);
86
+        }
87
+ 
88
+        String rfid = entity.getRfid();
89
+        if (rfid != null) {
90
+            stmt.bindString(2, rfid);
91
+        }
92
+ 
93
+        String vin = entity.getVin();
94
+        if (vin != null) {
95
+            stmt.bindString(3, vin);
96
+        }
97
+ 
98
+        String status = entity.getStatus();
99
+        if (status != null) {
100
+            stmt.bindString(4, status);
101
+        }
102
+ 
103
+        String remark = entity.getRemark();
104
+        if (remark != null) {
105
+            stmt.bindString(5, remark);
106
+        }
107
+ 
108
+        String createTime = entity.getCreateTime();
109
+        if (createTime != null) {
110
+            stmt.bindString(6, createTime);
111
+        }
112
+ 
113
+        String operatorId = entity.getOperatorId();
114
+        if (operatorId != null) {
115
+            stmt.bindString(7, operatorId);
116
+        }
117
+ 
118
+        String type = entity.getType();
119
+        if (type != null) {
120
+            stmt.bindString(8, type);
121
+        }
122
+ 
123
+        String storeId = entity.getStoreId();
124
+        if (storeId != null) {
125
+            stmt.bindString(9, storeId);
126
+        }
127
+ 
128
+        String color = entity.getColor();
129
+        if (color != null) {
130
+            stmt.bindString(10, color);
131
+        }
132
+ 
133
+        String carType = entity.getCarType();
134
+        if (carType != null) {
135
+            stmt.bindString(11, carType);
136
+        }
137
+    }
138
+
139
+    @Override
140
+    protected final void bindValues(SQLiteStatement stmt, Record entity) {
141
+        stmt.clearBindings();
142
+ 
143
+        Long id = entity.getId();
144
+        if (id != null) {
145
+            stmt.bindLong(1, id);
146
+        }
147
+ 
148
+        String rfid = entity.getRfid();
149
+        if (rfid != null) {
150
+            stmt.bindString(2, rfid);
151
+        }
152
+ 
153
+        String vin = entity.getVin();
154
+        if (vin != null) {
155
+            stmt.bindString(3, vin);
156
+        }
157
+ 
158
+        String status = entity.getStatus();
159
+        if (status != null) {
160
+            stmt.bindString(4, status);
161
+        }
162
+ 
163
+        String remark = entity.getRemark();
164
+        if (remark != null) {
165
+            stmt.bindString(5, remark);
166
+        }
167
+ 
168
+        String createTime = entity.getCreateTime();
169
+        if (createTime != null) {
170
+            stmt.bindString(6, createTime);
171
+        }
172
+ 
173
+        String operatorId = entity.getOperatorId();
174
+        if (operatorId != null) {
175
+            stmt.bindString(7, operatorId);
176
+        }
177
+ 
178
+        String type = entity.getType();
179
+        if (type != null) {
180
+            stmt.bindString(8, type);
181
+        }
182
+ 
183
+        String storeId = entity.getStoreId();
184
+        if (storeId != null) {
185
+            stmt.bindString(9, storeId);
186
+        }
187
+ 
188
+        String color = entity.getColor();
189
+        if (color != null) {
190
+            stmt.bindString(10, color);
191
+        }
192
+ 
193
+        String carType = entity.getCarType();
194
+        if (carType != null) {
195
+            stmt.bindString(11, carType);
196
+        }
197
+    }
198
+
199
+    @Override
200
+    protected final void attachEntity(Record entity) {
201
+        super.attachEntity(entity);
202
+        entity.__setDaoSession(daoSession);
203
+    }
204
+
205
+    @Override
206
+    public Long readKey(Cursor cursor, int offset) {
207
+        return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
208
+    }    
209
+
210
+    @Override
211
+    public Record readEntity(Cursor cursor, int offset) {
212
+        Record entity = new Record( //
213
+            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
214
+            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // rfid
215
+            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // vin
216
+            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // status
217
+            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // remark
218
+            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // createTime
219
+            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // operatorId
220
+            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // type
221
+            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // storeId
222
+            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // color
223
+            cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // carType
224
+        );
225
+        return entity;
226
+    }
227
+     
228
+    @Override
229
+    public void readEntity(Cursor cursor, Record entity, int offset) {
230
+        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
231
+        entity.setRfid(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
232
+        entity.setVin(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
233
+        entity.setStatus(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
234
+        entity.setRemark(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
235
+        entity.setCreateTime(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
236
+        entity.setOperatorId(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
237
+        entity.setType(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
238
+        entity.setStoreId(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
239
+        entity.setColor(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
240
+        entity.setCarType(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
241
+     }
242
+    
243
+    @Override
244
+    protected final Long updateKeyAfterInsert(Record entity, long rowId) {
245
+        entity.setId(rowId);
246
+        return rowId;
247
+    }
248
+    
249
+    @Override
250
+    public Long getKey(Record entity) {
251
+        if(entity != null) {
252
+            return entity.getId();
253
+        } else {
254
+            return null;
255
+        }
256
+    }
257
+
258
+    @Override
259
+    public boolean hasKey(Record entity) {
260
+        return entity.getId() != null;
261
+    }
262
+
263
+    @Override
264
+    protected final boolean isEntityUpdateable() {
265
+        return true;
266
+    }
267
+    
268
+    /** Internal query to resolve the "records" to-many relationship of CarInfo. */
269
+    public List<Record> _queryCarInfo_Records(String vin) {
270
+        synchronized (this) {
271
+            if (carInfo_RecordsQuery == null) {
272
+                QueryBuilder<Record> queryBuilder = queryBuilder();
273
+                queryBuilder.where(Properties.Vin.eq(null));
274
+                queryBuilder.orderRaw("T.'CREATE_TIME' DESC");
275
+                carInfo_RecordsQuery = queryBuilder.build();
276
+            }
277
+        }
278
+        Query<Record> query = carInfo_RecordsQuery.forCurrentThread();
279
+        query.setParameter(0, vin);
280
+        return query.list();
281
+    }
282
+
283
+    private String selectDeep;
284
+
285
+    protected String getSelectDeep() {
286
+        if (selectDeep == null) {
287
+            StringBuilder builder = new StringBuilder("SELECT ");
288
+            SqlUtils.appendColumns(builder, "T", getAllColumns());
289
+            builder.append(',');
290
+            SqlUtils.appendColumns(builder, "T0", daoSession.getCarInfoDao().getAllColumns());
291
+            builder.append(" FROM RECORD T");
292
+            builder.append(" LEFT JOIN CAR_INFO T0 ON T.\"VIN\"=T0.\"VIN\"");
293
+            builder.append(' ');
294
+            selectDeep = builder.toString();
295
+        }
296
+        return selectDeep;
297
+    }
298
+    
299
+    protected Record loadCurrentDeep(Cursor cursor, boolean lock) {
300
+        Record entity = loadCurrent(cursor, 0, lock);
301
+        int offset = getAllColumns().length;
302
+
303
+        CarInfo carInfo = loadCurrentOther(daoSession.getCarInfoDao(), cursor, offset);
304
+        entity.setCarInfo(carInfo);
305
+
306
+        return entity;    
307
+    }
308
+
309
+    public Record loadDeep(Long key) {
310
+        assertSinglePk();
311
+        if (key == null) {
312
+            return null;
313
+        }
314
+
315
+        StringBuilder builder = new StringBuilder(getSelectDeep());
316
+        builder.append("WHERE ");
317
+        SqlUtils.appendColumnsEqValue(builder, "T", getPkColumns());
318
+        String sql = builder.toString();
319
+        
320
+        String[] keyArray = new String[] { key.toString() };
321
+        Cursor cursor = db.rawQuery(sql, keyArray);
322
+        
323
+        try {
324
+            boolean available = cursor.moveToFirst();
325
+            if (!available) {
326
+                return null;
327
+            } else if (!cursor.isLast()) {
328
+                throw new IllegalStateException("Expected unique result, but count was " + cursor.getCount());
329
+            }
330
+            return loadCurrentDeep(cursor, true);
331
+        } finally {
332
+            cursor.close();
333
+        }
334
+    }
335
+    
336
+    /** Reads all available rows from the given cursor and returns a list of new ImageTO objects. */
337
+    public List<Record> loadAllDeepFromCursor(Cursor cursor) {
338
+        int count = cursor.getCount();
339
+        List<Record> list = new ArrayList<Record>(count);
340
+        
341
+        if (cursor.moveToFirst()) {
342
+            if (identityScope != null) {
343
+                identityScope.lock();
344
+                identityScope.reserveRoom(count);
345
+            }
346
+            try {
347
+                do {
348
+                    list.add(loadCurrentDeep(cursor, false));
349
+                } while (cursor.moveToNext());
350
+            } finally {
351
+                if (identityScope != null) {
352
+                    identityScope.unlock();
353
+                }
354
+            }
355
+        }
356
+        return list;
357
+    }
358
+    
359
+    protected List<Record> loadDeepAllAndCloseCursor(Cursor cursor) {
360
+        try {
361
+            return loadAllDeepFromCursor(cursor);
362
+        } finally {
363
+            cursor.close();
364
+        }
365
+    }
366
+    
367
+
368
+    /** A raw-style query where you can pass any WHERE clause and arguments. */
369
+    public List<Record> queryDeep(String where, String... selectionArg) {
370
+        Cursor cursor = db.rawQuery(getSelectDeep() + where, selectionArg);
371
+        return loadDeepAllAndCloseCursor(cursor);
372
+    }
373
+ 
374
+}

+ 69 - 0
app/src/main/java/hf/lskj/com/carstockcount/db/User.java

@@ -0,0 +1,69 @@
1
+package hf.lskj.com.carstockcount.db;
2
+
3
+import org.greenrobot.greendao.annotation.Entity;
4
+import org.greenrobot.greendao.annotation.Id;
5
+import org.greenrobot.greendao.annotation.Generated;
6
+
7
+/**
8
+ * Created by yaoju on 2017/7/31.
9
+ */
10
+
11
+@Entity
12
+public class User {
13
+    @Id
14
+    private String loginId;
15
+    private String password;
16
+    private String realName;
17
+    private String role;
18
+    private String storeName;
19
+    private boolean current;
20
+    @Generated(hash = 300782054)
21
+    public User(String loginId, String password, String realName, String role,
22
+            String storeName, boolean current) {
23
+        this.loginId = loginId;
24
+        this.password = password;
25
+        this.realName = realName;
26
+        this.role = role;
27
+        this.storeName = storeName;
28
+        this.current = current;
29
+    }
30
+    @Generated(hash = 586692638)
31
+    public User() {
32
+    }
33
+    public String getLoginId() {
34
+        return this.loginId;
35
+    }
36
+    public void setLoginId(String loginId) {
37
+        this.loginId = loginId;
38
+    }
39
+    public String getPassword() {
40
+        return this.password;
41
+    }
42
+    public void setPassword(String password) {
43
+        this.password = password;
44
+    }
45
+    public String getRealName() {
46
+        return this.realName;
47
+    }
48
+    public void setRealName(String realName) {
49
+        this.realName = realName;
50
+    }
51
+    public String getRole() {
52
+        return this.role;
53
+    }
54
+    public void setRole(String role) {
55
+        this.role = role;
56
+    }
57
+    public String getStoreName() {
58
+        return this.storeName;
59
+    }
60
+    public void setStoreName(String storeName) {
61
+        this.storeName = storeName;
62
+    }
63
+    public boolean getCurrent() {
64
+        return this.current;
65
+    }
66
+    public void setCurrent(boolean current) {
67
+        this.current = current;
68
+    }
69
+}

+ 174 - 0
app/src/main/java/hf/lskj/com/carstockcount/db/UserDao.java

@@ -0,0 +1,174 @@
1
+package hf.lskj.com.carstockcount.db;
2
+
3
+import android.database.Cursor;
4
+import android.database.sqlite.SQLiteStatement;
5
+
6
+import org.greenrobot.greendao.AbstractDao;
7
+import org.greenrobot.greendao.Property;
8
+import org.greenrobot.greendao.internal.DaoConfig;
9
+import org.greenrobot.greendao.database.Database;
10
+import org.greenrobot.greendao.database.DatabaseStatement;
11
+
12
+// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
13
+/** 
14
+ * DAO for table "USER".
15
+*/
16
+public class UserDao extends AbstractDao<User, String> {
17
+
18
+    public static final String TABLENAME = "USER";
19
+
20
+    /**
21
+     * Properties of entity User.<br/>
22
+     * Can be used for QueryBuilder and for referencing column names.
23
+     */
24
+    public static class Properties {
25
+        public final static Property LoginId = new Property(0, String.class, "loginId", true, "LOGIN_ID");
26
+        public final static Property Password = new Property(1, String.class, "password", false, "PASSWORD");
27
+        public final static Property RealName = new Property(2, String.class, "realName", false, "REAL_NAME");
28
+        public final static Property Role = new Property(3, String.class, "role", false, "ROLE");
29
+        public final static Property StoreName = new Property(4, String.class, "storeName", false, "STORE_NAME");
30
+        public final static Property Current = new Property(5, boolean.class, "current", false, "CURRENT");
31
+    }
32
+
33
+
34
+    public UserDao(DaoConfig config) {
35
+        super(config);
36
+    }
37
+    
38
+    public UserDao(DaoConfig config, DaoSession daoSession) {
39
+        super(config, daoSession);
40
+    }
41
+
42
+    /** Creates the underlying database table. */
43
+    public static void createTable(Database db, boolean ifNotExists) {
44
+        String constraint = ifNotExists? "IF NOT EXISTS ": "";
45
+        db.execSQL("CREATE TABLE " + constraint + "\"USER\" (" + //
46
+                "\"LOGIN_ID\" TEXT PRIMARY KEY NOT NULL ," + // 0: loginId
47
+                "\"PASSWORD\" TEXT," + // 1: password
48
+                "\"REAL_NAME\" TEXT," + // 2: realName
49
+                "\"ROLE\" TEXT," + // 3: role
50
+                "\"STORE_NAME\" TEXT," + // 4: storeName
51
+                "\"CURRENT\" INTEGER NOT NULL );"); // 5: current
52
+    }
53
+
54
+    /** Drops the underlying database table. */
55
+    public static void dropTable(Database db, boolean ifExists) {
56
+        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"USER\"";
57
+        db.execSQL(sql);
58
+    }
59
+
60
+    @Override
61
+    protected final void bindValues(DatabaseStatement stmt, User entity) {
62
+        stmt.clearBindings();
63
+ 
64
+        String loginId = entity.getLoginId();
65
+        if (loginId != null) {
66
+            stmt.bindString(1, loginId);
67
+        }
68
+ 
69
+        String password = entity.getPassword();
70
+        if (password != null) {
71
+            stmt.bindString(2, password);
72
+        }
73
+ 
74
+        String realName = entity.getRealName();
75
+        if (realName != null) {
76
+            stmt.bindString(3, realName);
77
+        }
78
+ 
79
+        String role = entity.getRole();
80
+        if (role != null) {
81
+            stmt.bindString(4, role);
82
+        }
83
+ 
84
+        String storeName = entity.getStoreName();
85
+        if (storeName != null) {
86
+            stmt.bindString(5, storeName);
87
+        }
88
+        stmt.bindLong(6, entity.getCurrent() ? 1L: 0L);
89
+    }
90
+
91
+    @Override
92
+    protected final void bindValues(SQLiteStatement stmt, User entity) {
93
+        stmt.clearBindings();
94
+ 
95
+        String loginId = entity.getLoginId();
96
+        if (loginId != null) {
97
+            stmt.bindString(1, loginId);
98
+        }
99
+ 
100
+        String password = entity.getPassword();
101
+        if (password != null) {
102
+            stmt.bindString(2, password);
103
+        }
104
+ 
105
+        String realName = entity.getRealName();
106
+        if (realName != null) {
107
+            stmt.bindString(3, realName);
108
+        }
109
+ 
110
+        String role = entity.getRole();
111
+        if (role != null) {
112
+            stmt.bindString(4, role);
113
+        }
114
+ 
115
+        String storeName = entity.getStoreName();
116
+        if (storeName != null) {
117
+            stmt.bindString(5, storeName);
118
+        }
119
+        stmt.bindLong(6, entity.getCurrent() ? 1L: 0L);
120
+    }
121
+
122
+    @Override
123
+    public String readKey(Cursor cursor, int offset) {
124
+        return cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0);
125
+    }    
126
+
127
+    @Override
128
+    public User readEntity(Cursor cursor, int offset) {
129
+        User entity = new User( //
130
+            cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // loginId
131
+            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // password
132
+            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // realName
133
+            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // role
134
+            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // storeName
135
+            cursor.getShort(offset + 5) != 0 // current
136
+        );
137
+        return entity;
138
+    }
139
+     
140
+    @Override
141
+    public void readEntity(Cursor cursor, User entity, int offset) {
142
+        entity.setLoginId(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0));
143
+        entity.setPassword(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
144
+        entity.setRealName(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
145
+        entity.setRole(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
146
+        entity.setStoreName(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
147
+        entity.setCurrent(cursor.getShort(offset + 5) != 0);
148
+     }
149
+    
150
+    @Override
151
+    protected final String updateKeyAfterInsert(User entity, long rowId) {
152
+        return entity.getLoginId();
153
+    }
154
+    
155
+    @Override
156
+    public String getKey(User entity) {
157
+        if(entity != null) {
158
+            return entity.getLoginId();
159
+        } else {
160
+            return null;
161
+        }
162
+    }
163
+
164
+    @Override
165
+    public boolean hasKey(User entity) {
166
+        return entity.getLoginId() != null;
167
+    }
168
+
169
+    @Override
170
+    protected final boolean isEntityUpdateable() {
171
+        return true;
172
+    }
173
+    
174
+}

+ 49 - 0
app/src/main/java/hf/lskj/com/carstockcount/db/UserDaoUtils.java

@@ -0,0 +1,49 @@
1
+package hf.lskj.com.carstockcount.db;
2
+
3
+import java.util.List;
4
+
5
+import android.content.Context;
6
+
7
+import hf.lskj.com.carstockcount.MyApplication;
8
+
9
+public class UserDaoUtils {
10
+    private Context context;
11
+    public UserDao dao;
12
+
13
+    public UserDaoUtils(Context context) {
14
+        this.context = context;
15
+        dao = MyApplication.getInstances().getDaoSession().getUserDao();
16
+    }
17
+
18
+    public void insert(User User) {
19
+        dao.insertOrReplace(User);
20
+    }
21
+
22
+    public void delete(String key) {
23
+        dao.deleteByKey(key);
24
+    }
25
+
26
+    public void update(User User) {
27
+        dao.update(User);
28
+    }
29
+
30
+
31
+
32
+    /**
33
+     * 根据Id来查询数据库中个人信息
34
+     */
35
+    public List<User> queryByKey(String key) {
36
+        return dao.queryBuilder().where(UserDao.Properties.LoginId.eq(key)).orderAsc().list();
37
+    }
38
+
39
+    /**
40
+     * 查询所有的User
41
+     */
42
+    public List<User> loadAll() {
43
+        return dao.loadAll();
44
+    }
45
+
46
+    public User loadCurrent(){
47
+        return dao.queryBuilder().where(UserDao.Properties.Current.eq(1)).unique();
48
+    }
49
+}

+ 13 - 0
app/src/main/java/hf/lskj/com/carstockcount/event/BindEvent.java

@@ -0,0 +1,13 @@
1
+package hf.lskj.com.carstockcount.event;
2
+
3
+/**
4
+ * Created by yaoju on 2017/8/4.
5
+ */
6
+
7
+public class BindEvent {
8
+    public String tag;
9
+
10
+    public BindEvent(String tag) {
11
+        this.tag = tag;
12
+    }
13
+}

+ 11 - 0
app/src/main/java/hf/lskj/com/carstockcount/event/ChooseCarEvent.java

@@ -0,0 +1,11 @@
1
+package hf.lskj.com.carstockcount.event;
2
+
3
+import hf.lskj.com.carstockcount.db.CarInfo;
4
+
5
+/**
6
+ * Created by yaoju on 2017/8/3.
7
+ */
8
+
9
+public class ChooseCarEvent {
10
+    public CarInfo carInfo;
11
+}

+ 11 - 0
app/src/main/java/hf/lskj/com/carstockcount/event/ChooseRecordEvent.java

@@ -0,0 +1,11 @@
1
+package hf.lskj.com.carstockcount.event;
2
+
3
+import hf.lskj.com.carstockcount.db.Record;
4
+
5
+/**
6
+ * Created by yaoju on 2017/8/3.
7
+ */
8
+
9
+public class ChooseRecordEvent {
10
+    public Record record;
11
+}

+ 7 - 0
app/src/main/java/hf/lskj/com/carstockcount/event/ExitEvent.java

@@ -0,0 +1,7 @@
1
+package hf.lskj.com.carstockcount.event;
2
+
3
+/**
4
+ * Created by xuxihong on 15/6/23.
5
+ */
6
+public class ExitEvent {
7
+}

+ 74 - 0
app/src/main/java/hf/lskj/com/carstockcount/fragment/BaseFragment.java

@@ -0,0 +1,74 @@
1
+package hf.lskj.com.carstockcount.fragment;
2
+
3
+import android.support.v4.app.Fragment;
4
+import android.util.Log;
5
+
6
+public abstract class BaseFragment extends Fragment {
7
+
8
+    /**
9
+     * Fragment当前状态是否可见
10
+     */
11
+    protected boolean isVisible;
12
+
13
+    @Override
14
+    public void onResume() {
15
+        super.onResume();
16
+        Log.i("BaseFragment", getClass().getSimpleName() + " onResume");
17
+    }
18
+
19
+    @Override
20
+    public void onPause() {
21
+        super.onPause();
22
+        Log.i("BaseFragment", getClass().getSimpleName() + " onPause");
23
+    }
24
+
25
+    @Override
26
+    public void onStop() {
27
+        super.onStop();
28
+        Log.i("BaseFragment", getClass().getSimpleName() + " onStop");
29
+    }
30
+
31
+    @Override
32
+    public void onDestroyView() {
33
+        super.onDestroyView();
34
+        Log.i("BaseFragment", getClass().getSimpleName() + " onDestroyView");
35
+    }
36
+
37
+    @Override
38
+    public void setUserVisibleHint(boolean isVisibleToUser) {
39
+        super.setUserVisibleHint(isVisibleToUser);
40
+        Log.i("BaseFragment", getClass().getSimpleName() + " visible:" + isVisibleToUser);
41
+        if (getUserVisibleHint()) {
42
+            isVisible = true;
43
+            onVisible();
44
+        } else {
45
+            isVisible = false;
46
+            onInvisible();
47
+        }
48
+    }
49
+
50
+
51
+    /**
52
+     * 可见
53
+     */
54
+    protected void onVisible() {
55
+        lazyLoad();
56
+    }
57
+
58
+
59
+    /**
60
+     * 不可见
61
+     */
62
+    protected void onInvisible() {
63
+
64
+
65
+    }
66
+
67
+
68
+    /**
69
+     * 延迟加载
70
+     * 子类必须重写此方法
71
+     */
72
+    protected abstract void lazyLoad();
73
+
74
+}

+ 365 - 0
app/src/main/java/hf/lskj/com/carstockcount/fragment/BindFragment.java

@@ -0,0 +1,365 @@
1
+package hf.lskj.com.carstockcount.fragment;
2
+
3
+
4
+import android.content.DialogInterface;
5
+import android.graphics.drawable.Drawable;
6
+import android.os.Bundle;
7
+import android.support.v7.app.AlertDialog;
8
+import android.support.v7.widget.AppCompatAutoCompleteTextView;
9
+import android.text.Editable;
10
+import android.text.TextUtils;
11
+import android.text.TextWatcher;
12
+import android.util.Log;
13
+import android.view.KeyEvent;
14
+import android.view.LayoutInflater;
15
+import android.view.MotionEvent;
16
+import android.view.View;
17
+import android.view.ViewGroup;
18
+import android.widget.AdapterView;
19
+import android.widget.ArrayAdapter;
20
+import android.widget.Button;
21
+import android.widget.TextView;
22
+import android.widget.Toast;
23
+
24
+import org.greenrobot.eventbus.EventBus;
25
+
26
+import java.util.ArrayList;
27
+import java.util.List;
28
+
29
+import butterknife.Bind;
30
+import butterknife.ButterKnife;
31
+import hf.lskj.com.carstockcount.MyApplication;
32
+import hf.lskj.com.carstockcount.R;
33
+import hf.lskj.com.carstockcount.adapter.VinAdapter;
34
+import hf.lskj.com.carstockcount.db.CarInfo;
35
+import hf.lskj.com.carstockcount.db.CarInfoDao;
36
+import hf.lskj.com.carstockcount.db.Record;
37
+import hf.lskj.com.carstockcount.db.RecordDao;
38
+import hf.lskj.com.carstockcount.event.BindEvent;
39
+import hf.lskj.com.carstockcount.utils.KeyBoardUtils;
40
+import hf.lskj.com.carstockcount.utils.LogUtils;
41
+import hf.lskj.com.carstockcount.utils.ToastUtils;
42
+import hf.lskj.com.carstockcount.utils.UHF.Sound;
43
+import hf.lskj.com.carstockcount.utils.UHF.UHFClient;
44
+import hf.lskj.com.carstockcount.utils.UHF.UHFUtils;
45
+import uhf.api.CommandType;
46
+import uhf.api.Query_epc;
47
+import uhf.api.ShareData;
48
+
49
+
50
+public class BindFragment extends BaseFragment implements OnKeyDownInterface {
51
+    private static final String ARG_PARAM1 = "param1";
52
+    private static final String ARG_PARAM2 = "param2";
53
+    @Bind(R.id.tv_vin_title)
54
+    TextView tvVinTitle;
55
+    @Bind(R.id.tv_vin)
56
+    AppCompatAutoCompleteTextView tvVin;
57
+    @Bind(R.id.tv_rfid_title)
58
+    TextView tvRfidTitle;
59
+    @Bind(R.id.tv_rfid)
60
+    TextView tvRfid;
61
+    @Bind(R.id.bt_bind)
62
+    Button btBind;
63
+    @Bind(R.id.bt_unbind)
64
+    Button btUnbind;
65
+    private String mParam2;
66
+    private CarInfoDao mCarInfoDao;
67
+    private String mVin;
68
+    private RecordDao mRecordDao;
69
+    private Sound mSound;
70
+    private ArrayAdapter<String> carsAdapter;
71
+    private List<String> vinList = new ArrayList<>();
72
+    private CarInfo mSelectedCar;
73
+
74
+    public BindFragment() {
75
+    }
76
+
77
+    public static BindFragment newInstance(String vin, String param2) {
78
+        BindFragment fragment = new BindFragment();
79
+        Bundle args = new Bundle();
80
+        args.putString(ARG_PARAM1, vin);
81
+        args.putString(ARG_PARAM2, param2);
82
+        fragment.setArguments(args);
83
+        return fragment;
84
+    }
85
+
86
+    public void setCarInfo(CarInfo carInfo) {
87
+        setVin(carInfo.getVin());
88
+    }
89
+
90
+    public void setVin(String vin) {
91
+        mVin = vin;
92
+        tvVin.setText(mVin);
93
+    }
94
+
95
+    @Override
96
+    public void onCreate(Bundle savedInstanceState) {
97
+        super.onCreate(savedInstanceState);
98
+        if (getArguments() != null) {
99
+            mVin = getArguments().getString(ARG_PARAM1);
100
+            mParam2 = getArguments().getString(ARG_PARAM2);
101
+        }
102
+        mCarInfoDao = MyApplication.getInstances().getDaoSession().getCarInfoDao();
103
+        mRecordDao = MyApplication.getInstances().getDaoSession().getRecordDao();
104
+        mSound = new Sound(getActivity());
105
+    }
106
+
107
+    @Override
108
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
109
+                             Bundle savedInstanceState) {
110
+        View rootView = inflater.inflate(R.layout.fragment_bind, container, false);
111
+        ButterKnife.bind(this, rootView);
112
+        if (!TextUtils.isEmpty(mVin)) {
113
+            tvVin.setText(mVin);
114
+        }
115
+        List<CarInfo> cars = mCarInfoDao.queryBuilder().whereOr(CarInfoDao.Properties.Rfid.isNull(), CarInfoDao.Properties.Rfid.eq("")).list();
116
+
117
+        vinList.clear();
118
+        for (CarInfo car : cars) {
119
+            vinList.add(car.getVin());
120
+        }
121
+        carsAdapter = new VinAdapter(getActivity(), android.R.layout.simple_dropdown_item_1line, vinList);
122
+        tvVin.setAdapter(carsAdapter);
123
+        tvVin.setOnItemClickListener(new AdapterView.OnItemClickListener() {
124
+            @Override
125
+            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
126
+                mVin = carsAdapter.getItem(i);
127
+                KeyBoardUtils.closeKeybord(getActivity());
128
+            }
129
+        });
130
+        btBind.setOnClickListener(new View.OnClickListener() {
131
+            @Override
132
+            public void onClick(View view) {
133
+                //在扫描前,对vin码进行校验
134
+                if (beforeQueryTags()) {
135
+                    queryTags(true);
136
+                }
137
+            }
138
+        });
139
+        btUnbind.setOnClickListener(new View.OnClickListener() {
140
+            @Override
141
+            public void onClick(View view) {
142
+                queryTags(false);
143
+            }
144
+        });
145
+
146
+        tvVin.addTextChangedListener(new TextWatcher() {
147
+
148
+            @Override
149
+            public void onTextChanged(CharSequence s, int start, int before, int count) {
150
+                if (s.length() == 0) {
151
+                    tvVin.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
152
+                } else {
153
+                    tvVin.setCompoundDrawablesWithIntrinsicBounds(null, null, getResources().getDrawable(R.mipmap.search_clear), null);
154
+
155
+                }
156
+            }
157
+
158
+            @Override
159
+            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
160
+
161
+            }
162
+
163
+            @Override
164
+            public void afterTextChanged(Editable s) {
165
+
166
+            }
167
+        });
168
+        tvVin.setOnTouchListener(new View.OnTouchListener() {
169
+
170
+            @Override
171
+            public boolean onTouch(View v, MotionEvent event) {
172
+                //可以获得上下左右四个drawable,右侧排第二。图标没有设置则为空。
173
+                Drawable rightIcon = tvVin.getCompoundDrawables()[2];
174
+                if (rightIcon != null && event.getAction() == MotionEvent.ACTION_UP) {
175
+                    //检查点击的位置是否是右侧的删除图标
176
+                    //注意,使用getRwwX()是获取相对屏幕的位置,getX()可能获取相对父组件的位置
177
+                    int leftEdgeOfRightDrawable = tvVin.getRight() - tvVin.getPaddingRight()
178
+                            - rightIcon.getBounds().width();
179
+                    if (event.getRawX() >= leftEdgeOfRightDrawable) {
180
+                        tvVin.setText("");
181
+                    }
182
+                }
183
+                return false;
184
+            }
185
+        });
186
+        return rootView;
187
+    }
188
+
189
+    private boolean beforeQueryTags() {
190
+        if (!tvVin.getText().toString().equals(mVin)) {
191
+            if (tvVin.getText().length() > 0) {
192
+                LogUtils.i("车辆VIN码不正确,mVin=" + mVin);
193
+                Toast.makeText(getActivity(), "车辆VIN码不正确,请重新选择", Toast.LENGTH_SHORT).show();
194
+                return false;
195
+            }
196
+            mVin = "";
197
+        }
198
+        if (TextUtils.isEmpty(mVin)) {
199
+            Toast.makeText(getActivity(), "请先选择车辆VIN码", Toast.LENGTH_SHORT).show();
200
+            return false;
201
+        }
202
+        mSelectedCar = mCarInfoDao.load(mVin);
203
+        if (mSelectedCar != null) {
204
+            if (!TextUtils.isEmpty(mSelectedCar.getRfid())) {
205
+                ToastUtils.showShort("绑定失败:车辆已绑定,标签ID:" + mSelectedCar.getRfid());
206
+                return false;
207
+            }
208
+        } else {
209
+            Log.w("BindFragment", "根据vin" + mVin + "无法获得carInfo记录");
210
+            ToastUtils.showShort("vin码有误,请重新选择!");
211
+            return false;
212
+        }
213
+        return true;
214
+    }
215
+
216
+    private void queryTags(boolean isBind) {
217
+
218
+        Query_epc mQuery_epc = new Query_epc();
219
+        UHFClient info = UHFClient.getInstance();
220
+        if (info != null) {
221
+
222
+            Boolean ret = UHFClient.mUHF.command(CommandType.SINGLE_QUERY_TAGS_EPC, mQuery_epc);
223
+            if (ret) {
224
+                String str_tmp = ShareData.CharToString(mQuery_epc.epc.epc, mQuery_epc.epc.epc.length);
225
+                str_tmp = str_tmp.replace(" ", "");
226
+                LogUtils.i(str_tmp);
227
+                if ("060D0A000000000000000000".equals(str_tmp) || "0D0A00000000000000000000".equals(str_tmp)) {
228
+                    //不知道为什么 没有标签也能读出这个数据
229
+                    mSound.callAlarm(false, 0);
230
+                    return;
231
+                } else if ("".equals(str_tmp)) {
232
+                    mSound.callAlarm(false, 0);
233
+                    ToastUtils.showShort("请对准标签扫描");
234
+                    return;
235
+                }
236
+                tvRfid.setText(str_tmp);
237
+                if (isBind) {
238
+                    bind(str_tmp);
239
+                } else {
240
+                    unBind(str_tmp);
241
+                }
242
+                mSound.callAlarm(true, 0);
243
+            } else {
244
+                mSound.callAlarm(false, 0);
245
+                ToastUtils.showShort("没有扫描到标签");
246
+            }
247
+        } else {
248
+            LogUtils.i("info is null");
249
+        }
250
+    }
251
+
252
+    private void bind(String rfid) {
253
+        List<CarInfo> dbEntity = mCarInfoDao.queryBuilder().where(CarInfoDao.Properties.Rfid.eq(rfid)).list();
254
+        if (dbEntity.size() > 0) {
255
+            for (CarInfo carInfo : dbEntity) {
256
+                if (mVin.equals(carInfo.getVin())) {
257
+                    ToastUtils.showShort("绑定成功");
258
+                    return;
259
+                }
260
+            }
261
+            ToastUtils.showShort("绑定失败,此标签已绑定其他车辆:" + dbEntity.get(0).getVin());
262
+            return;
263
+        }
264
+        mSelectedCar.setRfid(rfid);
265
+        mSelectedCar.setStockCountTime(System.currentTimeMillis() + "");
266
+        mSelectedCar.setStockCountType(Record.TYPE_BANGDING);
267
+        if (mCarInfoDao.insertOrReplace(mSelectedCar) > 0) {
268
+            Record record = new Record();
269
+            record.setRfid(tvRfid.getText().toString());
270
+            record.setVin(mVin);
271
+            record.setCreateTime(System.currentTimeMillis() + "");
272
+            record.setOperatorId(MyApplication.currentUser.getLoginId());
273
+            record.setStoreId(mSelectedCar.getStoreId());
274
+            record.setStatus(mSelectedCar.getStatus());
275
+            record.setColor(mSelectedCar.getColor());
276
+            record.setCarType(mSelectedCar.getType());
277
+            record.setType(Record.TYPE_BANGDING);
278
+            if (mRecordDao.insert(record) > 0) {
279
+                vinList.remove(mVin);
280
+                carsAdapter.notifyDataSetChanged();
281
+                ToastUtils.showShort("绑定成功");
282
+                EventBus.getDefault().post(new BindEvent(record.getRfid()));
283
+            } else {
284
+                Toast.makeText(getActivity(), "绑定失败!", Toast.LENGTH_SHORT).show();
285
+            }
286
+        } else {
287
+            Toast.makeText(getActivity(), "绑定失败!", Toast.LENGTH_SHORT).show();
288
+        }
289
+    }
290
+
291
+    private void unBind(final String rfid) {
292
+        final CarInfo carInfo = mCarInfoDao.queryBuilder().where(CarInfoDao.Properties.Rfid.eq(rfid)).unique();
293
+        if (carInfo == null) {
294
+            ToastUtils.showShort("此标签尚未绑定");
295
+        } else {
296
+            tvVin.setText(carInfo.getVin());
297
+            new AlertDialog.Builder(getActivity())
298
+                    .setTitle("确定解绑吗?")
299
+                    .setMessage("VIN码:\n" + carInfo.getVin() + "\n标签ID:\n" + rfid)
300
+                    .setNegativeButton("取消", new DialogInterface.OnClickListener() {
301
+                        @Override
302
+                        public void onClick(DialogInterface dialog, int which) {
303
+                            dialog.dismiss();
304
+                        }
305
+                    })
306
+                    .setPositiveButton("确定", new DialogInterface.OnClickListener() {
307
+                        @Override
308
+                        public void onClick(DialogInterface dialog, int which) {
309
+                            Record record = new Record();
310
+                            record.setRfid(carInfo.getRfid());
311
+                            record.setVin(carInfo.getVin());
312
+                            record.setStatus(carInfo.getStatus());
313
+                            record.setCreateTime(System.currentTimeMillis() + "");
314
+                            record.setOperatorId(MyApplication.currentUser.getLoginId());
315
+                            record.setStoreId(carInfo.getStoreId());
316
+                            record.setColor(carInfo.getColor());
317
+                            record.setCarType(carInfo.getType());
318
+                            record.setType(Record.TYPE_JIEBANG);
319
+                            MyApplication.getInstances().getDb().beginTransaction();
320
+                            if (mRecordDao.insertOrReplace(record) > 0) {
321
+                                carInfo.setRfid("");
322
+                                carInfo.setStockCountType(Record.TYPE_JIEBANG);
323
+                                carInfo.setStockCountTime(System.currentTimeMillis() + "");
324
+                                if (mCarInfoDao.insertOrReplace(carInfo) > 0) {
325
+                                    ToastUtils.showShort("解绑成功");
326
+                                    MyApplication.getInstances().getDb().setTransactionSuccessful();
327
+                                } else {
328
+                                    ToastUtils.showShort("解绑失败!");
329
+                                }
330
+                            } else {
331
+                                ToastUtils.showShort("解绑失败!");
332
+                            }
333
+                            MyApplication.getInstances().getDb().endTransaction();
334
+                            dialog.dismiss();
335
+                        }
336
+                    })
337
+                    .show();
338
+        }
339
+    }
340
+
341
+    @Override
342
+    public void onDestroyView() {
343
+        super.onDestroyView();
344
+        ButterKnife.unbind(this);
345
+    }
346
+
347
+    @Override
348
+    protected void lazyLoad() {
349
+        if (!isVisible) {
350
+            return;
351
+        }
352
+        new Thread(new Runnable() {
353
+            @Override
354
+            public void run() {
355
+                UHFUtils uhfUtils = new UHFUtils(getActivity());
356
+                uhfUtils.handleSetPower(6);
357
+            }
358
+        }).run();
359
+    }
360
+
361
+    @Override
362
+    public void onKeyDown(int keyCode, KeyEvent event) {
363
+        btBind.callOnClick();
364
+    }
365
+}

+ 94 - 0
app/src/main/java/hf/lskj/com/carstockcount/fragment/MeFragment.java

@@ -0,0 +1,94 @@
1
+package hf.lskj.com.carstockcount.fragment;
2
+
3
+
4
+import android.content.Intent;
5
+import android.os.Bundle;
6
+import android.support.v4.app.Fragment;
7
+import android.view.LayoutInflater;
8
+import android.view.View;
9
+import android.view.ViewGroup;
10
+import android.widget.Button;
11
+import android.widget.RelativeLayout;
12
+import android.widget.TextView;
13
+
14
+import butterknife.Bind;
15
+import butterknife.ButterKnife;
16
+import hf.lskj.com.carstockcount.MyApplication;
17
+import hf.lskj.com.carstockcount.R;
18
+import hf.lskj.com.carstockcount.activity.CarListActivity;
19
+import hf.lskj.com.carstockcount.activity.RecordListActivity;
20
+import hf.lskj.com.carstockcount.activity.LoginActivity;
21
+import hf.lskj.com.carstockcount.db.User;
22
+import hf.lskj.com.carstockcount.db.UserDaoUtils;
23
+
24
+
25
+public class MeFragment extends Fragment {
26
+
27
+
28
+    @Bind(R.id.tv_realName)
29
+    TextView tvRealName;
30
+    @Bind(R.id.tv_role)
31
+    TextView tvRole;
32
+    @Bind(R.id.tv_loginName)
33
+    TextView tvLoginName;
34
+    @Bind(R.id.layout_count_records)
35
+    RelativeLayout layoutCountRecords;
36
+    @Bind(R.id.layout_cars)
37
+    RelativeLayout layoutCars;
38
+    @Bind(R.id.bt_exit)
39
+    Button btExit;
40
+    @Bind(R.id.tv_cars_title)
41
+    TextView tvCarsTitle;
42
+
43
+    public MeFragment() {
44
+    }
45
+
46
+
47
+    @Override
48
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
49
+                             Bundle savedInstanceState) {
50
+        View rootView = inflater.inflate(R.layout.fragment_me, container, false);
51
+        ButterKnife.bind(this, rootView);
52
+        tvRole.setText(MyApplication.currentUser.getRole());
53
+        tvLoginName.setText(MyApplication.currentUser.getLoginId());
54
+        tvRealName.setText(MyApplication.currentUser.getRealName());
55
+        tvCarsTitle.setText(MyApplication.currentUser.getStoreName() == null ?
56
+                "库存车辆" : MyApplication.currentUser.getStoreName() + "库存车辆");
57
+        setListener();
58
+        return rootView;
59
+    }
60
+
61
+    private void setListener() {
62
+        btExit.setOnClickListener(new View.OnClickListener() {
63
+            @Override
64
+            public void onClick(View view) {
65
+                UserDaoUtils userDaoUtils = new UserDaoUtils(getActivity());
66
+                User current = userDaoUtils.loadCurrent();
67
+                current.setCurrent(false);
68
+                userDaoUtils.update(current);
69
+                Intent intent = new Intent(getActivity(), LoginActivity.class);
70
+                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
71
+                startActivity(intent);
72
+                getActivity().finish();
73
+            }
74
+        });
75
+        layoutCountRecords.setOnClickListener(new View.OnClickListener() {
76
+            @Override
77
+            public void onClick(View view) {
78
+                startActivity(new Intent(getActivity(), RecordListActivity.class));
79
+            }
80
+        });
81
+        layoutCars.setOnClickListener(new View.OnClickListener() {
82
+            @Override
83
+            public void onClick(View view) {
84
+                startActivity(new Intent(getActivity(), CarListActivity.class));
85
+            }
86
+        });
87
+    }
88
+
89
+    @Override
90
+    public void onDestroyView() {
91
+        super.onDestroyView();
92
+        ButterKnife.unbind(this);
93
+    }
94
+}

+ 11 - 0
app/src/main/java/hf/lskj/com/carstockcount/fragment/OnKeyDownInterface.java

@@ -0,0 +1,11 @@
1
+package hf.lskj.com.carstockcount.fragment;
2
+
3
+import android.view.KeyEvent;
4
+
5
+/**
6
+ * Created by yaoju on 2017/8/2.
7
+ */
8
+
9
+public interface OnKeyDownInterface {
10
+    void onKeyDown(int keyCode, KeyEvent event);
11
+}

+ 472 - 0
app/src/main/java/hf/lskj/com/carstockcount/fragment/StockCountFragment.java

@@ -0,0 +1,472 @@
1
+package hf.lskj.com.carstockcount.fragment;
2
+
3
+
4
+import android.content.Intent;
5
+import android.os.Bundle;
6
+import android.os.Handler;
7
+import android.os.HandlerThread;
8
+import android.os.Message;
9
+import android.support.v7.widget.AppCompatSpinner;
10
+import android.text.TextUtils;
11
+import android.util.Log;
12
+import android.view.KeyEvent;
13
+import android.view.LayoutInflater;
14
+import android.view.View;
15
+import android.view.ViewGroup;
16
+import android.widget.AdapterView;
17
+import android.widget.ArrayAdapter;
18
+import android.widget.Button;
19
+import android.widget.CompoundButton;
20
+import android.widget.TextView;
21
+import android.widget.Toast;
22
+import android.widget.ToggleButton;
23
+
24
+import com.google.gson.Gson;
25
+
26
+import org.greenrobot.eventbus.EventBus;
27
+import org.greenrobot.eventbus.Subscribe;
28
+
29
+import java.io.IOException;
30
+import java.util.HashSet;
31
+import java.util.Set;
32
+
33
+import butterknife.Bind;
34
+import butterknife.ButterKnife;
35
+import hf.lskj.com.carstockcount.MyApplication;
36
+import hf.lskj.com.carstockcount.R;
37
+import hf.lskj.com.carstockcount.RequestUtils;
38
+import hf.lskj.com.carstockcount.activity.CarListActivity;
39
+import hf.lskj.com.carstockcount.db.MyDao;
40
+import hf.lskj.com.carstockcount.db.CarInfo;
41
+import hf.lskj.com.carstockcount.db.CarInfoDao;
42
+import hf.lskj.com.carstockcount.db.Record;
43
+import hf.lskj.com.carstockcount.event.BindEvent;
44
+import hf.lskj.com.carstockcount.utils.DateUtils;
45
+import hf.lskj.com.carstockcount.utils.LogUtils;
46
+import hf.lskj.com.carstockcount.utils.ToastUtils;
47
+import hf.lskj.com.carstockcount.utils.UHF.UHFClient;
48
+import hf.lskj.com.carstockcount.utils.UHF.UHFUtils;
49
+import okhttp3.Call;
50
+import okhttp3.Callback;
51
+import okhttp3.Response;
52
+import okhttp3.ResponseBody;
53
+import uhf.api.CommandType;
54
+import uhf.api.MultiLableCallBack;
55
+import uhf.api.Multi_query_epc;
56
+import uhf.api.ShareData;
57
+
58
+import static hf.lskj.com.carstockcount.db.CarInfo.STATUS_MOVE;
59
+import static hf.lskj.com.carstockcount.db.CarInfo.STATUS_WEIPANDAO;
60
+
61
+
62
+public class StockCountFragment extends BaseFragment implements MultiLableCallBack, OnKeyDownInterface {
63
+    private static final String ARG_PARAM1 = "param1";
64
+    private static final String ARG_PARAM2 = "param2";
65
+    @Bind(R.id.tv_vin)
66
+    TextView tvVin;
67
+    @Bind(R.id.tv_rfid)
68
+    TextView tvRfid;
69
+    @Bind(R.id.tv_type)
70
+    TextView tvType;
71
+    @Bind(R.id.tv_color)
72
+    TextView tvColor;
73
+    @Bind(R.id.tv_status)
74
+    TextView tvStatus;
75
+    @Bind(R.id.spi_status)
76
+    AppCompatSpinner spiStatus;
77
+    @Bind(R.id.tv_time)
78
+    TextView tvTime;
79
+    @Bind(R.id.bt_scan)
80
+    ToggleButton btScan;
81
+    @Bind(R.id.bt_save)
82
+    Button btSave;
83
+    @Bind(R.id.tv_time_title)
84
+    TextView tvTimeTitle;
85
+    private CarInfo mCarInfo;
86
+    private Record mRecord;
87
+    private String[] statuses = new String[]{"移动", "未盘到"};
88
+    private Set<String> tags = new HashSet<>();
89
+
90
+    private final MyApplication.MyHandler mHandler = new MyApplication.MyHandler();
91
+    private boolean stopped = true;
92
+    private CarInfoDao mCarInfoDao;
93
+
94
+    public StockCountFragment() {
95
+    }
96
+
97
+    public static StockCountFragment newInstance(CarInfo param1) {
98
+        StockCountFragment fragment = new StockCountFragment();
99
+        Bundle args = new Bundle();
100
+        args.putSerializable(ARG_PARAM1, param1);
101
+        fragment.setArguments(args);
102
+        return fragment;
103
+    }
104
+
105
+    public static StockCountFragment newInstance(Record param1) {
106
+        StockCountFragment fragment = new StockCountFragment();
107
+        Bundle args = new Bundle();
108
+        args.putSerializable(ARG_PARAM2, param1);
109
+        fragment.setArguments(args);
110
+        return fragment;
111
+    }
112
+
113
+    @Override
114
+    public void onCreate(Bundle savedInstanceState) {
115
+        super.onCreate(savedInstanceState);
116
+        if (getArguments() != null) {
117
+            mCarInfo = (CarInfo) getArguments().getSerializable(ARG_PARAM1);
118
+            mRecord = (Record) getArguments().getSerializable(ARG_PARAM2);
119
+        }
120
+        mCarInfoDao = MyApplication.getInstances().getDaoSession().getCarInfoDao();
121
+    }
122
+
123
+    @Override
124
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
125
+                             Bundle savedInstanceState) {
126
+        View rootView = inflater.inflate(R.layout.fragment_stock_count, container, false);
127
+        ButterKnife.bind(this, rootView);
128
+        bindData();
129
+        initListener();
130
+        EventBus.getDefault().register(this);
131
+        return rootView;
132
+    }
133
+
134
+    /**
135
+     * 用于异常处理
136
+     **/
137
+    public void setCarInfo(CarInfo carInfo) {
138
+        mCarInfo = carInfo;
139
+        mRecord = null;
140
+        bindData();
141
+    }
142
+
143
+    /**
144
+     * 用于查看盘点几率
145
+     **/
146
+    public void setCountRecord(Record record) {
147
+        mRecord = record;
148
+        mCarInfo = null;
149
+        bindData();
150
+    }
151
+
152
+    private void queryTags() {
153
+
154
+        Multi_query_epc mMulti_query_epc = new Multi_query_epc();
155
+        mMulti_query_epc.query_total = 0;
156
+
157
+        UHFClient info = UHFClient.getInstance();
158
+        if (info != null) {
159
+            UHFClient.mUHF.setCallBack(StockCountFragment.this);
160
+            UHFClient.mUHF.command(CommandType.MULTI_QUERY_TAGS_EPC, mMulti_query_epc);
161
+            stopped = false;
162
+        }
163
+    }
164
+
165
+    private void bindData() {
166
+        if (mCarInfo != null) {
167
+            //不再提供手动盘点 改为查看车辆详情
168
+            tvVin.setText(mCarInfo.getVin());
169
+            tvRfid.setText(mCarInfo.getRfid());
170
+            tvColor.setText(mCarInfo.getColor());
171
+            tvType.setText(mCarInfo.getType());
172
+            tvTime.setVisibility(View.GONE);
173
+            tvTimeTitle.setVisibility(View.GONE);
174
+            spiStatus.setVisibility(View.GONE);
175
+            spiStatus.setAdapter(new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, statuses));
176
+            tvStatus.setVisibility(View.VISIBLE);
177
+            tvStatus.setText(mCarInfo.getStatus());
178
+            switch (mCarInfo.getStatus()) {
179
+                case STATUS_MOVE:
180
+                    tvStatus.setTextColor(getActivity().getResources().getColor(R.color.car_move));
181
+                    break;
182
+                case STATUS_WEIPANDAO:
183
+                    tvStatus.setTextColor(getActivity().getResources().getColor(R.color.car_out));
184
+                    break;
185
+                default:
186
+                    tvStatus.setTextColor(getActivity().getResources().getColor(R.color.car_in));
187
+                    break;
188
+            }
189
+            btScan.setVisibility(View.GONE);
190
+            btSave.setVisibility(View.GONE);
191
+        } else if (mRecord != null) {
192
+            //查看盘点记录
193
+            tvVin.setText(mRecord.getVin());
194
+            tvRfid.setText(mRecord.getRfid());
195
+            tvType.setText(mRecord.getType());
196
+            tvColor.setText(mRecord.getColor());
197
+            tvStatus.setText(mRecord.getStatus());
198
+            switch (mRecord.getStatus()) {
199
+                case STATUS_MOVE:
200
+                    tvStatus.setTextColor(getActivity().getResources().getColor(R.color.car_move));
201
+                    break;
202
+                case STATUS_WEIPANDAO:
203
+                    tvStatus.setTextColor(getActivity().getResources().getColor(R.color.car_out));
204
+                    break;
205
+                default:
206
+                    tvStatus.setTextColor(getActivity().getResources().getColor(R.color.car_in));
207
+                    break;
208
+            }
209
+            tvTimeTitle.setVisibility(View.VISIBLE);
210
+            tvTime.setVisibility(View.VISIBLE);
211
+            tvTime.setText(DateUtils.format(mRecord.getCreateTime()));
212
+            switch (mRecord.getType()) {
213
+                case Record.TYPE_BANGDING:
214
+                    tvTimeTitle.setText("绑定时间:");
215
+                    break;
216
+                case Record.TYPE_JIEBANG:
217
+                    tvTimeTitle.setText("解绑时间:");
218
+                    break;
219
+                default:
220
+                    tvTimeTitle.setText("盘点时间:");
221
+                    break;
222
+            }
223
+            spiStatus.setVisibility(View.GONE);
224
+            btScan.setVisibility(View.GONE);
225
+            btSave.setVisibility(View.GONE);
226
+        } else {
227
+            tvStatus.setVisibility(View.VISIBLE);
228
+            spiStatus.setVisibility(View.GONE);
229
+            btScan.setVisibility(View.VISIBLE);
230
+            btSave.setVisibility(View.GONE);
231
+            tvTimeTitle.setVisibility(View.VISIBLE);
232
+            tvTime.setVisibility(View.VISIBLE);
233
+            tvVin.setText("");
234
+            tvRfid.setText("");
235
+            tvType.setText("");
236
+            tvColor.setText("");
237
+            tvStatus.setText("");
238
+            tvTime.setText("");
239
+        }
240
+
241
+    }
242
+
243
+    private void initListener() {
244
+        spiStatus.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
245
+            @Override
246
+            public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
247
+                tvStatus.setText(statuses[i]);
248
+            }
249
+
250
+            @Override
251
+            public void onNothingSelected(AdapterView<?> adapterView) {
252
+
253
+            }
254
+        });
255
+        btSave.setOnClickListener(new View.OnClickListener() {
256
+            @Override
257
+            public void onClick(View view) {
258
+                save(mCarInfo, true);
259
+            }
260
+        });
261
+        btScan.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
262
+            @Override
263
+            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
264
+                if (isChecked) {
265
+                    queryTags();
266
+                } else {
267
+                    stopQueryTags();
268
+                }
269
+            }
270
+        });
271
+    }
272
+
273
+    private void save(final CarInfo carInfo, boolean manual) {
274
+        final String tag = tvRfid.getText().toString();
275
+        final Record entity = new Record();
276
+        entity.setRfid(tag);
277
+        entity.setVin(tvVin.getText().toString());
278
+        entity.setStatus(tvStatus.getText().toString());
279
+        entity.setRemark("");
280
+        entity.setCreateTime(System.currentTimeMillis() + "");
281
+        entity.setOperatorId(MyApplication.currentUser.getLoginId());
282
+        entity.setStoreId(carInfo.getStoreId());
283
+        entity.setColor(carInfo.getColor());
284
+        entity.setCarType(carInfo.getType());
285
+        entity.setType(Record.TYPE_PANDIAN);
286
+        //todo 检查网络是否可用
287
+        boolean networkAvailable = false;
288
+        if (networkAvailable) {
289
+            RequestUtils.post("", new Gson().toJson(entity), new Callback() {
290
+                @Override
291
+                public void onFailure(Call call, IOException e) {
292
+                    e.printStackTrace();
293
+                }
294
+
295
+                @Override
296
+                public void onResponse(Call call, Response response) throws IOException {
297
+                    try (ResponseBody responseBody = response.body()) {
298
+                        if (!response.isSuccessful()) {
299
+                            throw new IOException("网络请求错误");
300
+                        } else {
301
+                            System.out.println(responseBody.string());
302
+                            boolean success = MyDao.saveToDb(getActivity(),carInfo, entity);
303
+                            Toast.makeText(getActivity(), success ? "vin:" + entity.getVin() + "盘点成功" : "盘点失败:数据保存失败", Toast.LENGTH_SHORT).show();
304
+                        }
305
+                    }
306
+                }
307
+            });
308
+        } else {
309
+            boolean success = MyDao.saveToDb(getActivity(),carInfo, entity);
310
+            Toast.makeText(getActivity(), success ? "vin:" + entity.getVin() + "盘点成功" : "盘点失败:数据保存失败", Toast.LENGTH_SHORT).show();
311
+            Log.i("StockCount", entity.getId() + "");
312
+        }
313
+        if (manual) {
314
+            startActivity(new Intent(getActivity(), CarListActivity.class));
315
+        }
316
+    }
317
+
318
+
319
+
320
+    @Override
321
+    public void onDestroyView() {
322
+        super.onDestroyView();
323
+        ButterKnife.unbind(this);
324
+        EventBus.getDefault().unregister(this);
325
+        if (handlerThread != null) {
326
+            handlerThread.quit();
327
+            handlerThread.interrupt();
328
+        }
329
+        handlerThread = null;
330
+    }
331
+
332
+    @Override
333
+    protected void onInvisible() {
334
+        super.onInvisible();
335
+        if (btScan != null) {
336
+            btScan.setChecked(false);
337
+        }
338
+    }
339
+
340
+    private void stopQueryTags() {
341
+        UHFClient info = UHFClient.getInstance();
342
+        if (info != null) {
343
+            new Thread(new Runnable() {
344
+                @Override
345
+                public void run() {
346
+                    stopped = UHFClient.mUHF.command(CommandType.STOP_MULTI_QUERY_TAGS_EPC, null);
347
+                    handlerThread.quit();
348
+                    handlerThread.interrupt();
349
+                    if (stopped) {
350
+                        Log.i("rfid", "Stop Ok");
351
+                    } else {
352
+                        Log.w("rfid", "Stop Fail");
353
+                    }
354
+                    UHFClient.mUHF.setCallBack(null);
355
+                }
356
+            }).run();
357
+        }
358
+    }
359
+
360
+    HandlerThread handlerThread;
361
+    Handler handler;
362
+
363
+    @Override
364
+    public void method(final char[] data) {
365
+        //当前在子线程内
366
+        //可改为Executors.newFixedThreadPool(5)线程池方式
367
+        if (data.length <= 0) {
368
+            return;
369
+        }
370
+        if (handlerThread == null) {
371
+            handlerThread = new HandlerThread("HandlerThread");
372
+        }
373
+        try {
374
+            handlerThread.start();
375
+        } catch (Exception e) {
376
+        }
377
+        if (handler == null) {
378
+            handler = new Handler(handlerThread.getLooper()) {
379
+                @Override
380
+                public void handleMessage(Message msg) {
381
+                    char[] data = (char[]) msg.obj;
382
+                    doWork(data);
383
+                    super.handleMessage(msg);
384
+                }
385
+            };
386
+        }
387
+        Message msg = new Message();
388
+        msg.obj = data;
389
+        handler.sendMessage(msg);
390
+
391
+    }
392
+
393
+    void doWork(char[] data) {
394
+        //把EPC拷贝出来显示
395
+        char msb = data[0];
396
+        char lsb = data[1];
397
+        int pc = (msb & 0x00ff) << 8 | (lsb & 0x00ff);
398
+        pc = (pc & 0xf800) >> 11;
399
+
400
+        char[] tmp = new char[pc * 2];
401
+        System.arraycopy(data, 2, tmp, 0, tmp.length);
402
+        String str_tmp = ShareData.CharToString(tmp, tmp.length);
403
+        str_tmp = str_tmp.replace(" ", "");
404
+        final String finalStr_tmp = str_tmp;
405
+        mHandler.post(new Runnable() {
406
+            @Override
407
+            public void run() {
408
+                if (stopped) {
409
+                    LogUtils.i("tags.clear");
410
+                    tags.clear();
411
+                    mHandler.removeCallbacksAndMessages(null);
412
+                    return;
413
+                }
414
+                if (!tags.contains(finalStr_tmp)) {
415
+                    tags.add(finalStr_tmp);
416
+                    Log.i("rfid", "str_tmp=" + finalStr_tmp);
417
+                    //todo 后续优化 预先把数据库车辆数据读取到内存集合中 从集合中查找
418
+                    CarInfo carInfo = mCarInfoDao.queryBuilder().where(CarInfoDao.Properties.Rfid.eq(finalStr_tmp)).unique();
419
+                    if (carInfo == null) {
420
+                        LogUtils.i(finalStr_tmp + "尚未绑定车辆");
421
+                        ToastUtils.showShort("盘点失败:" + finalStr_tmp + "尚未绑定车辆");
422
+                        return;
423
+                    }
424
+                    tvRfid.setText(finalStr_tmp);
425
+                    tvVin.setText(carInfo.getVin());
426
+                    tvType.setText(carInfo.getType());
427
+                    tvColor.setText(carInfo.getColor());
428
+                    tvStatus.setText("在库");
429
+                    tvStatus.setTextColor(getActivity().getResources().getColor(R.color.car_in));
430
+                    tvTime.setText(DateUtils.format(System.currentTimeMillis()));
431
+                    save(carInfo, false);
432
+                }
433
+            }
434
+        });
435
+    }
436
+
437
+    @Override
438
+    protected void lazyLoad() {
439
+        if (!isVisible) {
440
+            return;
441
+        }
442
+        new Thread(new Runnable() {
443
+            @Override
444
+            public void run() {
445
+                UHFUtils uhfUtils = new UHFUtils(getActivity());
446
+                uhfUtils.handleSetPower(30);
447
+            }
448
+        }).run();
449
+        if (btScan != null) {
450
+            btScan.setChecked(false);
451
+        }
452
+    }
453
+
454
+    @Override
455
+    public void onKeyDown(int keyCode, KeyEvent event) {
456
+        Log.i("StockCountFragment", "onkeyDown");
457
+        if (btScan.getVisibility() == View.VISIBLE) {
458
+            btScan.setChecked(!btScan.isChecked());
459
+        }
460
+    }
461
+
462
+    @Subscribe()
463
+    public void onMessageEvent(BindEvent bindEvent) {
464
+        //对于先盘点发现未绑定然后绑定的tag,应从tags里移除,避免再次进入"尚未绑定车辆"代码块
465
+        String tag = bindEvent.tag;
466
+        if (!TextUtils.isEmpty(tag)) {
467
+            if (tags.contains(tag)) {
468
+                tags.remove(tag);
469
+            }
470
+        }
471
+    }
472
+}

+ 66 - 0
app/src/main/java/hf/lskj/com/carstockcount/utils/ActivityJump.java

@@ -0,0 +1,66 @@
1
+package hf.lskj.com.carstockcount.utils;
2
+
3
+import android.app.Activity;
4
+import android.content.Context;
5
+import android.content.Intent;
6
+import android.os.Bundle;
7
+
8
+/**
9
+ * 跳转界面工具类
10
+ * Created by mQ on 2016/9/19.
11
+ */
12
+public class ActivityJump {
13
+
14
+
15
+    /**
16
+     * 普通跳转
17
+     *
18
+     * @param context
19
+     * @param cls
20
+     */
21
+    public static void startActivity(Context context, Class<?> cls) {
22
+        context.startActivity(new Intent().setClass(context, cls));
23
+    }
24
+
25
+    /**
26
+     * 带数据普通跳转
27
+     *
28
+     * @param context
29
+     * @param bundle
30
+     * @param cls
31
+     */
32
+    public static void startActivity(Context context, Class<?> cls ,Bundle bundle) {
33
+        context.startActivity(new Intent().setClass(context, cls).putExtras(bundle));
34
+    }
35
+
36
+    /**
37
+     * 带回传的跳转
38
+     *
39
+     * @param context
40
+     * @param cls
41
+     * @param requestCode
42
+     */
43
+    public static void startActivityForResult(Activity context, Class<?> cls, int requestCode) {
44
+        Intent intent = new Intent();
45
+        intent.setClass(context, cls);
46
+        context.startActivityForResult(intent, requestCode);
47
+    }
48
+
49
+    /**
50
+     * 带数据带回传的跳转
51
+     *
52
+     * @param context
53
+     * @param cls
54
+     * @param bundle
55
+     * @param requestCode
56
+     */
57
+    public static void startActivityForResult(Activity context, Class<?> cls, Bundle bundle, int requestCode) {
58
+        Intent intent = new Intent();
59
+        intent.setClass(context, cls);
60
+        intent.putExtras(bundle);
61
+        context.startActivityForResult(intent, requestCode);
62
+    }
63
+
64
+
65
+
66
+}

+ 44 - 0
app/src/main/java/hf/lskj/com/carstockcount/utils/AppUtils.java

@@ -0,0 +1,44 @@
1
+package hf.lskj.com.carstockcount.utils;
2
+
3
+import android.content.Context;
4
+import android.content.pm.ApplicationInfo;
5
+import android.content.pm.PackageInfo;
6
+import android.content.pm.PackageManager;
7
+
8
+/**
9
+ * Created on 2016/8/15.
10
+ * Author:crs
11
+ * Description:app工具类
12
+ */
13
+public class AppUtils {
14
+
15
+    //获取应用程序名称
16
+    public static String getAppName(Context context) {
17
+        try {
18
+            PackageManager pm = context.getPackageManager();
19
+            PackageInfo packageInfo = pm.getPackageInfo(context.getPackageName(), 0);
20
+            ApplicationInfo applicationInfo = packageInfo.applicationInfo;
21
+            //这种方式是可以的
22
+            //String name = applicationInfo.loadLabel(pm).toString();
23
+            int labelRes = applicationInfo.labelRes;
24
+            String name = context.getResources().getString(labelRes);
25
+            return name;
26
+        } catch (PackageManager.NameNotFoundException e) {
27
+            e.printStackTrace();
28
+        }
29
+        return "";
30
+    }
31
+
32
+    //获取应用程序版本名称
33
+    public static String getVersionName(Context context) {
34
+        try {
35
+            PackageManager packageManager = context.getPackageManager();
36
+            PackageInfo packageInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
37
+            String versionName = packageInfo.versionName;
38
+            return versionName;
39
+        } catch (PackageManager.NameNotFoundException e) {
40
+            e.printStackTrace();
41
+        }
42
+        return "";
43
+    }
44
+}

+ 296 - 0
app/src/main/java/hf/lskj/com/carstockcount/utils/Bimp.java

@@ -0,0 +1,296 @@
1
+package hf.lskj.com.carstockcount.utils;
2
+
3
+import android.graphics.Bitmap;
4
+import android.graphics.BitmapFactory;
5
+import android.graphics.Canvas;
6
+import android.graphics.Color;
7
+import android.graphics.Paint;
8
+import android.graphics.PorterDuff;
9
+import android.graphics.PorterDuffXfermode;
10
+import android.graphics.RectF;
11
+import android.graphics.drawable.BitmapDrawable;
12
+import android.graphics.drawable.Drawable;
13
+import android.util.Log;
14
+
15
+import java.io.BufferedInputStream;
16
+import java.io.ByteArrayInputStream;
17
+import java.io.ByteArrayOutputStream;
18
+import java.io.File;
19
+import java.io.FileInputStream;
20
+import java.io.FileNotFoundException;
21
+import java.io.IOException;
22
+import java.util.ArrayList;
23
+import java.util.List;
24
+
25
+/**
26
+ * 压缩图片
27
+ *
28
+ * @author Administrator
29
+ */
30
+public class Bimp {
31
+    public static int max = 0;
32
+    public static boolean act_bool = true;
33
+    public static List<Bitmap> bmp = new ArrayList<Bitmap>();
34
+
35
+    // 图片sd地址 上传服务器时把图片调用下面方法压缩后 保存到临时文件夹 图片压缩后小于100KB,失真度不明显
36
+    public static List<String> drr = new ArrayList<String>();
37
+
38
+    // TelephonyManager tm = (TelephonyManager) this
39
+    // .getSystemService(Context.TELEPHONY_SERVICE);
40
+
41
+    public static Bitmap revitionImageSize(String path) throws IOException {
42
+        BufferedInputStream in = new BufferedInputStream(new FileInputStream(
43
+                new File(path)));
44
+
45
+        BitmapFactory.Options options = new BitmapFactory.Options();
46
+        options.inJustDecodeBounds = true;
47
+        // Bitmap btBitmap=BitmapFactory.decodeFile(path);
48
+        // System.out.println("原尺寸高度:"+btBitmap.getHeight());
49
+        // System.out.println("原尺寸宽度:"+btBitmap.getWidth());
50
+        BitmapFactory.decodeStream(in, null, options);
51
+        in.close();
52
+        int i = 0;
53
+        Bitmap bitmap = null;
54
+        while (true) {
55
+            if ((options.outWidth >> i <= 800)
56
+                    && (options.outHeight >> i <= 800)) {
57
+                in = new BufferedInputStream(
58
+                        new FileInputStream(new File(path)));
59
+                options.inSampleSize = (int) Math.pow(2.0D, i);
60
+                options.inJustDecodeBounds = false;
61
+                bitmap = BitmapFactory.decodeStream(in, null, options);
62
+                break;
63
+            }
64
+            i += 1;
65
+        }
66
+        // 当机型为三星时图片翻转
67
+//		bitmap = Photo.photoAdapter(path, bitmap);
68
+//		System.out.println("-----压缩后尺寸高度:" + bitmap.getHeight());
69
+//		System.out.println("-----压缩后尺寸宽度度:" + bitmap.getWidth());
70
+        return bitmap;
71
+    }
72
+
73
+    public static Bitmap getLoacalBitmap(String url) {
74
+        try {
75
+            FileInputStream fis = new FileInputStream(url);
76
+            return BitmapFactory.decodeStream(fis); // /把流转化为Bitmap图片
77
+        } catch (FileNotFoundException e) {
78
+            e.printStackTrace();
79
+            return null;
80
+        }
81
+    }
82
+
83
+
84
+    /**
85
+     * @param x              图像的宽度
86
+     * @param y              图像的高度
87
+     * @param image          源图片
88
+     * @param outerRadiusRat 圆角的大小
89
+     * @return 圆角图片
90
+     */
91
+    public static Bitmap createFramedPhoto(int x, int y, Bitmap image, float outerRadiusRat) {
92
+        // 根据源文件新建一个darwable对象
93
+        Drawable imageDrawable = new BitmapDrawable(image);
94
+
95
+        // 新建一个新的输出图片
96
+        Bitmap output = Bitmap.createBitmap(x, y, Bitmap.Config.ARGB_8888);
97
+        Canvas canvas = new Canvas(output);
98
+
99
+        // 新建一个矩形
100
+        RectF outerRect = new RectF(0, 0, x, y);
101
+
102
+        // 产生一个红色的圆角矩形
103
+        Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
104
+        paint.setColor(Color.RED);
105
+        canvas.drawRoundRect(outerRect, outerRadiusRat, outerRadiusRat, paint);
106
+
107
+        // 将源图片绘制到这个圆角矩形上
108
+        paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
109
+        imageDrawable.setBounds(0, 0, x, y);
110
+        canvas.saveLayer(outerRect, paint, Canvas.ALL_SAVE_FLAG);
111
+        imageDrawable.draw(canvas);
112
+        canvas.restore();
113
+
114
+        return output;
115
+    }
116
+
117
+    public static Bitmap getimage(String pathName) {
118
+        String srcPath = new File(pathName).getPath();
119
+        Log.i("TAG", "compressImage: "+pathName+"------file:"+srcPath);
120
+        BitmapFactory.Options newOpts = new BitmapFactory.Options();
121
+
122
+//开始读入图片,此时把options.inJustDecodeBounds 设回true了
123
+
124
+        newOpts.inJustDecodeBounds = true;
125
+
126
+        Bitmap bitmap = BitmapFactory.decodeFile(srcPath, newOpts);//此时返回bm为空
127
+
128
+        newOpts.inJustDecodeBounds = false;
129
+
130
+        int w = newOpts.outWidth;
131
+
132
+        int h = newOpts.outHeight;
133
+
134
+//现在主流手机比较多是800*480分辨率,所以高和宽我们设置为
135
+
136
+        float hh = 800f;//这里设置高度为800f
137
+
138
+        float ww = 480f;//这里设置宽度为480f
139
+
140
+//缩放比。由于是固定比例缩放,只用高或者宽其中一个数据进行计算即可
141
+
142
+        int be = 1;//be=1表示不缩放
143
+
144
+        if (w > h && w > ww) {//如果宽度大的话根据宽度固定大小缩放
145
+
146
+            be = (int) (newOpts.outWidth / ww);
147
+
148
+        } else if (w < h && h > hh) {//如果高度高的话根据宽度固定大小缩放
149
+
150
+            be = (int) (newOpts.outHeight / hh);
151
+
152
+        }
153
+
154
+        if (be <= 0)
155
+
156
+            be = 1;
157
+
158
+        newOpts.inSampleSize = be;//设置缩放比例
159
+
160
+//重新读入图片,注意此时已经把options.inJustDecodeBounds 设回false了
161
+
162
+        bitmap = BitmapFactory.decodeFile(srcPath, newOpts);
163
+
164
+        return compressImage(bitmap);//压缩好比例大小后再进行质量压缩
165
+    }
166
+
167
+    public static Bitmap comp(Bitmap image) {
168
+
169
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
170
+
171
+        image.compress(Bitmap.CompressFormat.JPEG, 100, baos);
172
+
173
+        if (baos.toByteArray().length / 1024 > 1024) {//判断如果图片大于1M,进行压缩避免在生成图片(BitmapFactory.decodeStream)时溢出
174
+
175
+            baos.reset();//重置baos即清空baos
176
+
177
+            image.compress(Bitmap.CompressFormat.JPEG, 50, baos);//这里压缩50%,把压缩后的数据存放到baos中
178
+
179
+        }
180
+
181
+        ByteArrayInputStream isBm = new ByteArrayInputStream(baos.toByteArray());
182
+
183
+        BitmapFactory.Options newOpts = new BitmapFactory.Options();
184
+
185
+//开始读入图片,此时把options.inJustDecodeBounds 设回true了
186
+
187
+        newOpts.inJustDecodeBounds = true;
188
+
189
+        Bitmap bitmap = BitmapFactory.decodeStream(isBm, null, newOpts);
190
+
191
+        newOpts.inJustDecodeBounds = false;
192
+
193
+        int w = newOpts.outWidth;
194
+
195
+        int h = newOpts.outHeight;
196
+
197
+//现在主流手机比较多是800*480分辨率,所以高和宽我们设置为
198
+
199
+        float hh = 800f;//这里设置高度为800f
200
+
201
+        float ww = 480f;//这里设置宽度为480f
202
+
203
+//缩放比。由于是固定比例缩放,只用高或者宽其中一个数据进行计算即可
204
+
205
+        int be = 1;//be=1表示不缩放
206
+
207
+        if (w > h && w > ww) {//如果宽度大的话根据宽度固定大小缩放
208
+
209
+            be = (int) (newOpts.outWidth / ww);
210
+
211
+        } else if (w < h && h > hh) {//如果高度高的话根据宽度固定大小缩放
212
+
213
+            be = (int) (newOpts.outHeight / hh);
214
+
215
+        }
216
+
217
+        if (be <= 0)
218
+
219
+            be = 1;
220
+
221
+        newOpts.inSampleSize = be;//设置缩放比例
222
+
223
+        newOpts.inPreferredConfig = Bitmap.Config.RGB_565;//降低图片从ARGB888到RGB565
224
+
225
+//重新读入图片,注意此时已经把options.inJustDecodeBounds 设回false了
226
+
227
+        isBm = new ByteArrayInputStream(baos.toByteArray());
228
+
229
+        bitmap = BitmapFactory.decodeStream(isBm, null, newOpts);
230
+
231
+        return compressImage(bitmap);//压缩好比例大小后再进行质量压缩
232
+    }
233
+
234
+    public static Bitmap compressImage(Bitmap image) {
235
+        if (image != null) {
236
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
237
+
238
+            image.compress(Bitmap.CompressFormat.JPEG, 100, baos);//质量压缩方法,这里100表示不压缩,把压缩后的数据存放到baos中
239
+
240
+            int options = 100;
241
+
242
+            while (baos.toByteArray().length / 1024 > 100) {//循环判断如果压缩后图片是否大于100kb,大于继续压缩
243
+
244
+                baos.reset();//重置baos即清空baos
245
+
246
+                options -= 10;//每次都减少10
247
+
248
+                image.compress(Bitmap.CompressFormat.JPEG, options, baos);//这里压缩options%,把压缩后的数据存放到baos中
249
+
250
+            }
251
+
252
+            ByteArrayInputStream isBm = new ByteArrayInputStream(baos.toByteArray());//把压缩后的数据baos存放到ByteArrayInputStream中
253
+
254
+            Bitmap bitmap = BitmapFactory.decodeStream(isBm, null, null);//把ByteArrayInputStream数据生成图片
255
+            Log.i("TAG", "compressImage: 压缩成功");
256
+            return bitmap;
257
+        }
258
+        Log.i("TAG", "compressImage: 压缩失败");
259
+        return null;
260
+    }
261
+
262
+    public static Bitmap compressImage(String pathName) {
263
+        String path = new File(pathName).getPath();
264
+        Bitmap image = BitmapFactory.decodeFile(path);
265
+        Log.i("TAG", "compressImage: "+pathName+"------file:"+path);
266
+        if (image != null) {
267
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
268
+
269
+            image.compress(Bitmap.CompressFormat.JPEG, 100, baos);//质量压缩方法,这里100表示不压缩,把压缩后的数据存放到baos中
270
+
271
+            int options = 100;
272
+
273
+            while (baos.toByteArray().length / 1024 > 100) {//循环判断如果压缩后图片是否大于100kb,大于继续压缩
274
+
275
+                baos.reset();//重置baos即清空baos
276
+
277
+                options -= 10;//每次都减少10
278
+
279
+                image.compress(Bitmap.CompressFormat.JPEG, options, baos);//这里压缩options%,把压缩后的数据存放到baos中
280
+
281
+            }
282
+
283
+            ByteArrayInputStream isBm = new ByteArrayInputStream(baos.toByteArray());//把压缩后的数据baos存放到ByteArrayInputStream中
284
+
285
+            Bitmap bitmap = BitmapFactory.decodeStream(isBm, null, null);//把ByteArrayInputStream数据生成图片
286
+
287
+            Log.i("TAG", "compressImage: 压缩成功");
288
+
289
+            return bitmap;
290
+
291
+        }
292
+        Log.i("TAG", "compressImage: 压缩失败");
293
+        return null;
294
+    }
295
+
296
+}

+ 43 - 0
app/src/main/java/hf/lskj/com/carstockcount/utils/DPUtils.java

@@ -0,0 +1,43 @@
1
+package hf.lskj.com.carstockcount.utils;
2
+
3
+import android.content.Context;
4
+
5
+/**
6
+ * dp、sp 转换为 px 的工具类
7
+ * Created by hupai on 2016/9/4.
8
+ */
9
+public class DPUtils {
10
+
11
+    /**
12
+     * 将dip或dp值转换为px值,保证尺寸大小不变
13
+     */
14
+    public static int dp2px(Context context, float dp) {
15
+        final float scale = context.getResources().getDisplayMetrics().density;
16
+        return (int) (dp * scale + 0.5f);
17
+    }
18
+
19
+    /**
20
+     * 将px值转换为dip或dp值,保证尺寸大小不变
21
+     */
22
+    public static int px2dp(Context context, float px) {
23
+        final float scale = context.getResources().getDisplayMetrics().density;
24
+        return (int) (px / scale + 0.5f);
25
+    }
26
+
27
+    /**
28
+     * 将px值转换为sp值,保证文字大小不变
29
+     */
30
+    public static int px2sp(Context context, float pxValue) {
31
+        final float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
32
+        return (int) (pxValue / fontScale + 0.5f);
33
+    }
34
+
35
+    /**
36
+     * 将sp值转换为px值,保证文字大小不变
37
+     */
38
+    public static int sp2px(Context context, float spValue) {
39
+        final float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
40
+        return (int) (spValue * fontScale + 0.5f);
41
+    }
42
+
43
+}

+ 86 - 0
app/src/main/java/hf/lskj/com/carstockcount/utils/DateUtils.java

@@ -0,0 +1,86 @@
1
+package hf.lskj.com.carstockcount.utils;
2
+
3
+import android.text.TextUtils;
4
+
5
+import java.text.SimpleDateFormat;
6
+import java.util.Calendar;
7
+import java.util.Date;
8
+
9
+/**
10
+ * Created by yaoju on 2017/4/11.
11
+ */
12
+
13
+public class DateUtils {
14
+
15
+    public static String format(Date date) {
16
+        return format(date.getTime());
17
+    }
18
+
19
+    public static String format(Date date, String formatter) {
20
+        SimpleDateFormat sdf = new SimpleDateFormat(formatter);
21
+        return sdf.format(date);
22
+    }
23
+
24
+    public static String format(String timeInMills) {
25
+        if (TextUtils.isEmpty(timeInMills)) {
26
+            return "";
27
+        }
28
+        return format(Long.valueOf(timeInMills));
29
+    }
30
+    public static String format(Calendar calendar){
31
+        return format(calendar.getTimeInMillis());
32
+    }
33
+    public static String format(long timeInMills) {
34
+        Date date = new Date(timeInMills);
35
+        return format(date, "yyyy-M-d H:m");
36
+    }
37
+
38
+    public static String formatDate(Date date) {
39
+        if (date == null) {
40
+            return "";
41
+        }
42
+        String formatter = "yyyy-M-d";
43
+        SimpleDateFormat sdf = new SimpleDateFormat(formatter);
44
+        return sdf.format(date);
45
+    }
46
+
47
+    public static String addDays(String dateStr, int days) {
48
+        return addDays(dateStr, null, days);
49
+    }
50
+
51
+    public static String addDays(String dateStr, String formatter, int days) {
52
+        if (TextUtils.isEmpty(dateStr)) {
53
+            return "";
54
+        }
55
+        if (TextUtils.isEmpty(formatter)) {
56
+            formatter = "yyyy-MM-dd";
57
+        }
58
+        SimpleDateFormat sdf = new SimpleDateFormat(formatter);
59
+        try {
60
+            Date date = sdf.parse(dateStr);
61
+            return addDays(date, formatter, days);
62
+        } catch (Exception ex) {
63
+            return "";
64
+        }
65
+
66
+    }
67
+
68
+    public static String addDays(Date date, String formatter, int days) {
69
+        if (TextUtils.isEmpty(formatter)) {
70
+            return addDays(date, days);
71
+        } else {
72
+            return format(addDaysToDate(date, days), formatter);
73
+        }
74
+    }
75
+
76
+    public static String addDays(Date date, int days) {
77
+        return formatDate(addDaysToDate(date, days));
78
+    }
79
+
80
+    public static Date addDaysToDate(Date date, int days) {
81
+        Calendar calendar = Calendar.getInstance();
82
+        calendar.setTime(date);
83
+        calendar.add(Calendar.DAY_OF_MONTH, days);
84
+        return calendar.getTime();
85
+    }
86
+}

+ 133 - 0
app/src/main/java/hf/lskj/com/carstockcount/utils/FileUtils.java

@@ -0,0 +1,133 @@
1
+package hf.lskj.com.carstockcount.utils;
2
+
3
+import android.content.Context;
4
+import android.content.Intent;
5
+import android.graphics.Bitmap;
6
+import android.media.MediaScannerConnection;
7
+import android.net.Uri;
8
+import android.os.Environment;
9
+import android.text.TextUtils;
10
+import android.util.Log;
11
+import android.webkit.MimeTypeMap;
12
+import android.widget.Toast;
13
+
14
+import com.google.gson.Gson;
15
+
16
+import java.io.File;
17
+import java.io.FileOutputStream;
18
+import java.io.FileReader;
19
+import java.io.IOException;
20
+
21
+import hf.lskj.com.carstockcount.MyApplication;
22
+import hf.lskj.com.carstockcount.activity.LoginActivity;
23
+import hf.lskj.com.carstockcount.db.InitData;
24
+import hf.lskj.com.carstockcount.db.User;
25
+import hf.lskj.com.carstockcount.db.UserDaoUtils;
26
+
27
+public class FileUtils {
28
+    public static final String FILE_INIT = "用户数据";
29
+    public static final String FILE_CARS="车辆数据";
30
+    public static final String FILE_RECORD="盘点记录";
31
+    public static final String SDPATH = Environment.getExternalStorageDirectory()
32
+            + "/hplk/";
33
+
34
+    public static String saveBitmap(Bitmap bm, String picName) {
35
+        Log.i("TAG", "保存图片");
36
+        try {
37
+            if (!isFileExist("")) {
38
+                File tempf = createSDDir("");
39
+            }
40
+            File f = new File(SDPATH, picName + ".jpeg");
41
+            if (f.exists()) {
42
+                f.delete();
43
+            }
44
+            FileOutputStream out = new FileOutputStream(f);
45
+            bm.compress(Bitmap.CompressFormat.JPEG, 90, out);
46
+            out.flush();
47
+            out.close();
48
+            Log.i("TAG", "已经保存");
49
+            return SDPATH + picName + ".jpeg";
50
+        } catch (IOException e) {
51
+            e.printStackTrace();
52
+        }
53
+        return null;
54
+    }
55
+
56
+    public static File createSDDir(String dirName) throws IOException {
57
+        File dir = new File(SDPATH + dirName);
58
+        if (Environment.getExternalStorageState().equals(
59
+                Environment.MEDIA_MOUNTED)) {
60
+
61
+            System.out.println("createSDDir:" + dir.getAbsolutePath());
62
+            System.out.println("createSDDir:" + dir.mkdir());
63
+        }
64
+        return dir;
65
+    }
66
+
67
+    public static boolean isFileExist(String fileName) {
68
+        File file = new File(SDPATH + fileName);
69
+        file.isFile();
70
+        return file.exists();
71
+    }
72
+
73
+    public static void delFile(String fileName) {
74
+        File file = new File(SDPATH + fileName);
75
+        if (file.isFile()) {
76
+            file.delete();
77
+        }
78
+        file.exists();
79
+    }
80
+
81
+    public static void deleteDir(String path) {
82
+        if (TextUtils.isEmpty(path)) {
83
+            return;
84
+        }
85
+        File dir = new File(path);
86
+        if (!dir.exists() || !dir.isDirectory())
87
+            return;
88
+
89
+        for (File file : dir.listFiles()) {
90
+            if (file.isFile())
91
+                file.delete(); // 删除所有文件
92
+            else if (file.isDirectory())
93
+                deleteDir(path); // 递规的方式删除文件夹
94
+        }
95
+        dir.delete();// 删除目录本身
96
+    }
97
+
98
+    public static boolean fileIsExists(String path) {
99
+        try {
100
+            File f = new File(path);
101
+            if (!f.exists()) {
102
+                return false;
103
+            }
104
+        } catch (Exception e) {
105
+
106
+            return false;
107
+        }
108
+        return true;
109
+    }
110
+    public static void refreshFile(String filePath) {
111
+        File file = new File(filePath);
112
+        MimeTypeMap mtm = MimeTypeMap.getSingleton();
113
+        MediaScannerConnection.scanFile(MyApplication.getInstances(),
114
+                new String[] { file.toString() },
115
+                new String[] { mtm.getMimeTypeFromExtension(file.toString().substring(file.toString().lastIndexOf(".")+1)) },
116
+                new MediaScannerConnection.OnScanCompletedListener() {
117
+                    @Override
118
+                    public void onScanCompleted(final String path, final Uri uri) {
119
+                        LogUtils.i("刷新完毕");
120
+                    }
121
+                });
122
+    }
123
+    /**
124
+     * 出发扫描 mtp下的文件,在保存文件到 sd卡下后,不能显示,故这里触发一下扫描机制,让手机连上电脑后,就可以读出文件了
125
+     *
126
+     * @param fName,文件的完整路径名
127
+     */
128
+    public static void fileScan(String fName) {
129
+        Uri data = Uri.parse("file:///" + fName);
130
+        MyApplication.getInstances().sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, data));
131
+    }
132
+}
133
+

+ 54 - 0
app/src/main/java/hf/lskj/com/carstockcount/utils/KeyBoardUtils.java

@@ -0,0 +1,54 @@
1
+package hf.lskj.com.carstockcount.utils;
2
+
3
+import android.app.Activity;
4
+import android.content.Context;
5
+import android.view.View;
6
+import android.view.inputmethod.InputMethodManager;
7
+import android.widget.EditText;
8
+
9
+/**
10
+ * Created on 2016/8/15.
11
+ * Author:crs
12
+ * Description:软键盘工具类,需要事件触发
13
+ */
14
+public class KeyBoardUtils {
15
+
16
+    /**
17
+     * 打开软键盘
18
+     *
19
+     * @param editText
20
+     * @param context
21
+     */
22
+    public static void openKeybord(EditText editText, Context context) {
23
+        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
24
+        imm.showSoftInput(editText, InputMethodManager.RESULT_SHOWN);
25
+        imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
26
+    }
27
+
28
+    /**
29
+     * 关闭软键盘
30
+     *
31
+     * @param editText
32
+     * @param context
33
+     */
34
+    public static void closeKeybord(EditText editText, Context context) {
35
+        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
36
+        imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
37
+    }
38
+
39
+    /**
40
+     * 关闭软键盘
41
+     *
42
+     * @param context
43
+     */
44
+    public static void closeKeybord(Context context) {
45
+        if (context instanceof Activity) {
46
+            View focusView = ((Activity) context).getCurrentFocus();
47
+            if (focusView != null) {
48
+                InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
49
+                imm.hideSoftInputFromWindow(focusView.getWindowToken(), 0);
50
+            }
51
+        }
52
+
53
+    }
54
+}

+ 105 - 0
app/src/main/java/hf/lskj/com/carstockcount/utils/LogUtils.java

@@ -0,0 +1,105 @@
1
+package hf.lskj.com.carstockcount.utils;
2
+
3
+import android.text.TextUtils;
4
+import android.util.Log;
5
+
6
+/**
7
+ * Created on 2016/8/1.
8
+ * Author:crs
9
+ * Description:XXX
10
+ */
11
+public class LogUtils {
12
+    public static String getTag() {
13
+        return tag;
14
+    }
15
+
16
+    public static void setTag(String tag) {
17
+        LogUtils.tag = tag;
18
+    }
19
+
20
+    private static String tag = "x_log";
21
+
22
+    public static boolean isDebug = true;
23
+
24
+    public static void e(String msg) {
25
+        e(tag, msg);
26
+    }
27
+
28
+    public static void e(Throwable ex) {
29
+        e(tag, ex);
30
+    }
31
+
32
+    public static void w(String msg) {
33
+        w(tag, msg);
34
+    }
35
+
36
+    public static void v(String msg) {
37
+        v(tag, msg);
38
+    }
39
+
40
+
41
+    public static void d(String msg) {
42
+        d(tag, msg);
43
+    }
44
+
45
+    public static void i(String msg) {
46
+        i(tag, msg);
47
+    }
48
+
49
+    public static void e(String tag, String msg) {
50
+        if (isDebug) {
51
+            if (TextUtils.isEmpty(msg)) {
52
+                return;
53
+            }
54
+            Log.e(tag, msg);
55
+        }
56
+
57
+    }
58
+
59
+    public static void e(String tag, Throwable ex) {
60
+        if (isDebug) {
61
+            if (ex == null) {
62
+                return;
63
+            }
64
+            Log.e(tag, null, ex);
65
+        }
66
+
67
+    }
68
+
69
+    public static void w(String tag, String msg) {
70
+        if (isDebug) {
71
+            if (TextUtils.isEmpty(msg)) {
72
+                return;
73
+            }
74
+            Log.w(tag, msg);
75
+        }
76
+    }
77
+
78
+    public static void v(String tag, String msg) {
79
+        if (isDebug) {
80
+            if (TextUtils.isEmpty(msg)) {
81
+                return;
82
+            }
83
+            Log.v(tag, msg);
84
+        }
85
+    }
86
+
87
+
88
+    public static void d(String tag, String msg) {
89
+        if (isDebug) {
90
+            if (TextUtils.isEmpty(msg)) {
91
+                return;
92
+            }
93
+            Log.d(tag, msg);
94
+        }
95
+    }
96
+
97
+    public static void i(String tag, String msg) {
98
+        if (isDebug) {
99
+            if (TextUtils.isEmpty(msg)) {
100
+                return;
101
+            }
102
+            Log.i(tag, msg);
103
+        }
104
+    }
105
+}

+ 63 - 0
app/src/main/java/hf/lskj/com/carstockcount/utils/NetUtils.java

@@ -0,0 +1,63 @@
1
+package hf.lskj.com.carstockcount.utils;
2
+
3
+import android.app.Activity;
4
+import android.content.ComponentName;
5
+import android.content.Context;
6
+import android.content.Intent;
7
+import android.net.ConnectivityManager;
8
+import android.net.NetworkInfo;
9
+
10
+/**
11
+ * Created on 2016/8/15.
12
+ * Author:crs
13
+ * Description:网络工具类
14
+ */
15
+public class NetUtils {
16
+
17
+    /**
18
+     * 判断网络是否连接
19
+     *
20
+     * @param context
21
+     * @return
22
+     */
23
+    public static boolean isConnected(Context context) {
24
+        ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
25
+        if (cm != null) {
26
+            NetworkInfo activeNetworkInfo = cm.getActiveNetworkInfo();
27
+            if (activeNetworkInfo != null && activeNetworkInfo.isConnected()) {
28
+                if (activeNetworkInfo.getState() == NetworkInfo.State.CONNECTED) {
29
+                    return true;
30
+                }
31
+            }
32
+        }
33
+        return false;
34
+    }
35
+
36
+    /**
37
+     * 判断是不是WiFi连接
38
+     *
39
+     * @param context
40
+     * @return
41
+     */
42
+    public static boolean isWifi(Context context) {
43
+        ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
44
+        if (cm != null) {
45
+            return cm.getActiveNetworkInfo().getType() == ConnectivityManager.TYPE_WIFI;
46
+        }
47
+        return false;
48
+    }
49
+
50
+    /**
51
+     * 打开网络设置界面
52
+     *
53
+     * @param activity
54
+     */
55
+    public static void openSetting(Activity activity) {
56
+        Intent intent = new Intent("/");
57
+        ComponentName cm = new ComponentName("com.android.settings", "com.android.settings.WirelessSettings");
58
+        intent.setComponent(cm);
59
+        intent.setAction("android.intent.action.VIEW");
60
+        activity.startActivityForResult(intent, 0);
61
+    }
62
+
63
+}

+ 204 - 0
app/src/main/java/hf/lskj/com/carstockcount/utils/NumberFormatUtil.java

@@ -0,0 +1,204 @@
1
+package hf.lskj.com.carstockcount.utils;
2
+
3
+import android.text.TextUtils;
4
+
5
+import java.math.BigDecimal;
6
+import java.text.DecimalFormat;
7
+
8
+/**
9
+ * Created by yaoju on 2017/4/28.
10
+ */
11
+
12
+public class NumberFormatUtil {
13
+
14
+    static String[] units = {"", "十", "百", "千", "万", "十万", "百万", "千万", "亿", "十亿", "百亿", "千亿", "万亿"};
15
+    static char[] numArray = {'零', '一', '二', '三', '四', '五', '六', '七', '八', '九'};
16
+
17
+    /**
18
+     * 将整数转换成汉字数字
19
+     *
20
+     * @param num 需要转换的数字
21
+     * @return 转换后的汉字
22
+     */
23
+    public static String formatInteger(int num) {
24
+        char[] val = String.valueOf(num).toCharArray();
25
+        int len = val.length;
26
+        StringBuilder sb = new StringBuilder();
27
+        for (int i = 0; i < len; i++) {
28
+            String m = val[i] + "";
29
+            int n = Integer.parseInt(m);
30
+            boolean isZero = n == 0;
31
+            String unit = units[(len - 1) - i];
32
+            if (isZero) {
33
+                if ('0' == val[i - 1]) {
34
+                    continue;
35
+                } else {
36
+                    sb.append(numArray[n]);
37
+                }
38
+            } else {
39
+                sb.append(numArray[n]);
40
+                sb.append(unit);
41
+            }
42
+        }
43
+        return sb.toString();
44
+    }
45
+
46
+    /**
47
+     * 将小数转换成汉字数字
48
+     *
49
+     * @param decimal 需要转换的数字
50
+     * @return 转换后的汉字
51
+     */
52
+    public static String formatDecimal(double decimal) {
53
+
54
+        String decimals = String.valueOf(decimal);
55
+        return formatDecimal(decimals);
56
+    }
57
+
58
+    public static String formatDecimal(String decimal) {
59
+        String result;
60
+        int decIndex = decimal.indexOf(".");
61
+
62
+        if (decIndex >= 0) {
63
+            int integ = Integer.parseInt(decimal.substring(0, decIndex));
64
+            String xiaoshu = decimal.substring(decIndex + 1);
65
+            if (xiaoshu.length() > 0) {
66
+                int dec = Integer.valueOf(xiaoshu);
67
+                result = formatInteger(integ) + "点" + formatFractionalPart(dec);
68
+            } else {
69
+                result = formatInteger(integ);
70
+            }
71
+
72
+        } else {
73
+            int integ = Integer.parseInt(decimal);
74
+            result = formatInteger(integ);
75
+        }
76
+
77
+        return result;
78
+    }
79
+
80
+    /**
81
+     * 格式化小数部分的数字
82
+     *
83
+     * @param decimal 需要转换的数字
84
+     * @return 转换后的汉字
85
+     */
86
+    public static String formatFractionalPart(int decimal) {
87
+        char[] val = String.valueOf(decimal).toCharArray();
88
+        int len = val.length;
89
+        StringBuilder sb = new StringBuilder();
90
+        for (int i = 0; i < len; i++) {
91
+            int n = Integer.parseInt(val[i] + "");
92
+            sb.append(numArray[n]);
93
+        }
94
+        return sb.toString();
95
+    }
96
+
97
+    /**
98
+     * 去除科学记数法 2016.00-->2016
99
+     */
100
+    public static String convertDouble(String double1) {
101
+        if (TextUtils.isEmpty(double1)) {
102
+            return double1;
103
+        }
104
+        java.text.NumberFormat nf = java.text.NumberFormat.getInstance();
105
+        nf.setGroupingUsed(false);
106
+        try {
107
+            return nf.format(Double.valueOf(double1));
108
+        } catch (Exception e) {
109
+            return double1;
110
+        }
111
+
112
+    }
113
+
114
+    /**
115
+     * 去除科学记数法 2016.3-->2,016.30
116
+     */
117
+    public static String convertDouble(Double double1) {
118
+        DecimalFormat decimalFormat = new DecimalFormat("#,##0.00");//格式化设置
119
+        return decimalFormat.format(double1);
120
+    }
121
+
122
+    /**
123
+     * 对double数据进行取精度.
124
+     *
125
+     * @param value        double数据.
126
+     * @param scale        精度位数(保留的小数位数).
127
+     * @param roundingMode 精度取值方式.
128
+     * @return 精度计算后的数据.
129
+     */
130
+    public static double round(double value, int scale,
131
+                               int roundingMode) {
132
+        BigDecimal bd = new BigDecimal(value);
133
+        bd = bd.setScale(scale, roundingMode);
134
+        return bd.doubleValue();
135
+    }
136
+
137
+    public static double round(double value, int scale) {
138
+        return round(value, scale, BigDecimal.ROUND_HALF_UP);
139
+    }
140
+
141
+    /**
142
+     * double 相加
143
+     *
144
+     * @param d1
145
+     * @param d2
146
+     * @return
147
+     */
148
+    public static double sum(double d1, double d2) {
149
+        BigDecimal bd1 = new BigDecimal(Double.toString(d1));
150
+        BigDecimal bd2 = new BigDecimal(Double.toString(d2));
151
+        return bd1.add(bd2).doubleValue();
152
+    }
153
+
154
+
155
+    /**
156
+     * double 相减
157
+     *
158
+     * @param d1
159
+     * @param d2
160
+     * @return
161
+     */
162
+    public static double sub(double d1, double d2) {
163
+        BigDecimal bd1 = new BigDecimal(Double.toString(d1));
164
+        BigDecimal bd2 = new BigDecimal(Double.toString(d2));
165
+        return bd1.subtract(bd2).doubleValue();
166
+    }
167
+
168
+    /**
169
+     * double 乘法
170
+     *
171
+     * @param d1
172
+     * @param d2
173
+     * @return
174
+     */
175
+    public static double mul(double d1, double d2) {
176
+        BigDecimal bd1 = new BigDecimal(Double.toString(d1));
177
+        BigDecimal bd2 = new BigDecimal(Double.toString(d2));
178
+        return bd1.multiply(bd2).doubleValue();
179
+    }
180
+
181
+    public static String mulToString(double d1, double d2) {
182
+        BigDecimal bd1 = new BigDecimal(Double.toString(d1));
183
+        BigDecimal bd2 = new BigDecimal(Double.toString(d2));
184
+        return convertDouble(bd1.multiply(bd2).toPlainString());
185
+    }
186
+
187
+    /**
188
+     * double 除法
189
+     *
190
+     * @param d1
191
+     * @param d2
192
+     * @param scale 四舍五入 小数点位数
193
+     * @return
194
+     */
195
+    public static double div(double d1, double d2, int scale) {
196
+        //  当然在此之前,你要判断分母是否为0,
197
+        //  为0你可以根据实际需求做相应的处理
198
+
199
+        BigDecimal bd1 = new BigDecimal(Double.toString(d1));
200
+        BigDecimal bd2 = new BigDecimal(Double.toString(d2));
201
+        return bd1.divide
202
+                (bd2, scale, BigDecimal.ROUND_HALF_UP).doubleValue();
203
+    }
204
+}

+ 126 - 0
app/src/main/java/hf/lskj/com/carstockcount/utils/NumberToCN.java

@@ -0,0 +1,126 @@
1
+package hf.lskj.com.carstockcount.utils;
2
+
3
+import android.text.TextUtils;
4
+
5
+import java.math.BigDecimal;
6
+
7
+/**
8
+ * 数字转换为汉语中人民币的大写
9
+ * Created by by on 2017/4/28.
10
+ */
11
+
12
+public class NumberToCN {
13
+
14
+    /**
15
+     * 汉语中数字大写
16
+     */
17
+    private static final String[] CN_UPPER_NUMBER = {"零", "壹", "贰", "叁", "肆",
18
+            "伍", "陆", "柒", "捌", "玖"};
19
+    /**
20
+     * 汉语中货币单位大写,这样的设计类似于占位符
21
+     */
22
+    private static final String[] CN_UPPER_MONETRAY_UNIT = {"分", "角", "元",
23
+            "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟", "兆", "拾",
24
+            "佰", "仟"};
25
+    /**
26
+     * 特殊字符:整
27
+     */
28
+    private static final String CN_FULL = "整";
29
+    /**
30
+     * 特殊字符:负
31
+     */
32
+    private static final String CN_NEGATIVE = "负";
33
+    /**
34
+     * 金额的精度,默认值为2
35
+     */
36
+    private static final int MONEY_PRECISION = 2;
37
+    /**
38
+     * 特殊字符:零元整
39
+     */
40
+    private static final String CN_ZEOR_FULL = "零元" + CN_FULL;
41
+
42
+    /**
43
+     * 把输入的金额转换为汉语中人民币的大写
44
+     *
45
+     * @param numberOfMoney 输入的金额
46
+     * @return 对应的汉语大写
47
+     */
48
+    public static String number2CNMontrayUnit(BigDecimal numberOfMoney) {
49
+        StringBuffer sb = new StringBuffer();
50
+        // -1, 0, or 1 as the value of this BigDecimal is negative, zero, or
51
+        // positive.
52
+        int signum = numberOfMoney.signum();
53
+        // 零元整的情况
54
+        if (signum == 0) {
55
+            return CN_ZEOR_FULL;
56
+        }
57
+        //这里会进行金额的四舍五入
58
+        long number = numberOfMoney.movePointRight(MONEY_PRECISION)
59
+                .setScale(0, 4).abs().longValue();
60
+        // 得到小数点后两位值
61
+        long scale = number % 100;
62
+        int numUnit = 0;
63
+        int numIndex = 0;
64
+        boolean getZero = false;
65
+        // 判断最后两位数,一共有四中情况:00 = 0, 01 = 1, 10, 11
66
+        if (!(scale > 0)) {
67
+            numIndex = 2;
68
+            number = number / 100;
69
+            getZero = true;
70
+        }
71
+        if ((scale > 0) && (!(scale % 10 > 0))) {
72
+            numIndex = 1;
73
+            number = number / 10;
74
+            getZero = true;
75
+        }
76
+        int zeroSize = 0;
77
+        while (true) {
78
+            if (number <= 0) {
79
+                break;
80
+            }
81
+            // 每次获取到最后一个数
82
+            numUnit = (int) (number % 10);
83
+            if (numUnit > 0) {
84
+                if ((numIndex == 9) && (zeroSize >= 3)) {
85
+                    sb.insert(0, CN_UPPER_MONETRAY_UNIT[6]);
86
+                }
87
+                if ((numIndex == 13) && (zeroSize >= 3)) {
88
+                    sb.insert(0, CN_UPPER_MONETRAY_UNIT[10]);
89
+                }
90
+                sb.insert(0, CN_UPPER_MONETRAY_UNIT[numIndex]);
91
+                sb.insert(0, CN_UPPER_NUMBER[numUnit]);
92
+                getZero = false;
93
+                zeroSize = 0;
94
+            } else {
95
+                ++zeroSize;
96
+                if (!(getZero)) {
97
+                    sb.insert(0, CN_UPPER_NUMBER[numUnit]);
98
+                }
99
+                if (numIndex == 2) {
100
+                    if (number > 0) {
101
+                        sb.insert(0, CN_UPPER_MONETRAY_UNIT[numIndex]);
102
+                    }
103
+                } else if (((numIndex - 2) % 4 == 0) && (number % 1000 > 0)) {
104
+                    sb.insert(0, CN_UPPER_MONETRAY_UNIT[numIndex]);
105
+                }
106
+                getZero = true;
107
+            }
108
+            // 让number每次都去掉最后一个数
109
+            number = number / 10;
110
+            ++numIndex;
111
+        }
112
+        // 如果signum == -1,则说明输入的数字为负数,就在最前面追加特殊字符:负
113
+        if (signum == -1) {
114
+            sb.insert(0, CN_NEGATIVE);
115
+        }
116
+        // 输入的数字小数点后两位为"00"的情况,则要在最后追加特殊字符:整
117
+        if (!(scale > 0)) {
118
+            sb.append(CN_FULL);
119
+        }
120
+        return sb.toString();
121
+    }
122
+
123
+    public static String number2CNMontrayUnit(int num) {
124
+        return number2CNMontrayUnit(new BigDecimal(num));
125
+    }
126
+}

+ 84 - 0
app/src/main/java/hf/lskj/com/carstockcount/utils/PreferencesUtils.java

@@ -0,0 +1,84 @@
1
+package hf.lskj.com.carstockcount.utils;
2
+
3
+import android.content.Context;
4
+import android.content.SharedPreferences;
5
+
6
+import java.util.ArrayList;
7
+import java.util.List;
8
+
9
+/**
10
+ * Created on 2016/8/2.
11
+ * Author:crs
12
+ * Description:首选项工具类
13
+ */
14
+public class PreferencesUtils {
15
+    //存储数据需要editor对象,取数据直接首选项对象就好了。
16
+    private static final String SHARE_PREFER_NAME = "config";
17
+    private static SharedPreferences mSharedPreferences;
18
+
19
+
20
+    //-----------------------------put开始-------------------------
21
+    public static void putBoolean(Context context, String key, boolean value) {
22
+        putBoolean(context, key, value, SHARE_PREFER_NAME);
23
+    }
24
+
25
+    private static void putBoolean(Context context, String key, boolean value, String fileName) {
26
+        if (mSharedPreferences == null) {
27
+            //私有模式
28
+            mSharedPreferences = context.getSharedPreferences(fileName, Context.MODE_PRIVATE);
29
+        }
30
+        SharedPreferences.Editor editor = mSharedPreferences.edit();
31
+        editor.putBoolean(key, value);
32
+        editor.apply();
33
+    }
34
+
35
+    public static void putString(Context context, String key, String value) {
36
+        putString(context, key, value, SHARE_PREFER_NAME);
37
+    }
38
+
39
+    private static void putString(Context context, String key, String value, String fileName) {
40
+            mSharedPreferences = context.getSharedPreferences(fileName, Context.MODE_PRIVATE);
41
+        SharedPreferences.Editor edit = mSharedPreferences.edit();
42
+        edit.putString(key, value);
43
+        edit.apply();
44
+    }
45
+
46
+    //-----------------------------以下是Get--------------------
47
+    public static boolean getBoolean(Context context, String key, boolean defaultValue) {
48
+        return getBoolean(context, key, defaultValue, SHARE_PREFER_NAME);
49
+    }
50
+
51
+    private static boolean getBoolean(Context context, String key, boolean defaultValue, String fileName) {
52
+        if (mSharedPreferences == null) {
53
+            mSharedPreferences = context.getSharedPreferences(fileName, Context.MODE_PRIVATE);
54
+        }
55
+        //如果获取不到就显示默认值
56
+        return mSharedPreferences.getBoolean(key, defaultValue);
57
+    }
58
+
59
+    public static String getString(Context context, String key) {
60
+        return getString(context, key, "");
61
+    }
62
+
63
+    public static String getString(Context context, String key, String defaultValue) {
64
+        return getString(context, key, defaultValue, SHARE_PREFER_NAME);
65
+    }
66
+
67
+    private static String getString(Context context, String key, String defaultValue, String fileName) {
68
+        if (mSharedPreferences == null) {
69
+            mSharedPreferences = context.getSharedPreferences(fileName, Context.MODE_PRIVATE);
70
+        }
71
+        //如果获取不到就显示默认值
72
+        return mSharedPreferences.getString(key, defaultValue);
73
+    }
74
+
75
+    public static void clearDefault(Context context) {
76
+        if (mSharedPreferences == null) {
77
+            mSharedPreferences = context.getSharedPreferences(SHARE_PREFER_NAME, Context.MODE_PRIVATE);
78
+        }
79
+        final SharedPreferences.Editor editor = mSharedPreferences.edit();
80
+        editor.clear();
81
+        editor.apply();
82
+    }
83
+
84
+}

+ 43 - 0
app/src/main/java/hf/lskj/com/carstockcount/utils/SDCardUtils.java

@@ -0,0 +1,43 @@
1
+package hf.lskj.com.carstockcount.utils;
2
+
3
+import android.os.Environment;
4
+import android.os.StatFs;
5
+
6
+import java.io.File;
7
+
8
+/**
9
+ * Created on 2016/8/15.
10
+ * Author:crs
11
+ * Description:sd卡工具类
12
+ */
13
+public class SDCardUtils {
14
+
15
+    //判断sd卡是否可用
16
+    public static boolean isSDCardEnable() {
17
+        return Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
18
+    }
19
+
20
+    //获取sd卡路径
21
+    public static String getSDCardPath() {
22
+        File file = Environment.getExternalStorageDirectory();
23
+        String path = file.getAbsolutePath() + File.separator;
24
+        return path;
25
+    }
26
+
27
+    //获取系统存储路径
28
+    public static String getRootDirectoryPath() {
29
+        File rootDirectory = Environment.getRootDirectory();
30
+        String path = rootDirectory.getAbsolutePath();
31
+        return path;
32
+    }
33
+
34
+    //获取sd卡的剩余存储空间  单位byte
35
+    public static long getSDCardAllSize() {
36
+        StatFs statFs = new StatFs(getSDCardPath());
37
+        //获取空闲的数据块的数量
38
+        long availableBlocksLong = statFs.getAvailableBlocks();
39
+        //获取单个数据块的大小
40
+        long blockSize = statFs.getBlockSize();
41
+        return availableBlocksLong * blockSize;
42
+    }
43
+}

+ 78 - 0
app/src/main/java/hf/lskj/com/carstockcount/utils/ScreenUtils.java

@@ -0,0 +1,78 @@
1
+package hf.lskj.com.carstockcount.utils;
2
+
3
+import android.app.Activity;
4
+import android.app.ActivityManager;
5
+import android.content.Context;
6
+import android.content.IntentFilter;
7
+import android.content.pm.ApplicationInfo;
8
+import android.content.pm.PackageInfo;
9
+import android.content.pm.PackageManager;
10
+import android.content.res.Resources;
11
+import android.graphics.Bitmap;
12
+import android.net.ConnectivityManager;
13
+import android.net.NetworkInfo;
14
+import android.os.Build;
15
+import android.os.Environment;
16
+import android.telephony.TelephonyManager;
17
+import android.util.DisplayMetrics;
18
+import android.view.Display;
19
+import android.view.View;
20
+import android.view.Window;
21
+import android.view.WindowManager;
22
+import android.widget.RelativeLayout;
23
+
24
+/**
25
+ * Created on 2016/8/1.
26
+ * Author:crs
27
+ * Description:屏幕工具类
28
+ */
29
+public class ScreenUtils {
30
+    //获取屏幕的宽度
31
+    public static int getScreenWidth(Context context) {
32
+        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
33
+        Display defaultDisplay = wm.getDefaultDisplay();
34
+        int width = defaultDisplay.getWidth();
35
+        return width;
36
+    }
37
+
38
+    //获取屏幕的高度
39
+    public static int getScreenHeight(Context context) {
40
+        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
41
+        Display defaultDisplay = wm.getDefaultDisplay();
42
+        int height = defaultDisplay.getHeight();
43
+
44
+        return height;
45
+    }
46
+
47
+    //获取状态栏的高度
48
+    public static int getStatusHeight(Context context) {
49
+        int statusHeight = -1;
50
+        //使用反射,可能会出现类找不到的异常ClassNotFoundException
51
+        try {
52
+            Class<?> clazz = Class.forName("com.android.internal.R$dimen");
53
+            Object object = clazz.newInstance();
54
+            String status_bar_height = clazz.getField("status_bar_height").get(object).toString();
55
+            int height = Integer.parseInt(status_bar_height);
56
+            //转化成px返回
57
+            statusHeight = context.getResources().getDimensionPixelSize(height);
58
+        } catch (Exception e) {
59
+            e.printStackTrace();
60
+        }
61
+        return statusHeight;
62
+    }
63
+
64
+    //获取当前屏幕截图,包括状态栏
65
+    public static Bitmap getSnapshot(Activity activity) {
66
+        Window window = activity.getWindow();
67
+        View view = window.getDecorView();
68
+        view.setDrawingCacheEnabled(true);
69
+        view.buildDrawingCache();
70
+        Bitmap bitmap = view.getDrawingCache();
71
+        int screenWidth = getScreenWidth(activity);
72
+        int screenHeight = getScreenHeight(activity);
73
+        Bitmap bp;
74
+        bp = Bitmap.createBitmap(bitmap, 0, 0, screenWidth, screenHeight);
75
+        view.destroyDrawingCache();
76
+        return bp;
77
+    }
78
+}

+ 596 - 0
app/src/main/java/hf/lskj/com/carstockcount/utils/StringUtils.java

@@ -0,0 +1,596 @@
1
+package hf.lskj.com.carstockcount.utils;
2
+
3
+import java.io.BufferedReader;
4
+import java.io.IOException;
5
+import java.io.InputStream;
6
+import java.io.InputStreamReader;
7
+import java.sql.Timestamp;
8
+import java.text.ParseException;
9
+import java.text.SimpleDateFormat;
10
+import java.util.Calendar;
11
+import java.util.Date;
12
+import java.util.Locale;
13
+import java.util.TimeZone;
14
+import java.util.regex.Matcher;
15
+import java.util.regex.Pattern;
16
+
17
+/**
18
+ * 字符串操作工具包
19
+ *
20
+ * @author liux (http://my.oschina.net/liux)
21
+ * @version 1.0
22
+ * @created 2012-3-21
23
+ */
24
+public class StringUtils {
25
+    private final static Pattern emailer = Pattern
26
+            .compile("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
27
+
28
+    private final static Pattern IMG_URL = Pattern
29
+            .compile(".*?(gif|jpeg|png|jpg|bmp)");
30
+
31
+    private final static Pattern URL = Pattern
32
+            .compile("^(https|http)://.*?$(net|com|.com.cn|org|me|)");
33
+
34
+    private final static ThreadLocal<SimpleDateFormat> dateFormater = new ThreadLocal<SimpleDateFormat>() {
35
+        @Override
36
+        protected SimpleDateFormat initialValue() {
37
+            return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
38
+        }
39
+    };
40
+
41
+    public static boolean isBlank(String str) {
42
+        return (str == null || str.trim().length() == 0);
43
+    }
44
+
45
+    private final static ThreadLocal<SimpleDateFormat> dateFormater2 = new ThreadLocal<SimpleDateFormat>() {
46
+        @Override
47
+        protected SimpleDateFormat initialValue() {
48
+            return new SimpleDateFormat("yyyy-MM-dd");
49
+        }
50
+    };
51
+
52
+    /**
53
+     * 将字符串转位日期类型
54
+     *
55
+     * @param sdate
56
+     * @return
57
+     */
58
+    public static Date toDate(String sdate) {
59
+        return toDate(sdate, dateFormater.get());
60
+    }
61
+
62
+    public static Date toDate(String sdate, SimpleDateFormat dateFormater) {
63
+        try {
64
+            return dateFormater.parse(sdate);
65
+        } catch (ParseException e) {
66
+            return null;
67
+        }
68
+    }
69
+
70
+    public static String getDateString(Date date) {
71
+        return dateFormater.get().format(date);
72
+    }
73
+
74
+    //时间戳转字符串
75
+    public static String getStrTime(String timeStamp) {
76
+        String timeString = null;
77
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
78
+        long l = Long.parseLong(timeStamp);
79
+        timeString = sdf.format(new Date(l * 1000));//单位秒
80
+        return timeString;
81
+    }
82
+
83
+    //时间戳转字符串
84
+    public static String getStrTime2(String timeStamp) {
85
+        String timeString = null;
86
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
87
+        long l = Long.parseLong(timeStamp);
88
+        timeString = sdf.format(new Date(l * 1000));//单位秒
89
+        return timeString;
90
+    }
91
+
92
+    //时间戳转字符串
93
+    public static String getStrTime3(String timeStamp) {
94
+        String timeString = null;
95
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
96
+        long l = Long.parseLong(timeStamp);
97
+        timeString = sdf.format(new Date(l * 1000));//单位秒
98
+        return timeString;
99
+    }
100
+
101
+    /**
102
+     * 以友好的方式显示时间
103
+     *
104
+     * @param sdate
105
+     * @return
106
+     */
107
+    public static String friendly_time(String sdate) {
108
+        Date time = null;
109
+
110
+        if (TimeZoneUtil.isInEasternEightZones())
111
+            time = toDate(sdate);
112
+        else
113
+            time = TimeZoneUtil.transformTime(toDate(sdate),
114
+                    TimeZone.getTimeZone("GMT+08"), TimeZone.getDefault());
115
+
116
+        if (time == null) {
117
+            return "Unknown";
118
+        }
119
+        String ftime = "";
120
+        Calendar cal = Calendar.getInstance();
121
+
122
+        // 判断是否是同一天
123
+        String curDate = dateFormater2.get().format(cal.getTime());
124
+        String paramDate = dateFormater2.get().format(time);
125
+        if (curDate.equals(paramDate)) {
126
+            int hour = (int) ((cal.getTimeInMillis() - time.getTime()) / 3600000);
127
+            if (hour == 0)
128
+                ftime = Math.max(
129
+                        (cal.getTimeInMillis() - time.getTime()) / 60000, 1)
130
+                        + "分钟前";
131
+            else
132
+                ftime = hour + "小时前";
133
+            return ftime;
134
+        }
135
+
136
+        long lt = time.getTime() / 86400000;
137
+        long ct = cal.getTimeInMillis() / 86400000;
138
+        int days = (int) (ct - lt);
139
+        if (days == 0) {
140
+            int hour = (int) ((cal.getTimeInMillis() - time.getTime()) / 3600000);
141
+            if (hour == 0)
142
+                ftime = Math.max(
143
+                        (cal.getTimeInMillis() - time.getTime()) / 60000, 1)
144
+                        + "分钟前";
145
+            else
146
+                ftime = hour + "小时前";
147
+        } else if (days == 1) {
148
+            ftime = "昨天";
149
+        } else if (days == 2) {
150
+            ftime = "前天 ";
151
+        } else if (days > 2 && days < 31) {
152
+            ftime = days + "天前";
153
+        } else if (days >= 31 && days <= 2 * 31) {
154
+            ftime = "一个月前";
155
+        } else if (days > 2 * 31 && days <= 3 * 31) {
156
+            ftime = "2个月前";
157
+        } else if (days > 3 * 31 && days <= 4 * 31) {
158
+            ftime = "3个月前";
159
+        } else {
160
+            ftime = dateFormater2.get().format(time);
161
+        }
162
+        return ftime;
163
+    }
164
+
165
+    public static String friendly_time2(String sdate) {
166
+        String res = "";
167
+        if (isEmpty(sdate))
168
+            return "";
169
+
170
+        String[] weekDays = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
171
+        String currentData = StringUtils.getDataTime("MM-dd");
172
+        int currentDay = toInt(currentData.substring(3));
173
+        int currentMoth = toInt(currentData.substring(0, 2));
174
+
175
+        int sMoth = toInt(sdate.substring(5, 7));
176
+        int sDay = toInt(sdate.substring(8, 10));
177
+        int sYear = toInt(sdate.substring(0, 4));
178
+        Date dt = new Date(sYear, sMoth - 1, sDay - 1);
179
+
180
+        if (sDay == currentDay && sMoth == currentMoth) {
181
+            res = "今天 / " + weekDays[getWeekOfDate(new Date())];
182
+        } else if (sDay == currentDay + 1 && sMoth == currentMoth) {
183
+            res = "昨天 / " + weekDays[(getWeekOfDate(new Date()) + 6) % 7];
184
+        } else {
185
+            if (sMoth < 10) {
186
+                res = "0";
187
+            }
188
+            res += sMoth + "/";
189
+            if (sDay < 10) {
190
+                res += "0";
191
+            }
192
+            res += sDay + " / " + weekDays[getWeekOfDate(dt)];
193
+        }
194
+
195
+        return res;
196
+    }
197
+
198
+    //获取系统当前时间戳,返回000000000秒
199
+    public static long getTimeStamp() {
200
+        Timestamp now = new Timestamp(System.currentTimeMillis());
201
+        return now.getTime() / 1000;
202
+    }
203
+
204
+    //将时间戳专为日期
205
+    public static String compareDate(long a) {
206
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
207
+        String date = sdf.format(new Date(a * 1000));
208
+        return date;
209
+    }
210
+
211
+    //将时间戳专为日期
212
+    public static String compareDate2(long a) {
213
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
214
+        String date = sdf.format(new Date(a * 1000));
215
+        return date;
216
+    }
217
+
218
+    /**
219
+     * 掉此方法输入所要转换的时间输入例如("2014-06-14 16:09:00")返回时间戳
220
+     *
221
+     * @param time
222
+     * @return
223
+     */
224
+    public static String dataOne(String time) {
225
+        SimpleDateFormat sdr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss",
226
+                Locale.CHINA);
227
+        Date date;
228
+        String times = null;
229
+        try {
230
+            date = sdr.parse(time);
231
+            long l = date.getTime();
232
+            String stf = String.valueOf(l);
233
+            times = stf.substring(0, 10);
234
+//            Log.d("--444444---", times);
235
+        } catch (ParseException e) {
236
+            e.printStackTrace();
237
+        }
238
+        return times;
239
+    }
240
+
241
+    //时间差
242
+    public static String getTimeDifference(String time) {
243
+        if (!StringUtils.isEmpty(time)) {
244
+            long l = (long) Integer.parseInt(time);//传入的时间
245
+            long timeStamp = getTimeStamp();//系统时间
246
+            timeStamp = timeStamp - l;
247
+            long timeResult = timeStamp / 60 / 60;
248
+            if (timeResult > 0 && timeResult < 24) {
249
+                return timeResult + "小时前";
250
+            } else if (timeResult > 24) {
251
+                if (timeResult / 24 < 7)
252
+                    return compareDate(l);
253
+                else
254
+                    return timeResult / 24 + "天前";
255
+            } else if (timeResult < 24) {
256
+                if (timeStamp / 60 > 0) {
257
+                    return timeStamp / 60 + "分钟前";
258
+                } else {
259
+                    return "刚刚";
260
+                }
261
+            }
262
+        }
263
+        return null;
264
+    }
265
+
266
+    /**
267
+     * 获取当前日期是星期几<br>
268
+     *
269
+     * @param dt
270
+     * @return 当前日期是星期几
271
+     */
272
+    public static int getWeekOfDate(Date dt) {
273
+        Calendar cal = Calendar.getInstance();
274
+        cal.setTime(dt);
275
+        int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
276
+        if (w < 0)
277
+            w = 0;
278
+        return w;
279
+    }
280
+
281
+    /**
282
+     * 判断给定字符串时间是否为今日
283
+     *
284
+     * @param sdate
285
+     * @return boolean
286
+     */
287
+    public static boolean isToday(String sdate) {
288
+        boolean b = false;
289
+        Date time = toDate(sdate);
290
+        Date today = new Date();
291
+        if (time != null) {
292
+            String nowDate = dateFormater2.get().format(today);
293
+            String timeDate = dateFormater2.get().format(time);
294
+            if (nowDate.equals(timeDate)) {
295
+                b = true;
296
+            }
297
+        }
298
+        return b;
299
+    }
300
+
301
+    /**
302
+     * 返回long类型的今天的日期
303
+     *
304
+     * @return
305
+     */
306
+    public static long getToday() {
307
+        Calendar cal = Calendar.getInstance();
308
+        String curDate = dateFormater2.get().format(cal.getTime());
309
+        curDate = curDate.replace("-", "");
310
+        return Long.parseLong(curDate);
311
+    }
312
+
313
+    public static String getCurTimeStr() {
314
+        Calendar cal = Calendar.getInstance();
315
+        String curDate = dateFormater.get().format(cal.getTime());
316
+        return curDate;
317
+    }
318
+
319
+    /***
320
+     * 计算两个时间差,返回的是的秒s
321
+     *
322
+     * @author 火蚁 2015-2-9 下午4:50:06
323
+     *
324
+     * @return long
325
+     * @param dete1
326
+     * @param date2
327
+     * @return
328
+     */
329
+    public static long calDateDifferent(String dete1, String date2) {
330
+
331
+        long diff = 0;
332
+
333
+        Date d1 = null;
334
+        Date d2 = null;
335
+
336
+        try {
337
+            d1 = dateFormater.get().parse(dete1);
338
+            d2 = dateFormater.get().parse(date2);
339
+
340
+            // 毫秒ms
341
+            diff = d2.getTime() - d1.getTime();
342
+
343
+        } catch (Exception e) {
344
+            e.printStackTrace();
345
+        }
346
+
347
+        return diff / 1000;
348
+    }
349
+
350
+    /**
351
+     * 判断给定字符串是否空白串。 空白串是指由空格、制表符、回车符、换行符组成的字符串 若输入字符串为null或空字符串,返回true
352
+     *
353
+     * @param input
354
+     * @return boolean
355
+     */
356
+    public static boolean isEmpty(String input) {
357
+        if (input == null || "".equals(input) || input.equals("null"))
358
+            return true;
359
+
360
+        for (int i = 0; i < input.length(); i++) {
361
+            char c = input.charAt(i);
362
+            if (c != ' ' && c != '\t' && c != '\r' && c != '\n') {
363
+                return false;
364
+            }
365
+        }
366
+        return true;
367
+    }
368
+
369
+    /**
370
+     * 判断是不是一个合法的电子邮件地址
371
+     *
372
+     * @param email
373
+     * @return
374
+     */
375
+    public static boolean isEmail(String email) {
376
+        if (email == null || email.trim().length() == 0)
377
+            return false;
378
+        return emailer.matcher(email).matches();
379
+    }
380
+
381
+    /**
382
+     * 判断一个url是否为图片url
383
+     *
384
+     * @param url
385
+     * @return
386
+     */
387
+    public static boolean isImgUrl(String url) {
388
+        if (url == null || url.trim().length() == 0)
389
+            return false;
390
+        return IMG_URL.matcher(url).matches();
391
+    }
392
+
393
+    /**
394
+     * 判断是否为一个合法的url地址
395
+     *
396
+     * @param str
397
+     * @return
398
+     */
399
+    public static boolean isUrl(String str) {
400
+        if (str == null || str.trim().length() == 0)
401
+            return false;
402
+        return URL.matcher(str).matches();
403
+    }
404
+
405
+    /**
406
+     * 字符串转整数
407
+     *
408
+     * @param str
409
+     * @param defValue
410
+     * @return
411
+     */
412
+    public static int toInt(String str, int defValue) {
413
+        try {
414
+            return Integer.parseInt(str);
415
+        } catch (Exception e) {
416
+        }
417
+        return defValue;
418
+    }
419
+
420
+    /**
421
+     * 对象转整数
422
+     *
423
+     * @param obj
424
+     * @return 转换异常返回 0
425
+     */
426
+    public static int toInt(Object obj) {
427
+        if (obj == null)
428
+            return 0;
429
+        return toInt(obj.toString(), 0);
430
+    }
431
+
432
+    /**
433
+     * 对象转整数
434
+     *
435
+     * @param obj
436
+     * @return 转换异常返回 0
437
+     */
438
+    public static long toLong(String obj) {
439
+        try {
440
+            return Long.parseLong(obj);
441
+        } catch (Exception e) {
442
+        }
443
+        return 0;
444
+    }
445
+
446
+    /**
447
+     * 字符串转布尔值
448
+     *
449
+     * @param b
450
+     * @return 转换异常返回 false
451
+     */
452
+    public static boolean toBool(String b) {
453
+        try {
454
+            return Boolean.parseBoolean(b);
455
+        } catch (Exception e) {
456
+        }
457
+        return false;
458
+    }
459
+
460
+    public static String getString(String s) {
461
+        return s == null ? "" : s;
462
+    }
463
+
464
+    /**
465
+     * 将一个InputStream流转换成字符串
466
+     */
467
+    public static String toConvertString(InputStream is) {
468
+        StringBuilder res = new StringBuilder();
469
+        if (null == is) {
470
+            return "";
471
+        }
472
+        InputStreamReader isr = new InputStreamReader(is);
473
+        BufferedReader read = new BufferedReader(isr);
474
+        try {
475
+            String line;
476
+            line = read.readLine();
477
+            while (line != null) {
478
+                res.append(line).append("<br>");
479
+                line = read.readLine();
480
+            }
481
+        } catch (IOException e) {
482
+            e.printStackTrace();
483
+        } finally {
484
+            try {
485
+                isr.close();
486
+                read.close();
487
+                is.close();
488
+            } catch (IOException e) {
489
+            }
490
+        }
491
+        return res.toString();
492
+    }
493
+
494
+    /***
495
+     * 截取字符串
496
+     *
497
+     * @param start
498
+     *            从那里开始,0算起
499
+     * @param num
500
+     *            截取多少个
501
+     * @param str
502
+     *            截取的字符串
503
+     * @return
504
+     */
505
+    public static String getSubString(int start, int num, String str) {
506
+        if (str == null) {
507
+            return "";
508
+        }
509
+        int leng = str.length();
510
+        if (start < 0) {
511
+            start = 0;
512
+        }
513
+        if (start > leng) {
514
+            start = leng;
515
+        }
516
+        if (num < 0) {
517
+            num = 1;
518
+        }
519
+        int end = start + num;
520
+        if (end > leng) {
521
+            end = leng;
522
+        }
523
+        return str.substring(start, end);
524
+    }
525
+
526
+    /**
527
+     * 获取当前时间为每年第几周
528
+     *
529
+     * @return
530
+     */
531
+    public static int getWeekOfYear() {
532
+        return getWeekOfYear(new Date());
533
+    }
534
+
535
+    /**
536
+     * 获取当前时间为每年第几周
537
+     *
538
+     * @param date
539
+     * @return
540
+     */
541
+    public static int getWeekOfYear(Date date) {
542
+        Calendar c = Calendar.getInstance();
543
+        c.setFirstDayOfWeek(Calendar.MONDAY);
544
+        c.setTime(date);
545
+        int week = c.get(Calendar.WEEK_OF_YEAR) - 1;
546
+        week = week == 0 ? 52 : week;
547
+        return week > 0 ? week : 1;
548
+    }
549
+
550
+    public static int[] getCurrentDate() {
551
+        int[] dateBundle = new int[3];
552
+        String[] temp = getDataTime("yyyy-MM-dd").split("-");
553
+
554
+        for (int i = 0; i < 3; i++) {
555
+            try {
556
+                dateBundle[i] = Integer.parseInt(temp[i]);
557
+            } catch (Exception e) {
558
+                dateBundle[i] = 0;
559
+            }
560
+        }
561
+        return dateBundle;
562
+    }
563
+
564
+    /**
565
+     * 返回当前系统时间
566
+     */
567
+    public static String getDataTime(String format) {
568
+        SimpleDateFormat df = new SimpleDateFormat(format);
569
+        return df.format(new Date());
570
+    }
571
+
572
+    /**
573
+     * 是否是手机号
574
+     *
575
+     * @param phoneNumber
576
+     * @return
577
+     */
578
+    public static boolean isPhoneNumberValid(String phoneNumber) {
579
+        boolean isValid = false;
580
+        CharSequence inputStr = phoneNumber;
581
+        //正则表达式
582
+
583
+        String phone = "^1[34578]\\d{9}$";
584
+
585
+
586
+        Pattern pattern = Pattern.compile(phone);
587
+        Matcher matcher = pattern.matcher(inputStr);
588
+
589
+
590
+        if (matcher.matches()) {
591
+            isValid = true;
592
+        }
593
+        return isValid;
594
+    }
595
+
596
+}

+ 36 - 0
app/src/main/java/hf/lskj/com/carstockcount/utils/TimeZoneUtil.java

@@ -0,0 +1,36 @@
1
+package hf.lskj.com.carstockcount.utils;
2
+
3
+import java.util.Date;
4
+import java.util.TimeZone;
5
+
6
+/**
7
+ * @author HuangWenwei
8
+ * 
9
+ * @date 2014年10月9日
10
+ */
11
+public class TimeZoneUtil {
12
+
13
+	/**
14
+	 * 判断用户的设备时区是否为东八区(中国) 2014年7月31日
15
+	 * @return
16
+	 */
17
+	public static boolean isInEasternEightZones() {
18
+		boolean defaultVaule = true;
19
+		defaultVaule = TimeZone.getDefault() == TimeZone.getTimeZone("GMT+08");
20
+		return defaultVaule;
21
+	}
22
+
23
+	/**
24
+	 * 根据不同时区,转换时间 2014年7月31日
25
+	 * @return
26
+	 */
27
+	public static Date transformTime(Date date, TimeZone oldZone, TimeZone newZone) {
28
+		Date finalDate = null;
29
+		if (date != null) {
30
+			int timeOffset = oldZone.getOffset(date.getTime())
31
+					- newZone.getOffset(date.getTime());
32
+			finalDate = new Date(date.getTime() - timeOffset);
33
+		}
34
+		return finalDate;
35
+	}
36
+}

+ 42 - 0
app/src/main/java/hf/lskj/com/carstockcount/utils/ToastUtils.java

@@ -0,0 +1,42 @@
1
+package hf.lskj.com.carstockcount.utils;
2
+
3
+import android.content.Context;
4
+import android.text.TextUtils;
5
+import android.widget.Toast;
6
+
7
+import hf.lskj.com.carstockcount.MyApplication;
8
+
9
+/**
10
+ * Created on 2016/8/1.
11
+ * Author:crs
12
+ * Description:XXX
13
+ */
14
+public class ToastUtils {
15
+    public static void showLong(Context context, String msg) {
16
+        if (TextUtils.isEmpty(msg)){
17
+            return;
18
+        }
19
+        Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
20
+    }
21
+
22
+    public static void showShort(Context context, String msg) {
23
+        if (TextUtils.isEmpty(msg)){
24
+            return;
25
+        }
26
+        Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
27
+    }
28
+
29
+    public static void showLong(String msg) {
30
+        if (TextUtils.isEmpty(msg)){
31
+            return;
32
+        }
33
+        Toast.makeText(MyApplication.getInstances(), msg, Toast.LENGTH_LONG).show();
34
+    }
35
+
36
+    public static void showShort(String msg) {
37
+        if (TextUtils.isEmpty(msg)){
38
+            return;
39
+        }
40
+        Toast.makeText(MyApplication.getInstances(), msg, Toast.LENGTH_SHORT).show();
41
+    }
42
+}

+ 219 - 0
app/src/main/java/hf/lskj/com/carstockcount/utils/UHF/ShellUtils.java

@@ -0,0 +1,219 @@
1
+package hf.lskj.com.carstockcount.utils.UHF;
2
+
3
+import java.io.BufferedReader;
4
+import java.io.DataOutputStream;
5
+import java.io.IOException;
6
+import java.io.InputStreamReader;
7
+import java.util.List;
8
+
9
+/**
10
+ * ShellUtils
11
+ * <ul>
12
+ * <strong>Check root</strong>
13
+ * <li>{@link ShellUtils#checkRootPermission()}</li>
14
+ * </ul>
15
+ * <ul>
16
+ * <strong>Execte command</strong>
17
+ * <li>{@link ShellUtils#execCommand(String, boolean)}</li>
18
+ * <li>{@link ShellUtils#execCommand(String, boolean, boolean)}</li>
19
+ * <li>{@link ShellUtils#execCommand(List, boolean)}</li>
20
+ * <li>{@link ShellUtils#execCommand(List, boolean, boolean)}</li>
21
+ * <li>{@link ShellUtils#execCommand(String[], boolean)}</li>
22
+ * <li>{@link ShellUtils#execCommand(String[], boolean, boolean)}</li>
23
+ * </ul>
24
+ * 
25
+ * @author <a href="http://www.trinea.cn" target="_blank">Trinea</a> 2013-5-16
26
+ */
27
+public class ShellUtils {
28
+
29
+    public static final String COMMAND_SU       = "su";
30
+    public static final String COMMAND_SH       = "sh";
31
+    public static final String COMMAND_EXIT     = "exit\n";
32
+    public static final String COMMAND_LINE_END = "\n";
33
+
34
+    /**
35
+     * check whether has root permission
36
+     * 
37
+     * @return
38
+     */
39
+    public static boolean checkRootPermission() {
40
+        return execCommand("echo root", true, false).result == 0;
41
+    }
42
+
43
+    /**
44
+     * execute shell command, default return result msg
45
+     * 
46
+     * @param command command
47
+     * @param isRoot whether need to run with root
48
+     * @return
49
+     * @see ShellUtils#execCommand(String[], boolean, boolean)
50
+     */
51
+    public static CommandResult execCommand(String command, boolean isRoot) {
52
+        return execCommand(new String[] {command}, isRoot, true);
53
+    }
54
+
55
+    /**
56
+     * execute shell commands, default return result msg
57
+     * 
58
+     * @param commands command list
59
+     * @param isRoot whether need to run with root
60
+     * @return
61
+     * @see ShellUtils#execCommand(String[], boolean, boolean)
62
+     */
63
+    public static CommandResult execCommand(List<String> commands, boolean isRoot) {
64
+        return execCommand(commands == null ? null : commands.toArray(new String[] {}), isRoot, true);
65
+    }
66
+
67
+    /**
68
+     * execute shell commands, default return result msg
69
+     * 
70
+     * @param commands command array
71
+     * @param isRoot whether need to run with root
72
+     * @return
73
+     * @see ShellUtils#execCommand(String[], boolean, boolean)
74
+     */
75
+    public static CommandResult execCommand(String[] commands, boolean isRoot) {
76
+        return execCommand(commands, isRoot, true);
77
+    }
78
+
79
+    /**
80
+     * execute shell command
81
+     * 
82
+     * @param command command
83
+     * @param isRoot whether need to run with root
84
+     * @param isNeedResultMsg whether need result msg
85
+     * @return
86
+     * @see ShellUtils#execCommand(String[], boolean, boolean)
87
+     */
88
+    public static CommandResult execCommand(String command, boolean isRoot, boolean isNeedResultMsg) {
89
+        return execCommand(new String[] {command}, isRoot, isNeedResultMsg);
90
+    }
91
+
92
+    /**
93
+     * execute shell commands
94
+     * 
95
+     * @param commands command list
96
+     * @param isRoot whether need to run with root
97
+     * @param isNeedResultMsg whether need result msg
98
+     * @return
99
+     * @see ShellUtils#execCommand(String[], boolean, boolean)
100
+     */
101
+    public static CommandResult execCommand(List<String> commands, boolean isRoot, boolean isNeedResultMsg) {
102
+        return execCommand(commands == null ? null : commands.toArray(new String[] {}), isRoot, isNeedResultMsg);
103
+    }
104
+
105
+    /**
106
+     * execute shell commands
107
+     * 
108
+     * @param commands command array
109
+     * @param isRoot whether need to run with root
110
+     * @param isNeedResultMsg whether need result msg
111
+     * @return <ul>
112
+     *         <li>if isNeedResultMsg is false, {@link CommandResult#successMsg} is null and
113
+     *         {@link CommandResult#errorMsg} is null.</li>
114
+     *         <li>if {@link CommandResult#result} is -1, there maybe some excepiton.</li>
115
+     *         </ul>
116
+     */
117
+    public static CommandResult execCommand(String[] commands, boolean isRoot, boolean isNeedResultMsg) {
118
+        int result = -1;
119
+        if (commands == null || commands.length == 0) {
120
+            return new CommandResult(result, null, null);
121
+        }
122
+
123
+        Process process = null;
124
+        BufferedReader successResult = null;
125
+        BufferedReader errorResult = null;
126
+        StringBuilder successMsg = null;
127
+        StringBuilder errorMsg = null;
128
+
129
+        DataOutputStream os = null;
130
+        try {
131
+            process = Runtime.getRuntime().exec(isRoot ? COMMAND_SU : COMMAND_SH);
132
+            os = new DataOutputStream(process.getOutputStream());
133
+            for (String command : commands) {
134
+                if (command == null) {
135
+                    continue;
136
+                }
137
+
138
+                // donnot use os.writeBytes(commmand), avoid chinese charset error
139
+                os.write(command.getBytes());
140
+                os.writeBytes(COMMAND_LINE_END);
141
+                os.flush();
142
+            }
143
+            os.writeBytes(COMMAND_EXIT);
144
+            os.flush();
145
+
146
+            result = process.waitFor();
147
+            // get command result
148
+            if (isNeedResultMsg) {
149
+                successMsg = new StringBuilder();
150
+                errorMsg = new StringBuilder();
151
+                successResult = new BufferedReader(new InputStreamReader(process.getInputStream()));
152
+                errorResult = new BufferedReader(new InputStreamReader(process.getErrorStream()));
153
+                String s;
154
+                while ((s = successResult.readLine()) != null) {
155
+                    successMsg.append(s);
156
+                }
157
+                while ((s = errorResult.readLine()) != null) {
158
+                    errorMsg.append(s);
159
+                }
160
+            }
161
+        } catch (IOException e) {
162
+            e.printStackTrace();
163
+        } catch (Exception e) {
164
+            e.printStackTrace();
165
+        } finally {
166
+            try {
167
+                if (os != null) {
168
+                    os.close();
169
+                }
170
+                if (successResult != null) {
171
+                    successResult.close();
172
+                }
173
+                if (errorResult != null) {
174
+                    errorResult.close();
175
+                }
176
+            } catch (IOException e) {
177
+                e.printStackTrace();
178
+            }
179
+
180
+            if (process != null) {
181
+                process.destroy();
182
+            }
183
+        }
184
+        return new CommandResult(result, successMsg == null ? null : successMsg.toString(), errorMsg == null ? null
185
+                : errorMsg.toString());
186
+    }
187
+
188
+    /**
189
+     * result of command
190
+     * <ul>
191
+     * <li>{@link CommandResult#result} means result of command, 0 means normal, else means error, same to excute in
192
+     * linux shell</li>
193
+     * <li>{@link CommandResult#successMsg} means success message of command result</li>
194
+     * <li>{@link CommandResult#errorMsg} means error message of command result</li>
195
+     * </ul>
196
+     * 
197
+     * @author <a href="http://www.trinea.cn" target="_blank">Trinea</a> 2013-5-16
198
+     */
199
+    public static class CommandResult {
200
+
201
+        /** result of command **/
202
+        public int    result;
203
+        /** success message of command result **/
204
+        public String successMsg;
205
+        /** error message of command result **/
206
+        public String errorMsg;
207
+
208
+        public CommandResult(int result) 
209
+        {
210
+            this.result = result;
211
+        }
212
+
213
+        public CommandResult(int result, String successMsg, String errorMsg) {
214
+            this.result = result;
215
+            this.successMsg = successMsg;
216
+            this.errorMsg = errorMsg;
217
+        }
218
+    }
219
+}

+ 56 - 0
app/src/main/java/hf/lskj/com/carstockcount/utils/UHF/Sound.java

@@ -0,0 +1,56 @@
1
+package hf.lskj.com.carstockcount.utils.UHF;
2
+
3
+import android.content.Context;
4
+import android.media.AudioManager;
5
+import android.media.MediaPlayer;
6
+import android.os.Vibrator;
7
+
8
+import hf.lskj.com.carstockcount.R;
9
+
10
+
11
+public class Sound {
12
+
13
+    public int max;
14
+    public int current;
15
+    MediaPlayer player_fail;
16
+    MediaPlayer player_success;
17
+    Vibrator vibrator;
18
+    public static final int MIN_VOLUME = 10;// 最小音量
19
+
20
+    public Sound(Context context) {
21
+        super();
22
+        AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); // 播放提示音
23
+        max = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
24
+        current = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
25
+        if (current < MIN_VOLUME) {
26
+            //判断当前音量,如果当前音量小于配置的音量,则调整当前音量的大小为指定的最小音量
27
+            audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, MIN_VOLUME,
28
+                    AudioManager.FLAG_PLAY_SOUND);
29
+        }
30
+        player_fail = MediaPlayer.create(context, R.raw.error);
31
+        player_fail.setVolume((float) current / (float) max, (float) current / (float) max); // 设置提示音量
32
+        player_success = MediaPlayer.create(context, R.raw.beep);
33
+        player_success.setVolume((float) current / (float) max, (float) current / (float) max); // 设置提示音量
34
+        vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); // 振动100毫秒
35
+
36
+    }
37
+
38
+    /**
39
+     * @param isok 成功还是失败变量
40
+     * @param ms   振动时间变量,单位ms
41
+     */
42
+
43
+    public void callAlarm(Boolean isok, int ms) {
44
+        vibrator.vibrate(ms); // 振动100毫秒
45
+        if (isok) {
46
+            if (!player_success.isPlaying()) {
47
+                player_success.start();
48
+            }
49
+        } else {
50
+            if (!player_fail.isPlaying()) {
51
+                player_fail.start();
52
+            }
53
+        }
54
+
55
+    }
56
+}

+ 48 - 0
app/src/main/java/hf/lskj/com/carstockcount/utils/UHF/UHFClient.java

@@ -0,0 +1,48 @@
1
+package hf.lskj.com.carstockcount.utils.UHF;
2
+
3
+
4
+import jni.Linuxc;
5
+import uhf.api.UHF;
6
+
7
+public class UHFClient {
8
+
9
+    public static UHF mUHF;
10
+    private static UHFClient instance = null;
11
+
12
+
13
+    /**
14
+     * 单子模式,防止重复使用串口
15
+     *
16
+     * @return
17
+     */
18
+    public static UHFClient getInstance() {
19
+        if (instance == null) {
20
+            //mUHF=new UHF("/dev/ttyMT0",Linuxc.BAUD_RATE_115200,1,0);
21
+            //mUHF=new UHF("/dev/ttySAC3",Linuxc.BAUD_RATE_115200,1,0);
22
+            //mUHF=new UHF("/dev/ttyMSM2",Linuxc.BAUD_RATE_115200,1,0);//0 2
23
+            //mUHF=new UHF("/dev/ttyHSL0",Linuxc.BAUD_RATE_115200,1,0);
24
+
25
+            //mUHF=new UHF("/dev/ttyS5",Linuxc.BAUD_RATE_115200,1,0);//0 2
26
+            mUHF = new UHF("/dev/ttyHSL1", Linuxc.BAUD_RATE_115200, 1, 0);
27
+
28
+            mUHF.com_fd = mUHF.transfer_open(mUHF);
29
+            if (mUHF.com_fd > 0) {
30
+                instance = new UHFClient();
31
+            }
32
+        }
33
+        return instance;
34
+    }
35
+
36
+
37
+    public static void Disconnect() {
38
+        if (instance != null) {
39
+            if (mUHF != null) {
40
+                mUHF.transfer_close(mUHF);
41
+                mUHF = null;
42
+            }
43
+            instance = null;
44
+        }
45
+    }
46
+
47
+
48
+}

+ 47 - 0
app/src/main/java/hf/lskj/com/carstockcount/utils/UHF/UHFUtils.java

@@ -0,0 +1,47 @@
1
+package hf.lskj.com.carstockcount.utils.UHF;
2
+
3
+import android.content.Context;
4
+import android.util.Log;
5
+
6
+import uhf.api.CommandType;
7
+import uhf.api.Power;
8
+
9
+/**
10
+ * Created by yaoju on 2017/8/2.
11
+ */
12
+
13
+public class UHFUtils {
14
+    private Context mContext;
15
+    private int count = 0;
16
+
17
+    public UHFUtils(Context context) {
18
+        mContext = context;
19
+        count = 0;
20
+    }
21
+
22
+    public void handleSetPower(int int_power_read_temp) {
23
+        Power mPower = new Power();
24
+        mPower.com_type = CommandType.SET_POWER;
25
+        mPower.loop = 0;
26
+        mPower.read = int_power_read_temp;
27
+        mPower.write = int_power_read_temp;
28
+
29
+        UHFClient info = UHFClient.getInstance();
30
+        if (info != null) {
31
+            Boolean ret = UHFClient.mUHF.command(CommandType.SET_POWER, mPower);
32
+            if (ret) {
33
+                Log.i("rfid", "Set Power " + int_power_read_temp + " Ok");
34
+            } else {
35
+
36
+                if (count < 3) {
37
+                    count++;
38
+                    handleSetPower(int_power_read_temp);
39
+                } else {
40
+                    Log.w("rfid", "Set Power " + int_power_read_temp +" Fail");
41
+                }
42
+            }
43
+        }
44
+
45
+
46
+    }
47
+}

+ 13 - 0
app/src/main/res/drawable/bg_block.xml

@@ -0,0 +1,13 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
3
+    android:shape="rectangle">
4
+    <solid android:color="@color/white" />
5
+    <stroke
6
+        android:width="1dp"
7
+        android:color="@color/line" />
8
+    <padding
9
+        android:bottom="5dp"
10
+        android:left="20dp"
11
+        android:top="5dp"
12
+        android:right="10dp"/>
13
+</shape>

+ 4 - 0
app/src/main/res/drawable/bg_button.xml

@@ -0,0 +1,4 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
3
+    <corners android:radius="2dp"/>
4
+</shape>

+ 6 - 0
app/src/main/res/drawable/guanlian.xml

@@ -0,0 +1,6 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
3
+    <item android:drawable="@mipmap/guanlian_xz"
4
+        android:state_selected="true" />
5
+    <item android:drawable="@mipmap/guanlian" />
6
+</selector>

+ 6 - 0
app/src/main/res/drawable/pandian.xml

@@ -0,0 +1,6 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
3
+    <item android:drawable="@mipmap/pandian_xz"
4
+        android:state_selected="true" />
5
+    <item android:drawable="@mipmap/pandian" />
6
+</selector>

+ 6 - 0
app/src/main/res/drawable/user.xml

@@ -0,0 +1,6 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
3
+    <item android:drawable="@mipmap/user_xz"
4
+        android:state_selected="true" />
5
+    <item android:drawable="@mipmap/user" />
6
+</selector>

+ 67 - 0
app/src/main/res/layout/activity_car_list.xml

@@ -0,0 +1,67 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+    xmlns:app="http://schemas.android.com/apk/res-auto"
4
+    xmlns:tools="http://schemas.android.com/tools"
5
+    android:id="@+id/view_root"
6
+    android:layout_width="match_parent"
7
+    android:layout_height="match_parent"
8
+    android:focusableInTouchMode="true"
9
+    tools:context="hf.lskj.com.carstockcount.activity.CarListActivity">
10
+
11
+    <LinearLayout
12
+        android:id="@+id/layout_above"
13
+        android:layout_width="match_parent"
14
+        android:layout_height="wrap_content"
15
+        android:paddingTop="5dp"
16
+        android:orientation="horizontal">
17
+
18
+        <TextView
19
+            android:id="@+id/tv_total"
20
+            style="@style/ListText"
21
+            android:layout_width="0dp"
22
+            android:layout_height="wrap_content"
23
+            android:layout_weight="1"
24
+            android:gravity="center"
25
+            android:text="库存:23" />
26
+
27
+        <TextView
28
+            android:id="@+id/tv_checked"
29
+            style="@style/ListText"
30
+            android:layout_width="0dp"
31
+            android:layout_height="wrap_content"
32
+            android:layout_weight="1"
33
+            android:gravity="center"
34
+            android:text="已盘点:23" />
35
+
36
+        <TextView
37
+            android:id="@+id/tv_not_checked"
38
+            style="@style/ListText"
39
+            android:layout_width="0dp"
40
+            android:layout_height="wrap_content"
41
+            android:layout_weight="1"
42
+            android:gravity="center"
43
+            android:text="未盘点:23" />
44
+    </LinearLayout>
45
+
46
+    <SearchView
47
+        android:id="@+id/searchView"
48
+        android:layout_width="match_parent"
49
+        android:layout_height="wrap_content"
50
+        android:layout_below="@id/layout_above"
51
+        android:layout_toLeftOf="@+id/spi_status"
52
+        android:iconifiedByDefault="false"
53
+        android:queryHint="按VIN码搜索" />
54
+
55
+    <android.support.v7.widget.AppCompatSpinner
56
+        android:id="@+id/spi_status"
57
+        android:layout_width="wrap_content"
58
+        android:layout_height="wrap_content"
59
+        android:layout_alignParentRight="true"
60
+        android:layout_alignTop="@id/searchView" />
61
+
62
+    <ListView
63
+        android:id="@+id/lv_cars"
64
+        android:layout_width="match_parent"
65
+        android:layout_height="wrap_content"
66
+        android:layout_below="@id/searchView" />
67
+</RelativeLayout>

+ 36 - 0
app/src/main/res/layout/activity_count_list.xml

@@ -0,0 +1,36 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+    xmlns:tools="http://schemas.android.com/tools"
4
+    android:layout_width="match_parent"
5
+    android:layout_height="match_parent"
6
+    android:paddingLeft="3dp"
7
+    android:id="@+id/view_root"
8
+    tools:context="hf.lskj.com.carstockcount.activity.RecordListActivity">
9
+
10
+    <TextView
11
+        android:id="@+id/tv_date"
12
+        style="@style/MainText"
13
+        android:text="2017-7-26"
14
+        android:drawableLeft="@mipmap/calendar"
15
+        android:drawablePadding="10dp"
16
+        android:textSize="16sp" />
17
+    <android.support.v7.widget.AppCompatSpinner
18
+        android:id="@+id/spi_status"
19
+        android:layout_width="wrap_content"
20
+        android:layout_height="wrap_content"
21
+        android:layout_alignParentRight="true" />
22
+    <!--<ImageButton-->
23
+        <!--android:id="@+id/bt_calendar"-->
24
+        <!--android:layout_width="wrap_content"-->
25
+        <!--android:layout_height="wrap_content"-->
26
+        <!--android:layout_alignParentRight="true"-->
27
+        <!--android:layout_alignTop="@id/tv_date"-->
28
+        <!--android:layout_alignBottom="@id/tv_date"-->
29
+        <!--android:src="@mipmap/calendar" />-->
30
+
31
+    <ListView
32
+        android:id="@+id/lv_records"
33
+        android:layout_width="match_parent"
34
+        android:layout_height="wrap_content"
35
+        android:layout_below="@id/tv_date" />
36
+</RelativeLayout>

+ 100 - 0
app/src/main/res/layout/activity_login.xml

@@ -0,0 +1,100 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+    xmlns:tools="http://schemas.android.com/tools"
4
+    android:layout_width="match_parent"
5
+    android:layout_height="match_parent"
6
+    android:paddingLeft="20dp"
7
+    android:paddingRight="20dp"
8
+    tools:mContext="hf.lskj.com.hplk.activity.LoginActivity">
9
+
10
+    <ImageView
11
+        android:id="@+id/iv_logo"
12
+        android:layout_width="wrap_content"
13
+        android:layout_height="wrap_content"
14
+        android:layout_centerHorizontal="true"
15
+        android:layout_marginTop="38.7dp"
16
+        android:src="@mipmap/index_logo" />
17
+
18
+    <LinearLayout
19
+        android:id="@+id/layout_uid"
20
+        android:layout_width="match_parent"
21
+        android:layout_height="44dp"
22
+        android:layout_below="@id/iv_logo"
23
+        android:layout_marginTop="74dp"
24
+        android:background="@android:color/white">
25
+
26
+        <ImageView
27
+            android:layout_width="43.7dp"
28
+            android:layout_height="match_parent"
29
+            android:scaleType="centerInside"
30
+            android:src="@mipmap/login_user" />
31
+
32
+        <EditText
33
+            android:id="@+id/et_uid"
34
+            android:layout_width="0dp"
35
+            android:layout_height="match_parent"
36
+            android:layout_weight="1"
37
+            android:background="@android:color/white"
38
+            android:gravity="center_vertical|left"
39
+            android:hint="登录账号"
40
+            android:inputType="text"
41
+            android:lines="1"
42
+            android:paddingLeft="10dp"
43
+            android:paddingRight="10dp"
44
+            android:singleLine="true"
45
+            android:textSize="@dimen/textX" />
46
+    </LinearLayout>
47
+
48
+    <LinearLayout
49
+        android:id="@+id/layout_password"
50
+        android:layout_width="match_parent"
51
+        android:layout_height="44dp"
52
+        android:layout_below="@id/layout_uid"
53
+        android:layout_marginTop="7dp"
54
+        android:background="@android:color/white">
55
+
56
+        <ImageView
57
+            android:layout_width="43.7dp"
58
+            android:layout_height="match_parent"
59
+            android:background="@android:color/white"
60
+            android:scaleType="centerInside"
61
+            android:src="@mipmap/login_password" />
62
+
63
+        <EditText
64
+            android:id="@+id/et_password"
65
+            android:layout_width="0dp"
66
+            android:layout_height="match_parent"
67
+            android:layout_weight="1"
68
+            android:background="@android:color/white"
69
+            android:gravity="center_vertical|left"
70
+            android:hint="密码"
71
+            android:imeOptions="actionGo"
72
+            android:inputType="textVisiblePassword"
73
+            android:lines="1"
74
+            android:paddingLeft="10dp"
75
+            android:paddingRight="10dp"
76
+            android:singleLine="true"
77
+            android:textSize="@dimen/textX" />
78
+    </LinearLayout>
79
+
80
+    <Button
81
+        android:id="@+id/bt_login"
82
+        android:layout_width="match_parent"
83
+        android:layout_height="44dp"
84
+        android:layout_below="@id/layout_password"
85
+        android:layout_marginTop="7dp"
86
+        android:background="@color/colorPrimary"
87
+        android:text="立即登录"
88
+        android:textColor="@color/white"
89
+        android:textSize="@dimen/textX" />
90
+
91
+    <Button
92
+        android:id="@+id/bt_init"
93
+        android:layout_width="wrap_content"
94
+        android:layout_height="wrap_content"
95
+        android:layout_alignParentBottom="true"
96
+        android:layout_alignParentRight="true"
97
+        android:background="@null"
98
+        android:text="初始化"
99
+        android:textColor="@color/colorPrimary" />
100
+</RelativeLayout>

+ 29 - 0
app/src/main/res/layout/activity_main.xml

@@ -0,0 +1,29 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+    xmlns:tools="http://schemas.android.com/tools"
4
+    xmlns:app="http://schemas.android.com/apk/res-auto"
5
+    android:layout_width="match_parent"
6
+    android:layout_height="match_parent"
7
+    android:orientation="vertical"
8
+    tools:context=".activity.MainActivity">
9
+
10
+    <android.support.v4.view.ViewPager
11
+        android:id="@+id/viewPager"
12
+        android:layout_width="match_parent"
13
+        android:layout_height="0dp"
14
+        android:layout_weight="1"
15
+        android:scrollbars="none">
16
+    </android.support.v4.view.ViewPager>
17
+
18
+    <android.support.design.widget.TabLayout
19
+        android:id="@+id/tabLayout"
20
+        android:layout_width="match_parent"
21
+        android:layout_height="50dp"
22
+        app:tabGravity="fill"
23
+        app:tabIndicatorHeight="0dp"
24
+        app:tabMode="fixed"
25
+        app:tabSelectedTextColor="@color/colorPrimary"
26
+        app:tabTextColor="#838181">
27
+    </android.support.design.widget.TabLayout>
28
+
29
+</LinearLayout>

+ 72 - 0
app/src/main/res/layout/fragment_bind.xml

@@ -0,0 +1,72 @@
1
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2
+    xmlns:tools="http://schemas.android.com/tools"
3
+    android:layout_width="match_parent"
4
+    android:layout_height="match_parent"
5
+    android:padding="10dp"
6
+    tools:context="hf.lskj.com.carstockcount.fragment.BindFragment">
7
+
8
+    <TextView
9
+        android:id="@+id/tv_vin_title"
10
+        style="@style/MainText"
11
+        android:gravity="right|center_vertical"
12
+        android:paddingLeft="15dp"
13
+        android:text="VIN码" />
14
+
15
+    <android.support.v7.widget.AppCompatAutoCompleteTextView
16
+        android:id="@+id/tv_vin"
17
+        style="@style/LineText"
18
+        android:layout_marginLeft="10dp"
19
+        android:layout_toRightOf="@id/tv_vin_title"
20
+        android:hint="模糊检索" />
21
+
22
+    <TextView
23
+        android:id="@+id/tv_rfid_title"
24
+        style="@style/MainText"
25
+        android:layout_alignRight="@id/tv_vin_title"
26
+        android:layout_below="@+id/tv_vin"
27
+        android:gravity="right|center_vertical"
28
+        android:text="标签ID" />
29
+
30
+    <TextView
31
+        android:id="@+id/tv_rfid"
32
+        style="@style/LineText"
33
+        android:textSize="18sp"
34
+        android:layout_alignLeft="@+id/tv_vin"
35
+        android:layout_alignTop="@id/tv_rfid_title" />
36
+
37
+    <LinearLayout
38
+        android:layout_width="match_parent"
39
+        android:layout_height="wrap_content"
40
+        android:layout_alignParentBottom="true">
41
+
42
+        <android.support.v4.widget.Space
43
+            android:layout_width="0dp"
44
+            android:layout_height="match_parent"
45
+            android:layout_weight="2" />
46
+
47
+        <Button
48
+            android:id="@+id/bt_bind"
49
+            style="@style/Button"
50
+            android:layout_marginTop="20dp"
51
+            android:text="扫描绑定" />
52
+
53
+        <android.support.v4.widget.Space
54
+            android:layout_width="0dp"
55
+            android:layout_height="match_parent"
56
+            android:layout_weight="1" />
57
+
58
+        <Button
59
+            android:id="@+id/bt_unbind"
60
+            style="@style/Button"
61
+            android:layout_marginTop="20dp"
62
+            android:background="@color/colorPrimary"
63
+            android:text="扫描解绑" />
64
+
65
+        <android.support.v4.widget.Space
66
+            android:layout_width="0dp"
67
+            android:layout_height="match_parent"
68
+            android:layout_weight="2" />
69
+    </LinearLayout>
70
+
71
+
72
+</RelativeLayout>

+ 103 - 0
app/src/main/res/layout/fragment_me.xml

@@ -0,0 +1,103 @@
1
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2
+    xmlns:tools="http://schemas.android.com/tools"
3
+    android:layout_width="match_parent"
4
+    android:layout_height="match_parent"
5
+    android:orientation="vertical"
6
+    android:paddingBottom="10dp"
7
+    android:paddingTop="10dp"
8
+    tools:context="hf.lskj.com.carstockcount.fragment.MeFragment">
9
+
10
+    <RelativeLayout
11
+        android:id="@+id/layout_user_info"
12
+        android:layout_width="match_parent"
13
+        android:layout_height="wrap_content"
14
+        android:layout_marginBottom="5dp"
15
+        android:background="@drawable/bg_block">
16
+
17
+        <ImageView
18
+            android:id="@+id/iv_user"
19
+            android:layout_width="wrap_content"
20
+            android:layout_height="wrap_content"
21
+            android:layout_centerVertical="true"
22
+            android:layout_marginRight="10dp"
23
+            android:src="@mipmap/user" />
24
+
25
+        <TextView
26
+            android:id="@+id/tv_role"
27
+            style="@style/MainText"
28
+            android:layout_height="30dp"
29
+            android:layout_toRightOf="@+id/iv_user"
30
+            android:text="用户角色" />
31
+
32
+        <TextView
33
+            android:id="@+id/tv_loginName"
34
+            style="@style/MainText"
35
+            android:layout_height="30dp"
36
+            android:layout_alignLeft="@id/tv_role"
37
+            android:layout_below="@id/tv_role"
38
+            android:text="用户名" />
39
+
40
+        <TextView
41
+            android:id="@+id/tv_realName"
42
+            style="@style/MainText"
43
+            android:layout_height="30dp"
44
+            android:layout_alignLeft="@id/tv_role"
45
+            android:layout_below="@id/tv_loginName"
46
+            android:text="用户姓名" />
47
+    </RelativeLayout>
48
+
49
+    <RelativeLayout
50
+        android:id="@+id/layout_count_records"
51
+        android:layout_width="match_parent"
52
+        android:layout_height="wrap_content"
53
+        android:layout_below="@id/layout_user_info"
54
+        android:layout_marginBottom="5dp"
55
+        android:background="@drawable/bg_block">
56
+
57
+        <TextView
58
+            style="@style/MainText"
59
+            android:drawableLeft="@mipmap/pandian"
60
+            android:drawablePadding="10dp"
61
+            android:text="操作记录" />
62
+
63
+        <ImageView
64
+            android:layout_width="wrap_content"
65
+            android:layout_height="wrap_content"
66
+            android:layout_alignParentRight="true"
67
+            android:layout_centerVertical="true"
68
+            android:src="@mipmap/arrow_right" />
69
+    </RelativeLayout>
70
+
71
+    <RelativeLayout
72
+        android:id="@+id/layout_cars"
73
+        android:layout_width="match_parent"
74
+        android:layout_height="wrap_content"
75
+        android:layout_below="@id/layout_count_records"
76
+        android:background="@drawable/bg_block">
77
+
78
+        <TextView
79
+            android:id="@+id/tv_cars_title"
80
+            style="@style/MainText"
81
+            android:drawableLeft="@mipmap/pandian"
82
+            android:drawablePadding="10dp"
83
+            android:text="****店在库车辆" />
84
+
85
+        <ImageView
86
+            android:layout_width="wrap_content"
87
+            android:layout_height="wrap_content"
88
+            android:layout_alignParentRight="true"
89
+            android:layout_centerVertical="true"
90
+            android:src="@mipmap/arrow_right" />
91
+    </RelativeLayout>
92
+
93
+    <Button
94
+        android:id="@+id/bt_exit"
95
+        style="@style/Button"
96
+        android:layout_width="wrap_content"
97
+        android:layout_height="wrap_content"
98
+        android:layout_alignParentBottom="true"
99
+        android:layout_centerHorizontal="true"
100
+        android:background="@color/colorPrimary"
101
+        android:padding="10dp"
102
+        android:text="退出登录" />
103
+</RelativeLayout>

+ 128 - 0
app/src/main/res/layout/fragment_stock_count.xml

@@ -0,0 +1,128 @@
1
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2
+    xmlns:tools="http://schemas.android.com/tools"
3
+    android:layout_width="match_parent"
4
+    android:layout_height="match_parent"
5
+    android:padding="10dp"
6
+    tools:context="hf.lskj.com.carstockcount.fragment.StockCountFragment">
7
+
8
+    <TextView
9
+        android:id="@+id/tv_vin_title"
10
+        style="@style/MainText"
11
+        android:layout_alignRight="@+id/tv_status_title"
12
+        android:text="VIN码:" />
13
+
14
+    <TextView
15
+        android:id="@+id/tv_vin"
16
+        style="@style/MainText"
17
+        android:layout_toRightOf="@id/tv_vin_title"
18
+        android:text="" />
19
+
20
+    <TextView
21
+        android:id="@+id/tv_rfid_title"
22
+        style="@style/MainText"
23
+        android:layout_alignRight="@+id/tv_status_title"
24
+        android:layout_below="@id/tv_vin"
25
+        android:text="标签ID:" />
26
+
27
+    <TextView
28
+        android:id="@+id/tv_rfid"
29
+        style="@style/MainText"
30
+        android:layout_alignLeft="@id/tv_vin"
31
+        android:layout_below="@id/tv_vin"
32
+        android:text="" />
33
+
34
+    <TextView
35
+        android:id="@+id/tv_type_title"
36
+        style="@style/MainText"
37
+        android:layout_alignRight="@+id/tv_status_title"
38
+        android:layout_below="@id/tv_rfid"
39
+        android:text="车型:" />
40
+
41
+    <TextView
42
+        android:id="@+id/tv_type"
43
+        style="@style/MainText"
44
+        android:layout_alignLeft="@id/tv_vin"
45
+        android:layout_below="@id/tv_rfid"
46
+        android:text="" />
47
+
48
+    <TextView
49
+        android:id="@+id/tv_color_title"
50
+        style="@style/MainText"
51
+        android:layout_alignRight="@+id/tv_status_title"
52
+        android:layout_below="@id/tv_type"
53
+        android:text="颜色:" />
54
+
55
+    <TextView
56
+        android:id="@+id/tv_color"
57
+        style="@style/MainText"
58
+        android:layout_alignLeft="@id/tv_vin"
59
+        android:layout_below="@id/tv_type"
60
+        android:text="" />
61
+
62
+    <TextView
63
+        android:id="@+id/tv_status_title"
64
+        style="@style/MainText"
65
+        android:layout_below="@id/tv_color_title"
66
+        android:text="库存状态:" />
67
+
68
+    <TextView
69
+        android:id="@+id/tv_status"
70
+        style="@style/MainText"
71
+        android:layout_alignLeft="@id/tv_vin"
72
+        android:layout_below="@id/tv_color_title"
73
+        android:text="" />
74
+
75
+    <android.support.v7.widget.AppCompatSpinner
76
+        android:id="@+id/spi_status"
77
+        android:layout_width="wrap_content"
78
+        android:layout_height="wrap_content"
79
+        android:layout_alignLeft="@id/tv_vin"
80
+        android:layout_below="@id/tv_color_title"
81
+        android:visibility="gone" />
82
+
83
+    <TextView
84
+        android:id="@+id/tv_time_title"
85
+        style="@style/MainText"
86
+        android:layout_alignRight="@id/tv_status_title"
87
+        android:layout_below="@id/tv_status_title"
88
+        android:text="盘点时间:" />
89
+
90
+    <TextView
91
+        android:id="@+id/tv_time"
92
+        style="@style/MainText"
93
+        android:layout_alignLeft="@id/tv_vin"
94
+        android:layout_below="@id/tv_status_title"
95
+        android:text="" />
96
+
97
+    <!--<TextView-->
98
+        <!--android:id="@+id/tv_remark"-->
99
+        <!--style="@style/MainText"-->
100
+        <!--android:layout_alignRight="@+id/tv_status_title"-->
101
+        <!--android:layout_below="@id/tv_time_title"-->
102
+        <!--android:layout_marginBottom="10dp"-->
103
+        <!--android:text="备注:" />-->
104
+
105
+    <!--<EditText-->
106
+        <!--android:id="@+id/et_remark"-->
107
+        <!--style="@style/LineText"-->
108
+        <!--android:layout_alignLeft="@id/tv_vin"-->
109
+        <!--android:layout_below="@id/tv_time_title"-->
110
+        <!--android:inputType="text" />-->
111
+
112
+    <ToggleButton
113
+        android:id="@+id/bt_scan"
114
+        style="@style/Button"
115
+        android:layout_alignParentBottom="true"
116
+        android:layout_centerHorizontal="true"
117
+        android:textOn="停止盘点"
118
+        android:textOff="开始盘点"/>
119
+
120
+    <Button
121
+        android:id="@+id/bt_save"
122
+        style="@style/Button"
123
+        android:layout_alignParentBottom="true"
124
+        android:layout_centerHorizontal="true"
125
+        android:background="@color/colorPrimary"
126
+        android:text="保存"
127
+        android:visibility="gone" />
128
+</RelativeLayout>

+ 71 - 0
app/src/main/res/layout/item_car.xml

@@ -0,0 +1,71 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+    android:layout_width="match_parent"
4
+    android:layout_height="wrap_content"
5
+    android:orientation="vertical"
6
+    android:paddingBottom="5dp"
7
+    android:paddingLeft="5dp"
8
+    android:paddingTop="10dp">
9
+
10
+    <TextView
11
+        android:id="@+id/tv_status"
12
+        style="@style/ListText"
13
+        android:layout_width="wrap_content"
14
+        android:layout_height="wrap_content"
15
+        android:layout_centerVertical="true"
16
+        android:drawablePadding="5dp"
17
+        android:drawableTop="@mipmap/pandian"
18
+        android:minWidth="32dp"
19
+        android:text="在库" />
20
+
21
+    <TableLayout
22
+        android:layout_width="match_parent"
23
+        android:layout_height="wrap_content"
24
+        android:layout_marginLeft="5dp"
25
+        android:layout_toRightOf="@id/tv_status">
26
+
27
+        <TableRow>
28
+
29
+            <TextView
30
+                android:gravity="right"
31
+                android:text="VIN码:" />
32
+
33
+            <TextView
34
+                android:id="@+id/tv_vin"
35
+                style="@style/ListText"
36
+                android:layout_width="wrap_content"
37
+                android:layout_height="wrap_content"
38
+                android:text="8888888888888" />
39
+        </TableRow>
40
+
41
+        <TableRow>
42
+
43
+            <TextView
44
+                android:gravity="right"
45
+                android:text="标签ID:" />
46
+
47
+            <TextView
48
+                android:id="@+id/tv_rfid"
49
+                style="@style/ListText"
50
+                android:layout_width="wrap_content"
51
+                android:layout_height="wrap_content"
52
+                android:text="E2004125220702781070AB47" />
53
+        </TableRow>
54
+
55
+        <TableRow>
56
+
57
+            <TextView
58
+                android:gravity="right"
59
+                android:text="时间:" />
60
+
61
+            <TextView
62
+                android:id="@+id/tv_time"
63
+                style="@style/ListText"
64
+                android:layout_width="wrap_content"
65
+                android:layout_height="wrap_content"
66
+                android:text="2017-4-21 15:44" />
67
+        </TableRow>
68
+    </TableLayout>
69
+
70
+
71
+</RelativeLayout>

+ 71 - 0
app/src/main/res/layout/item_record.xml

@@ -0,0 +1,71 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+    android:layout_width="match_parent"
4
+    android:layout_height="wrap_content"
5
+    android:orientation="vertical"
6
+    android:paddingBottom="5dp"
7
+    android:paddingTop="10dp">
8
+
9
+    <TextView
10
+        android:id="@+id/tv_status"
11
+        style="@style/MainText"
12
+        android:layout_width="wrap_content"
13
+        android:layout_height="wrap_content"
14
+        android:layout_centerVertical="true"
15
+        android:drawablePadding="5dp"
16
+        android:drawableTop="@mipmap/pandian"
17
+        android:minWidth="32dp"
18
+        android:textSize="14sp"
19
+        android:text="未盘到" />
20
+
21
+    <TableLayout
22
+        android:layout_width="match_parent"
23
+        android:layout_height="wrap_content"
24
+        android:layout_toRightOf="@id/tv_status">
25
+
26
+        <TableRow>
27
+
28
+            <TextView
29
+                android:gravity="right"
30
+                android:text="VIN码:" />
31
+
32
+            <TextView
33
+                android:id="@+id/tv_vin"
34
+                style="@style/ListText"
35
+                android:layout_width="wrap_content"
36
+                android:layout_height="wrap_content"
37
+                android:text="8888888888888" />
38
+        </TableRow>
39
+
40
+        <TableRow>
41
+
42
+            <TextView
43
+                android:gravity="right"
44
+                android:text="标签ID:" />
45
+
46
+            <TextView
47
+                android:id="@+id/tv_rfid"
48
+                style="@style/ListText"
49
+                android:layout_width="wrap_content"
50
+                android:layout_height="wrap_content"
51
+                android:text="E2004125220702781070AB47" />
52
+        </TableRow>
53
+
54
+        <TableRow>
55
+
56
+            <TextView
57
+                android:id="@+id/tv_time_title"
58
+                android:gravity="right"
59
+                android:text="时间:" />
60
+
61
+            <TextView
62
+                android:id="@+id/tv_time"
63
+                style="@style/ListText"
64
+                android:layout_width="wrap_content"
65
+                android:layout_height="wrap_content"
66
+                android:text="2017-4-21 15:44" />
67
+        </TableRow>
68
+    </TableLayout>
69
+
70
+
71
+</RelativeLayout>

+ 9 - 0
app/src/main/res/menu/car_list.xml

@@ -0,0 +1,9 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
3
+    xmlns:app="http://schemas.android.com/apk/res-auto">
4
+    <item
5
+        android:id="@+id/input"
6
+        android:showAsAction="always"
7
+        android:title="导入"
8
+        app:showAsAction="always" />
9
+</menu>

BIN
app/src/main/res/mipmap-hdpi/arrow_right.png


BIN
app/src/main/res/mipmap-hdpi/calendar.png


BIN
app/src/main/res/mipmap-hdpi/chuku_icon.png


BIN
app/src/main/res/mipmap-hdpi/guanlian.png


BIN
app/src/main/res/mipmap-hdpi/guanlian_xz.png


BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png


BIN
app/src/main/res/mipmap-hdpi/pandian.png


BIN
app/src/main/res/mipmap-hdpi/pandian_xz.png


BIN
app/src/main/res/mipmap-hdpi/search_clear.png


BIN
app/src/main/res/mipmap-hdpi/user.png


BIN
app/src/main/res/mipmap-hdpi/user_xz.png


BIN
app/src/main/res/mipmap-hdpi/yidong_icon.png


BIN
app/src/main/res/mipmap-hdpi/zaiku_icon.png


BIN
app/src/main/res/mipmap-mdpi/index_logo.png


BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png


BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png


+ 0 - 0
app/src/main/res/mipmap-xxhdpi/login_password.png


Some files were not shown because too many files changed in this diff