Browse Source

重新对接和修改护士手表逻辑

wangjk 4 năm trước cách đây
mục cha
commit
e73f756630
100 tập tin đã thay đổi với 8958 bổ sung0 xóa
  1. 10 0
      .gitignore
  2. BIN
      .idea/caches/build_file_checksums.ser
  3. BIN
      .idea/caches/gradle_models.ser
  4. 4 0
      .idea/encodings.xml
  5. 21 0
      .idea/gradle.xml
  6. 9 0
      .idea/misc.xml
  7. 12 0
      .idea/runConfigurations.xml
  8. 6 0
      .idea/vcs.xml
  9. 1 0
      app/.gitignore
  10. 80 0
      app/build.gradle
  11. BIN
      app/keystore/keystore.jks
  12. 21 0
      app/proguard-rules.pro
  13. BIN
      app/release/Nurse_Watch_V1.0_20191012.apk
  14. BIN
      app/release/Nurse_Watch_V2.0_20191113_t3.apk
  15. BIN
      app/release/Nurse_Watch_V2.0_20191210.apk
  16. 1 0
      app/release/output.json
  17. 125 0
      app/src/main/AndroidManifest.xml
  18. 13 0
      app/src/main/aidl/com/wdkl/nursewatch/KeepAliveConnection.aidl
  19. 85 0
      app/src/main/java/com/wdkl/nursewatch/MyApplication.java
  20. 75 0
      app/src/main/java/com/wdkl/nursewatch/adapters/HistoryCallAdapter.java
  21. 83 0
      app/src/main/java/com/wdkl/nursewatch/adapters/HistoryCallAdapterPhone.java
  22. 40 0
      app/src/main/java/com/wdkl/nursewatch/adapters/MainViewAdapter.java
  23. 26 0
      app/src/main/java/com/wdkl/nursewatch/broadcast/BatteryBroadcastReceiver.java
  24. 70 0
      app/src/main/java/com/wdkl/nursewatch/common/Constants.java
  25. 43 0
      app/src/main/java/com/wdkl/nursewatch/entity/BluetoothDataEntity.java
  26. 31 0
      app/src/main/java/com/wdkl/nursewatch/entity/HistoryCallEntity.java
  27. 334 0
      app/src/main/java/com/wdkl/nursewatch/entity/MessageEntity.java
  28. 27 0
      app/src/main/java/com/wdkl/nursewatch/entity/MessageEvent.java
  29. 81 0
      app/src/main/java/com/wdkl/nursewatch/entity/WebsocketEntity.java
  30. 42 0
      app/src/main/java/com/wdkl/nursewatch/entity/WebsocketEntityReal.java
  31. 421 0
      app/src/main/java/com/wdkl/nursewatch/presentation/ui/activities/HomeActivity.java
  32. 287 0
      app/src/main/java/com/wdkl/nursewatch/presentation/ui/activities/LoginActivity.java
  33. 310 0
      app/src/main/java/com/wdkl/nursewatch/presentation/ui/activities/MainActivity.java
  34. 223 0
      app/src/main/java/com/wdkl/nursewatch/presentation/ui/activities/VoiceMessageActivity.java
  35. 90 0
      app/src/main/java/com/wdkl/nursewatch/presentation/ui/activities/WelcomeActivity.java
  36. 273 0
      app/src/main/java/com/wdkl/nursewatch/presentation/ui/activitiesphone/LoginActivityPhone.java
  37. 332 0
      app/src/main/java/com/wdkl/nursewatch/presentation/ui/activitiesphone/MainActivityPhone.java
  38. 202 0
      app/src/main/java/com/wdkl/nursewatch/presentation/ui/activitiesphone/SettingActivityPhone.java
  39. 214 0
      app/src/main/java/com/wdkl/nursewatch/presentation/ui/base/BaseActivity.java
  40. 137 0
      app/src/main/java/com/wdkl/nursewatch/presentation/ui/base/BaseFragment.java
  41. 77 0
      app/src/main/java/com/wdkl/nursewatch/presentation/ui/views/BatteryView.java
  42. 30 0
      app/src/main/java/com/wdkl/nursewatch/presentation/ui/views/MarqueeText.java
  43. 61 0
      app/src/main/java/com/wdkl/nursewatch/presentation/ui/views/XWEasyRecyclerView.java
  44. 93 0
      app/src/main/java/com/wdkl/nursewatch/service/APPService.java
  45. 333 0
      app/src/main/java/com/wdkl/nursewatch/service/BeaconService.java
  46. 85 0
      app/src/main/java/com/wdkl/nursewatch/utils/LogUtil.java
  47. 981 0
      app/src/main/java/com/wdkl/nursewatch/utils/NetworkUtil.java
  48. 493 0
      app/src/main/java/com/wdkl/nursewatch/utils/PalyPhonetics.java
  49. 407 0
      app/src/main/java/com/wdkl/nursewatch/utils/PhoneUtils.java
  50. 69 0
      app/src/main/java/com/wdkl/nursewatch/utils/ReceiverUtil.java
  51. 162 0
      app/src/main/java/com/wdkl/nursewatch/utils/SaveCallListUtil.java
  52. 120 0
      app/src/main/java/com/wdkl/nursewatch/utils/SharedPreferencesUtil.java
  53. 1101 0
      app/src/main/java/com/wdkl/nursewatch/utils/StringUtils.java
  54. 189 0
      app/src/main/java/com/wdkl/nursewatch/utils/TimeUtil.java
  55. 126 0
      app/src/main/java/com/wdkl/nursewatch/utils/ToastUtil.java
  56. 326 0
      app/src/main/java/com/wdkl/nursewatch/utils/WebsocketUtil.java
  57. 44 0
      app/src/main/java/com/wdkl/nursewatch/utils/testudp.java
  58. BIN
      app/src/main/res/drawable-hdpi/app_logo.png
  59. BIN
      app/src/main/res/drawable-hdpi/jpush_ic_richpush_actionbar_back.png
  60. BIN
      app/src/main/res/drawable-hdpi/jpush_ic_richpush_actionbar_divider.png
  61. BIN
      app/src/main/res/drawable-hdpi/jpush_notification_icon.png
  62. 21 0
      app/src/main/res/drawable-hdpi/jpush_richpush_btn_selector.xml
  63. 20 0
      app/src/main/res/drawable-hdpi/jpush_richpush_progressbar.xml
  64. BIN
      app/src/main/res/drawable-mdpi/app_logo.png
  65. BIN
      app/src/main/res/drawable-mdpi/history_records.png
  66. BIN
      app/src/main/res/drawable-mdpi/ic_call_bed.png
  67. BIN
      app/src/main/res/drawable-mdpi/ic_calling_sickbed_room_standby_top.png
  68. BIN
      app/src/main/res/drawable-mdpi/ic_support.png
  69. BIN
      app/src/main/res/drawable-mdpi/ic_wc.png
  70. BIN
      app/src/main/res/drawable-mdpi/nor_calling.png
  71. BIN
      app/src/main/res/drawable-mdpi/setting.png
  72. BIN
      app/src/main/res/drawable-mdpi/setting_nor_click.png
  73. BIN
      app/src/main/res/drawable-mdpi/setting_sel_click.png
  74. BIN
      app/src/main/res/drawable-mdpi/unbind_nurse_station.png
  75. 34 0
      app/src/main/res/drawable-v24/ic_launcher_foreground.xml
  76. BIN
      app/src/main/res/drawable-xhdpi/app_logo.png
  77. BIN
      app/src/main/res/drawable-xxhdpi/app_logo.png
  78. BIN
      app/src/main/res/drawable-xxhdpi/img_back_white.png
  79. BIN
      app/src/main/res/drawable-xxhdpi/img_white_more.png
  80. BIN
      app/src/main/res/drawable-xxxhdpi/all_power_4g.png
  81. BIN
      app/src/main/res/drawable-xxxhdpi/all_power_4g_four.png
  82. BIN
      app/src/main/res/drawable-xxxhdpi/all_power_4g_nor.png
  83. BIN
      app/src/main/res/drawable-xxxhdpi/all_power_4g_one.png
  84. BIN
      app/src/main/res/drawable-xxxhdpi/all_power_4g_three.png
  85. BIN
      app/src/main/res/drawable-xxxhdpi/all_power_4g_two.png
  86. BIN
      app/src/main/res/drawable-xxxhdpi/app_logo.png
  87. BIN
      app/src/main/res/drawable-xxxhdpi/call_nor_per.png
  88. 170 0
      app/src/main/res/drawable/ic_launcher_background.xml
  89. 5 0
      app/src/main/res/drawable/selector_choose_botton.xml
  90. 5 0
      app/src/main/res/drawable/selector_choose_button_item_false.xml
  91. 5 0
      app/src/main/res/drawable/selector_choose_button_item_true.xml
  92. 8 0
      app/src/main/res/drawable/selector_setting_click.xml
  93. 7 0
      app/src/main/res/drawable/shape_confirm_unbind_station.xml
  94. 7 0
      app/src/main/res/drawable/shape_intoset_unbind_station.xml
  95. 6 0
      app/src/main/res/drawable/shape_nor_call_num.xml
  96. 26 0
      app/src/main/res/layout/activity_call_history_list.xml
  97. 23 0
      app/src/main/res/layout/activity_calling.xml
  98. 135 0
      app/src/main/res/layout/activity_home.xml
  99. 60 0
      app/src/main/res/layout/activity_login.xml
  100. 0 0
      app/src/main/res/layout/activity_login_phone.xml

+ 10 - 0
.gitignore

@@ -0,0 +1,10 @@
+*.iml
+.gradle
+/local.properties
+/.idea/libraries
+/.idea/modules.xml
+/.idea/workspace.xml
+.DS_Store
+/build
+/captures
+.externalNativeBuild

BIN
.idea/caches/build_file_checksums.ser


BIN
.idea/caches/gradle_models.ser


+ 4 - 0
.idea/encodings.xml

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Encoding" addBOMForNewFiles="with NO BOM" />
+</project>

+ 21 - 0
.idea/gradle.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="GradleSettings">
+    <option name="linkedExternalProjectsSettings">
+      <GradleProjectSettings>
+        <compositeConfiguration>
+          <compositeBuild compositeDefinitionSource="SCRIPT" />
+        </compositeConfiguration>
+        <option name="distributionType" value="DEFAULT_WRAPPED" />
+        <option name="externalProjectPath" value="$PROJECT_DIR$" />
+        <option name="modules">
+          <set>
+            <option value="$PROJECT_DIR$" />
+            <option value="$PROJECT_DIR$/app" />
+          </set>
+        </option>
+        <option name="resolveModulePerSourceSet" value="false" />
+      </GradleProjectSettings>
+    </option>
+  </component>
+</project>

+ 9 - 0
.idea/misc.xml

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

+ 12 - 0
.idea/runConfigurations.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="RunConfigurationProducerService">
+    <option name="ignoredProducers">
+      <set>
+        <option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
+        <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
+        <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
+      </set>
+    </option>
+  </component>
+</project>

+ 6 - 0
.idea/vcs.xml

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

+ 1 - 0
app/.gitignore

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

+ 80 - 0
app/build.gradle

@@ -0,0 +1,80 @@
+apply plugin: 'com.android.application'
+apply plugin: 'org.greenrobot.greendao'//添加数据库
+android {
+    compileSdkVersion 27
+    buildToolsVersion "27.0.3"
+    defaultConfig {
+        applicationId "com.wdkl.nursewatch"
+        minSdkVersion 19
+        targetSdkVersion 26
+        versionCode 1
+        versionName "2.2"
+        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+        android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true
+
+        ndk {
+            //选择要添加的对应 cpu 类型的 .so 库。
+            abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
+            // 还可以添加 'x86', 'x86_64', 'mips', 'mips64'
+        }
+        manifestPlaceholders = [
+                JPUSH_PKGNAME: applicationId,
+                JPUSH_APPKEY : "4943bda7c112c8c0222e5b4e", //JPush 上注册的包名对应的 Appkey.
+                JPUSH_CHANNEL: "developer-default", //暂时填写默认值即可.
+        ]
+
+    }
+    compileOptions {
+        sourceCompatibility JavaVersion.VERSION_1_8
+        targetCompatibility JavaVersion.VERSION_1_8
+    }
+    buildTypes {
+        release {
+            minifyEnabled false
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+        }
+    }
+
+    lintOptions {
+        checkReleaseBuilds false
+        abortOnError false
+    }
+
+}
+
+greendao {
+    schemaVersion 7             //数据库版本号
+    daoPackage 'com.wdkl.nursewatch.domain.repository.dao'     //生成的dao路径
+    targetGenDir 'src/main/java'                //数据库文件的目录
+}
+
+
+dependencies {
+    implementation fileTree(include: ['*.jar'], dir: 'libs')
+    implementation 'com.android.support:appcompat-v7:27.0.0'
+    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
+    testImplementation 'junit:junit:4.12'
+    androidTestImplementation 'com.android.support.test:runner:1.0.2'
+    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
+    implementation 'com.android.support:recyclerview-v7:27.0.0'
+    implementation 'org.greenrobot:eventbus:3.0.0'
+    implementation 'com.jakewharton:butterknife:7.0.1'
+    implementation 'com.jude:easyrecyclerview:4.4.2'
+    implementation 'com.squareup.okhttp3:okhttp:4.7.1'
+    implementation 'com.android.support:cardview-v7:23.2.0'
+    implementation 'cn.jiguang.sdk:jpush:3.1.6'
+    // 此处以JPush 3.1.6 版本为例。
+    implementation 'cn.jiguang.sdk:jcore:1.2.5'
+    // 此处以JCore 1.2.5 版本为例。
+    /*添加扫描二维码依赖*/
+    implementation 'com.github.yuzhiqiang1993:zxing:2.2.4'
+    implementation 'com.google.code.gson:gson:2.8.5'
+
+    implementation 'com.alibaba:fastjson:1.2.46'
+
+    //ibeancon
+    //implementation 'org.altbeacon:android-beacon-library:2.13+'
+    //implementation 'androidx.appcompat:appcompat:1.1.0'
+    implementation 'org.altbeacon:android-beacon-library:2.17'
+    implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
+}

BIN
app/keystore/keystore.jks


+ 21 - 0
app/proguard-rules.pro

@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile

BIN
app/release/Nurse_Watch_V1.0_20191012.apk


BIN
app/release/Nurse_Watch_V2.0_20191113_t3.apk


BIN
app/release/Nurse_Watch_V2.0_20191210.apk


+ 1 - 0
app/release/output.json

@@ -0,0 +1 @@
+[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"2.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]

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

@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    package="com.wdkl.nursewatch">
+
+
+    <uses-permission android:name="android.permission.BIND_DEVICE_ADMIN" />
+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
+    <uses-permission android:name="android.permission.WAKE_LOCK" />
+    <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
+    <uses-permission android:name="android.permission.CAMERA" />
+    <uses-permission android:name="android.permission.FLASHLIGHT" />
+
+    <uses-feature android:name="android.hardware.camera" />
+    <uses-feature android:name="android.hardware.camera.autofocus" />
+    <uses-feature android:name="android.hardware.bluetooth_le"
+        android:required="true"/>
+    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
+    <uses-permission android:name="android.permission.BLUETOOTH"/>
+    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
+
+    <uses-permission android:name="android.permission.VIBRATE" />
+    <uses-permission android:name="android.permission.WAKE_LOCK" />
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+    <!-- Required -->
+    <permission
+        android:name="com.wdkl.nursewatch.permission.JPUSH_MESSAGE"
+        android:protectionLevel="signature" />
+
+    <!-- Required -->
+    <uses-permission android:name="com.wdkl.nursewatch.permission.JPUSH_MESSAGE" />
+    <uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+    <uses-permission
+        android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"
+        tools:ignore="ProtectedPermissions" />
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+    <uses-permission
+        android:name="android.permission.WRITE_SETTINGS"
+        tools:ignore="ProtectedPermissions" />
+    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+
+    <!-- Optional. Required for location feature -->
+    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> <!-- 用于开启 debug 版本的应用在 6.0 系统上的层叠窗口权限 -->
+    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
+    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
+    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
+    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
+    <uses-permission android:name="android.permission.GET_TASKS" />
+    <uses-permission android:name="android.permission.VIBRATE" />
+
+    <application
+        android:name=".MyApplication"
+        android:allowBackup="true"
+        android:icon="@drawable/app_logo"
+        android:label="@string/app_name"
+        android:launchMode="singleInstance"
+        android:networkSecurityConfig="@xml/network_security_config"
+        android:persistent="true"
+        android:roundIcon="@drawable/app_logo"
+        android:sharedUserId="android.uid.system"
+        android:supportsRtl="true"
+        android:theme="@style/AppTheme">
+
+        <activity
+            android:name=".presentation.ui.activities.WelcomeActivity"
+            android:launchMode="singleTask"
+            android:screenOrientation="portrait">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+                <!-- 设置成主题界面 -->
+                <category android:name="android.intent.category.HOME" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+        </activity>
+        <activity
+            android:name=".presentation.ui.activities.HomeActivity"
+            android:launchMode="singleTask"
+            android:screenOrientation="portrait" />
+        <activity
+            android:name=".presentation.ui.activities.LoginActivity"
+            android:launchMode="singleTask"
+            android:screenOrientation="portrait" />
+        <activity
+            android:name=".presentation.ui.activities.MainActivity"
+            android:launchMode="singleTask"
+            android:screenOrientation="portrait" />
+        <activity
+            android:name=".presentation.ui.activities.VoiceMessageActivity"
+            android:launchMode="singleTask"
+            android:screenOrientation="portrait" />
+        <activity
+            android:name="com.wdkl.nursewatch.presentation.ui.activitiesphone.LoginActivityPhone"
+            android:launchMode="singleTask"
+            android:screenOrientation="portrait" />
+        <activity
+            android:name="com.wdkl.nursewatch.presentation.ui.activitiesphone.MainActivityPhone"
+            android:launchMode="singleTask"
+            android:screenOrientation="portrait" />
+        <activity
+            android:name="com.wdkl.nursewatch.presentation.ui.activitiesphone.SettingActivityPhone"
+            android:launchMode="singleTask"
+            android:screenOrientation="portrait" />
+
+        <service
+            android:name="com.wdkl.nursewatch.service.APPService"
+            android:enabled="true"
+            android:exported="true"
+            android:priority="1000"
+            android:permission="true"/>
+        <service android:name="com.wdkl.nursewatch.service.BeaconService"
+            android:persistent="true"
+            android:priority="999"/>
+    </application>
+
+</manifest>

+ 13 - 0
app/src/main/aidl/com/wdkl/nursewatch/KeepAliveConnection.aidl

@@ -0,0 +1,13 @@
+// KeepAliveConnection.aidl
+package com.wdkl.nursewatch;
+
+// Declare any non-default types here with import statements
+
+interface KeepAliveConnection {
+    /**
+     * Demonstrates some basic types that you can use as parameters
+     * and return values in AIDL.
+     */
+//    void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat,
+//            double aDouble, String aString);
+}

+ 85 - 0
app/src/main/java/com/wdkl/nursewatch/MyApplication.java

@@ -0,0 +1,85 @@
+package com.wdkl.nursewatch;
+
+import android.app.AlarmManager;
+import android.app.Application;
+import android.app.PendingIntent;
+import android.app.Service;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.IBinder;
+
+import com.wdkl.nursewatch.entity.MessageEntity;
+import com.wdkl.nursewatch.presentation.ui.activities.MainActivity;
+import com.wdkl.nursewatch.service.APPService;
+import com.wdkl.nursewatch.utils.SharedPreferencesUtil;
+import com.wdkl.nursewatch.utils.WebsocketUtil;
+
+import java.util.ArrayList;
+
+public class MyApplication extends Application {
+
+    /**
+     * 全局的播报列表
+     */
+    public volatile static ArrayList<MessageEntity> speakEntityList = new ArrayList<>();
+    //轮播语音全局控制(20171102)
+    public volatile static float PalyPhoneticsVolume = 1.0f;
+    //轮播语音全局控制默认值(20171102)(20171102)
+    public volatile static boolean PALYDISMISS = false;
+    //轮播语音全局控制(20171102)
+    public volatile static boolean IS_HAVE_SPEAK = true;
+
+    private static Context sAppContext;
+
+    public static Context getAppContext() {
+        if (null == sAppContext) {
+            sAppContext = getAppContext();
+        }
+        return sAppContext;
+    }
+
+    @Override
+    public void onCreate() {
+        sAppContext = this;
+        super.onCreate();
+//        IS_HAVE_SPEAK = SharedPreferencesUtil.getBooleanSp(SharedPreferencesUtil.SETTING_RONG);
+//
+//        Intent bindIntent = new Intent(MyApplication.this, APPService.class);
+//        bindService(bindIntent, connection, BIND_AUTO_CREATE);
+
+        IS_HAVE_SPEAK = SharedPreferencesUtil.getBooleanSp(SharedPreferencesUtil.SETTING_VOICE_BROADCAST);
+        WebsocketUtil.connectWS();
+
+        setAlarm();
+    }
+
+    public ServiceConnection connection = new ServiceConnection() {
+        @Override
+        public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
+            //APPService.ServiceBinder myBinder = (APPService.ServiceBinder) iBinder;
+        }
+
+        @Override
+        public void onServiceDisconnected(ComponentName componentName) {
+
+        }
+    };
+
+
+
+    public void setAlarm() {
+        Intent intent = new Intent(getAppContext(), APPService.class);
+        PendingIntent pIntent = PendingIntent.getService(getAppContext(), 1, intent, 0);
+        AlarmManager alarm = (AlarmManager) getSystemService(Service.ALARM_SERVICE);
+        if (alarm != null) {
+            alarm.cancel(pIntent);
+            // 闹钟在系统睡眠状态下会唤醒系统并执行提示功能
+            alarm.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 1000, 3000000, pIntent);
+            //alarm.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), pIntent);
+        }
+    }
+
+
+}

+ 75 - 0
app/src/main/java/com/wdkl/nursewatch/adapters/HistoryCallAdapter.java

@@ -0,0 +1,75 @@
+package com.wdkl.nursewatch.adapters;
+
+import android.content.Context;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.jude.easyrecyclerview.adapter.BaseViewHolder;
+import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;
+import com.wdkl.nursewatch.R;
+import com.wdkl.nursewatch.common.Constants;
+import com.wdkl.nursewatch.entity.MessageEntity;
+
+/**
+ * 健康宣教适配器
+ */
+public class HistoryCallAdapter extends RecyclerArrayAdapter<MessageEntity> {
+
+    public HistoryCallAdapter(Context context) {
+        super(context);
+    }
+
+    @Override
+    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
+        return new HeathListEntityHolder(parent);
+
+    }
+
+    public class HeathListEntityHolder extends BaseViewHolder<MessageEntity> implements View.OnClickListener {
+        LinearLayout llHistoryCallRecord;
+        ImageView imgPicture;
+        TextView tvName;
+        TextView tvNameTimes;
+
+        public HeathListEntityHolder(ViewGroup parent) {
+            super(parent, R.layout.list_item_history_records);
+
+            llHistoryCallRecord = $(R.id.list_item_ll_history_records);
+            imgPicture = $(R.id.list_item_img_history_records);
+            tvName = $(R.id.list_item_tv_history_records_name);
+            tvNameTimes = $(R.id.list_item_tv_history_records_times);
+
+        }
+
+        @Override
+        public void onClick(View view) {
+
+
+        }
+
+        @Override
+        public void setData(final MessageEntity data) {
+            tvName.setText(data.getPatientName());
+            if (data.getDataEight().equals(Constants.SON_CALL)) {//床头机呼叫
+                imgPicture.setImageResource(R.drawable.ic_call_bed);
+            } else if (data.getDataEight().equals(Constants.WSHROOM_CALL)) {//卫生间紧急呼叫
+                imgPicture.setImageResource(R.drawable.ic_wc);
+            } else if (data.getDataEight().equals(Constants.ROOMHELP_CALL)) {//床头机请求
+                imgPicture.setImageResource(R.drawable.ic_support);
+            } else if (data.getDataEight().equals(Constants.DOOR_CALL)) {//门口机呼叫
+                imgPicture.setImageResource(R.drawable.ic_calling_sickbed_room_standby_top);
+            } else if (data.getDataEight().equals(Constants.TRADITION_CALL)) {//传统子机呼叫
+                imgPicture.setImageResource(R.drawable.ic_call_bed);
+            }
+
+            //tvNameTimes.setText(data.getCreateTime());
+            //imgPicture.setImageResource(R.drawable.ic_back);
+        }
+    }
+
+
+}
+

+ 83 - 0
app/src/main/java/com/wdkl/nursewatch/adapters/HistoryCallAdapterPhone.java

@@ -0,0 +1,83 @@
+package com.wdkl.nursewatch.adapters;
+
+import android.content.Context;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.jude.easyrecyclerview.adapter.BaseViewHolder;
+import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;
+import com.wdkl.nursewatch.R;
+import com.wdkl.nursewatch.common.Constants;
+import com.wdkl.nursewatch.entity.MessageEntity;
+import com.wdkl.nursewatch.presentation.ui.views.MarqueeText;
+
+public class HistoryCallAdapterPhone extends RecyclerArrayAdapter<MessageEntity> {
+
+    AdapterOnClickListener adapterOnClickListener;
+
+    public HistoryCallAdapterPhone(Context context) {
+        super(context);
+    }
+
+    @Override
+    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
+        return new HeathListEntityHolder(parent);
+
+    }
+
+    public void setAdapterOnClickListener(AdapterOnClickListener adapterOnClickListener) {
+        this.adapterOnClickListener = adapterOnClickListener;
+    }
+
+    public interface AdapterOnClickListener {
+        void adapterOnClick(View view, MessageEntity messageEntity);
+    }
+
+    public class HeathListEntityHolder extends BaseViewHolder<MessageEntity> implements View.OnClickListener {
+        TextView item_tv_name;
+        MarqueeText item_tv_content;
+        Button delete_button, handle_button;
+        ImageView list_item_img_logo;
+
+        public HeathListEntityHolder(ViewGroup parent) {
+            super(parent, R.layout.list_item_history_records_phone);
+
+            list_item_img_logo = $(R.id.list_item_img_logo);
+            item_tv_name = $(R.id.item_tv_name);
+            item_tv_content = $(R.id.item_tv_content);
+            delete_button = $(R.id.delete_button);
+            handle_button = $(R.id.handle_button);
+            delete_button.setOnClickListener(this);
+            handle_button.setOnClickListener(this);
+        }
+
+        @Override
+        public void onClick(View view) {
+            adapterOnClickListener.adapterOnClick(view, getItem(getLayoutPosition()));
+        }
+
+        @Override
+        public void setData(final MessageEntity data) {
+            item_tv_name.setText(data.getDataNine());
+            item_tv_content.setText(data.getPatientName());
+            if (data.getDataEight().equals(Constants.SON_CALL)) {//床头机呼叫
+                list_item_img_logo.setImageResource(R.drawable.ic_call_bed);
+            } else if (data.getDataEight().equals(Constants.WSHROOM_CALL)) {//卫生间紧急呼叫
+                list_item_img_logo.setImageResource(R.drawable.ic_wc);
+            } else if (data.getDataEight().equals(Constants.ROOMHELP_CALL)) {//床头机请求
+                list_item_img_logo.setImageResource(R.drawable.ic_support);
+            } else if (data.getDataEight().equals(Constants.DOOR_CALL)) {//门口机呼叫
+                list_item_img_logo.setImageResource(R.drawable.ic_calling_sickbed_room_standby_top);
+            } else if (data.getDataEight().equals(Constants.TRADITION_CALL)) {//传统子机呼叫
+                list_item_img_logo.setImageResource(R.drawable.ic_call_bed);
+            }
+
+        }
+    }
+
+
+}
+

+ 40 - 0
app/src/main/java/com/wdkl/nursewatch/adapters/MainViewAdapter.java

@@ -0,0 +1,40 @@
+package com.wdkl.nursewatch.adapters;
+
+import java.util.List;
+
+import android.support.annotation.NonNull;
+import android.support.v4.view.PagerAdapter;
+import android.view.View;
+import android.view.ViewGroup;
+
+public class MainViewAdapter extends PagerAdapter {
+
+    private List<View> viewList;//数据源
+
+    public MainViewAdapter(List<View> viewList) {
+        this.viewList = viewList;
+    }
+
+    @Override
+    public int getCount() {
+        return viewList.size();
+    }
+
+    @Override
+    public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
+        return view == object;
+    }
+
+    @Override
+    public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
+        container.removeView(viewList.get(position));
+    }
+
+    @NonNull
+    @Override
+    public Object instantiateItem(@NonNull ViewGroup container, int position) {
+        container.addView(viewList.get(position));//千万别忘记添加到container
+        return viewList.get(position);
+    }
+
+}

+ 26 - 0
app/src/main/java/com/wdkl/nursewatch/broadcast/BatteryBroadcastReceiver.java

@@ -0,0 +1,26 @@
+package com.wdkl.nursewatch.broadcast;
+
+import android.content.Context;
+import android.content.Intent;
+import com.wdkl.nursewatch.presentation.ui.views.BatteryView;
+import com.wdkl.nursewatch.utils.LogUtil;
+
+public class BatteryBroadcastReceiver extends android.content.BroadcastReceiver {
+
+    private BatteryView mBatteryView;
+
+    public BatteryBroadcastReceiver(BatteryView mBatteryView) {
+        this.mBatteryView = mBatteryView;
+    }
+
+    @Override
+    public void onReceive(Context context, Intent intent) {
+        if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) {
+            int level = intent.getIntExtra("level", 0);
+            int scale = intent.getIntExtra("scale", 100);
+            int power = level * 100 / scale;
+            LogUtil.d("BatteryBroadcastReceiver", "电池电量::" + power);
+            mBatteryView.setPower(power);
+        }
+    }
+}

+ 70 - 0
app/src/main/java/com/wdkl/nursewatch/common/Constants.java

@@ -0,0 +1,70 @@
+package com.wdkl.nursewatch.common;
+
+/**
+ * 全局变量
+ */
+
+public class Constants {
+
+    public static final int DOORLIGHTTRUNRED = 1;
+    public static final String INITENTITY = "initEntity";
+
+    public static String[] MAIN_TITLE = {"未受理信息", "历史记录", "系统设置", "解绑护士站"};
+
+    /**
+     * 未接电话记录
+     */
+    public static final int EVENT_VOICE_MESSAGE = 0x12;
+    /**
+     * websocket连接状态
+     */
+    public static final int EVENT_LOGIN_STATUS_MESSAGE = 0x13;
+    /**
+     * 发送udp数据
+     */
+    public static final int EVENT_NEW_UDPDATA = 0x14;
+    /**
+     * 关闭弹出popupwindow
+     */
+    public static final int EVENT_CLOSE_POPUPWINDOW = 0x15;
+    /**
+     * 进入未接呼叫信息的pop刷新主页未接信息数目
+     */
+    public static final int EVENT_UPDATE_HOME_CALL_NUMBER = 0x16;
+
+    /**
+     * 各种呼叫的机型
+     * type :1门口机 2主机 3 子机 4请求增援 5卫生间 6子机转接优先等级依次升高  12传统子机呼叫
+     */
+    public static final String DOOR_CALL = "1";
+    public static final String MAIN_CALL = "2";
+    public static final String SON_CALL = "3";
+    public static final String ROOMHELP_CALL = "4";
+    public static final String WSHROOM_CALL = "5";
+    public static final String MULTITAP_CALL = "6";
+    public static final String TRADITION_CALL = "12";
+
+    //Handler_Flag
+    public static final int TIME_WHAT = 1000;//时间
+    //是否退出
+    public static boolean IS_LOGOUT = true;
+
+    //是否震动
+    public static boolean IS_Shake = true;
+    //铃声和通知声音切换
+    public static boolean IS_Rong = false;
+
+    public static String SETTING_SHAREPREFERENCE = "RingRong_Shake";
+
+    public static String PACKAGE_NAME = "com.wdkl.nursewatch";
+
+
+    public static String APP_PROCESS_ID = "";
+
+    public static boolean APP_ACTIVATE_STATUS = false;
+    /**
+     * udp数据
+     */
+    public static String UDP_WS_DATA = "";
+
+}

+ 43 - 0
app/src/main/java/com/wdkl/nursewatch/entity/BluetoothDataEntity.java

@@ -0,0 +1,43 @@
+package com.wdkl.nursewatch.entity;
+
+import java.io.Serializable;
+
+public class BluetoothDataEntity implements Serializable {
+
+    private String address;//信标地址 (唯一标识)
+    private int rssi;   //信标强度 负数 强度越大离得越近
+    private String distance; //距离信标的距离
+
+    @Override
+    public boolean equals(Object obj) {
+        if(obj instanceof BluetoothDataEntity){
+            BluetoothDataEntity bluetoothDataEntity = (BluetoothDataEntity)obj;
+            return address.equals(bluetoothDataEntity.getAddress());
+        }
+        return false;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    public int getRssi() {
+        return rssi;
+    }
+
+    public void setRssi(int rssi) {
+        this.rssi = rssi;
+    }
+
+    public String getDistance() {
+        return distance;
+    }
+
+    public void setDistance(String distance) {
+        this.distance = distance;
+    }
+}

+ 31 - 0
app/src/main/java/com/wdkl/nursewatch/entity/HistoryCallEntity.java

@@ -0,0 +1,31 @@
+package com.wdkl.nursewatch.entity;
+
+public class HistoryCallEntity {
+    private String id;
+    private String content;
+    private String DeviceType;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public String getDeviceType() {
+        return DeviceType;
+    }
+
+    public void setDeviceType(String deviceType) {
+        DeviceType = deviceType;
+    }
+}

+ 334 - 0
app/src/main/java/com/wdkl/nursewatch/entity/MessageEntity.java

@@ -0,0 +1,334 @@
+package com.wdkl.nursewatch.entity;
+
+import android.util.Log;
+
+public class MessageEntity {
+
+    private Long Id;
+    //病人ID
+    private String PatientID;
+
+    //消息内容
+    private String Content = "";
+    private String ID;
+    //服务器机器ID
+    private String MachineID;
+
+    /**
+     * 索引
+     */
+    private String Indexes;
+    /**
+     * 说明字段
+     */
+    private String PatientName;
+    /**
+     * 主机id nurseHostID
+     */
+    private String dataOne;
+    /**
+     * 门口机id doorwayMachineID
+     */
+    private String dataTwo;
+    /**
+     * 床头机id headMachineID
+     */
+    private String dataThree;
+    /**
+     * sip地址 sipAddress
+     */
+    private String dataFour;
+    /**
+     * 房间号 roomNumber
+     */
+    private String dataFive;
+    /**
+     * 床位号 bedNumber
+     */
+    private String dataSix;
+    /**
+     * 护理等级 level
+     */
+    private String dataSeven;
+    /**
+     *  呼叫类型 Type
+     */
+    private String dataEight;
+    /**
+     * 病人名称 name
+     */
+    private String dataNine;
+    /**
+     * 机器的MAC地址 deviceMAC
+     */
+    private String dataTen;
+
+   //-------------------------------------------------------------
+
+    public String getLevel() {
+        return null == dataSeven ? "0" : dataSeven;
+    }
+
+    public void setLevel(String level) {
+        this.dataSeven = level;
+    }
+
+    public String getType() {
+        return null == dataEight ? "0" : dataEight;
+    }
+
+    public void setType(String type) {
+        this.dataEight = type;
+    }
+
+    public String getName() {
+        return null == dataNine ? "" : dataNine;
+    }
+
+    public void setName(String name) {
+        this.dataNine = name;
+    }
+
+    public String getShowText() {
+        return null == PatientName ? "" : PatientName;
+    }
+
+    public void setShowText(String showText) {
+        this.PatientName = showText;
+    }
+
+    public String getNurseHostID() {
+        return null == dataOne ? "0" : dataOne;
+    }
+
+    public void setNurseHostID(String nurseHostID) {
+        this.dataOne = nurseHostID;
+    }
+
+    public String getDoorwayMachineID() {
+        return null == dataTwo ? "0" : dataTwo;
+    }
+
+    public void setDoorwayMachineID(String doorwayMachineID) {
+        this.dataTwo = doorwayMachineID;
+    }
+
+    public String getHeadMachineID() {
+        return null == dataThree ? "0" : dataThree;
+    }
+
+    public void setHeadMachineID(String headMachineID) {
+        this.dataThree = headMachineID;
+    }
+
+    public String getSipAddress() {
+        return null == dataFour ? "" : dataFour;
+    }
+
+    public void setSipAddress(String sipAddress) {
+        this.dataFour = sipAddress;
+    }
+
+    public String getRoomNumber() {
+        return null == dataFive ? "暂无" : dataFive;
+    }
+
+    public void setRoomNumber(String roomNumber) {
+        this.dataFive = roomNumber;
+    }
+
+    public String getBedNumber() {
+        return null == dataSix ? "暂无" : dataSix;
+    }
+
+    public void setBedNumber(String bedNumber) {
+        this.dataSix = bedNumber;
+    }
+
+    public String getDeviceMAC() {
+        return dataTen == null ? "" : dataTen;
+    }
+
+    public void setDeviceMAC(String deviceMAC) {
+        this.dataTen = deviceMAC;
+    }
+   //-------------------------------------------------------------
+
+    public String getDataOne() {
+        return dataOne == null ? "" : dataOne;
+    }
+
+    public void setDataOne(String dataOne) {
+        this.dataOne = dataOne;
+    }
+
+    public String getDataTwo() {
+        return dataTwo == null ? "" : dataTwo;
+    }
+
+    public void setDataTwo(String dataTwo) {
+        this.dataTwo = dataTwo;
+    }
+
+    public String getDataThree() {
+        return dataThree == null ? "" : dataThree;
+    }
+
+    public void setDataThree(String dataThree) {
+        this.dataThree = dataThree;
+    }
+
+    public String getDataFour() {
+        return dataFour == null ? "" : dataFour;
+    }
+
+    public void setDataFour(String dataFour) {
+        this.dataFour = dataFour;
+    }
+
+    public String getDataFive() {
+        return dataFive == null ? "" : dataFive;
+    }
+
+    public void setDataFive(String dataFive) {
+        this.dataFive = dataFive;
+    }
+
+    public String getDataSix() {
+        return dataSix == null ? "" : dataSix;
+    }
+
+    public void setDataSix(String dataSix) {
+        this.dataSix = dataSix;
+    }
+
+    public String getDataSeven() {
+        return dataSeven == null ? "" : dataSeven;
+    }
+
+    public void setDataSeven(String dataSeven) {
+        this.dataSeven = dataSeven;
+    }
+
+    public String getDataEight() {
+        return dataEight == null ? "" : dataEight;
+    }
+
+    public void setDataEight(String dataEight) {
+        this.dataEight = dataEight;
+    }
+
+    public String getDataNine() {
+        return dataNine == null ? "" : dataNine;
+    }
+
+    public void setDataNine(String dataNine) {
+        this.dataNine = dataNine;
+    }
+
+    public String getDataTen() {
+        return dataTen == null ? "" : dataTen;
+    }
+
+    public void setDataTen(String dataTen) {
+        this.dataTen = dataTen;
+    }
+
+    public String getID() {
+        return ID;
+    }
+
+    public void setID(String ID) {
+        this.ID = ID;
+    }
+
+    public String getIndexes() {
+        return Indexes;
+    }
+
+    public void setIndexes(String indexes) {
+        Indexes = indexes;
+    }
+
+    public String getMachineID() {
+        return MachineID == null ? "-" : MachineID;
+    }
+
+    public void setMachineID(String machineID) {
+        MachineID = machineID;
+    }
+
+    public String getPatientID() {
+        return PatientID == null ? "-" : PatientID;
+    }
+
+    public void setPatientID(String patientID) {
+        PatientID = patientID;
+    }
+
+    public String getPatientName() {
+        return PatientName == null ? "-" : PatientName;
+    }
+
+    public void setPatientName(String patientName) {
+        PatientName = patientName;
+    }
+
+    public String getContent() {
+        return Content;
+    }
+
+    public void setContent(String content) {
+        Content = content;
+    }
+
+
+    public Long getId() {
+        return this.Id;
+    }
+
+    public void setId(Long Id) {
+        this.Id = Id;
+    }
+
+    public static boolean equalsThisEntity(MessageEntity m1, MessageEntity m2) {
+        if (null == m1 || null == m2) return false;
+        try {
+            if (null == m1.getDataTen() && null != m2.getDataTen()) {
+                return false;
+            } else if (null != m1.getDataTen() && null == m2.getDataTen()) {
+                return false;
+            } else if (null == m1.getDataTen() && null == m2.getDataTen()) {
+                return m1.getPatientName().equals(m2.getPatientName()) && m1.getPatientID().equals(m2.getPatientID())
+                        && m1.getDataOne().equals(m2.getDataOne()) && m1.getDataTwo().equals(m2.getDataTwo()) && m1.getDataThree().equals(m2.getDataThree())
+                        && m1.getDataFour().equals(m2.getDataFour()) && m1.getDataFive().equals(m2.getDataFive()) && m1.getDataSix().equals(m2.getDataSix())
+                        && m1.getDataSeven().equals(m2.getDataSeven()) && m1.getDataEight().equals(m2.getDataEight()) && m1.getDataNine().equals(m2.getDataNine());
+
+            } else {
+                //测试使用
+//                Log.e("equalsThisEntity ","PatientName "+m1.getPatientName()+" PatientID()"+m1.getPatientID()+
+//                        " getIndexes "+m1.getIndexes()+" getDataOne "+m1.getDataOne()+" getDataTwo "+m1.getDataTwo()
+//                        +" getDataThree "+m1.getDataThree()+" getDataFour "+m1.getDataFour()+" getDataFive "+m1.getDataFive()
+//                        +" getDataSix "+m1.getDataSix()+" getDataSeven "+m1.getDataSeven()+" getDataEight "+m1.getDataEight()
+//                        +" getDataNine "+m1.getDataNine() +" getDataTen "+m1.getDataTen());
+//
+//                Log.e("equalsThisEntity ","PatientName "+m2.getPatientName()+" PatientID()"+m2.getPatientID()+
+//                        " getIndexes "+m2.getIndexes()+" getDataOne "+m2.getDataOne()+" getDataTwo "+m2.getDataTwo()
+//                        +" getDataThree "+m2.getDataThree()+" getDataFour "+m2.getDataFour()+" getDataFive "+m2.getDataFive()
+//                        +" getDataSix "+m2.getDataSix()+" getDataSeven "+m2.getDataSeven()+" getDataEight "+m2.getDataEight()
+//                        +" getDataNine "+m2.getDataNine() +" getDataTen "+m2.getDataTen());
+
+                return m1.getPatientName().equals(m2.getPatientName()) && m1.getPatientID().equals(m2.getPatientID())
+                        && m1.getDataOne().equals(m2.getDataOne()) && m1.getDataTwo().equals(m2.getDataTwo()) && m1.getDataThree().equals(m2.getDataThree())
+                        && m1.getDataFour().equals(m2.getDataFour()) && m1.getDataFive().equals(m2.getDataFive()) && m1.getDataSix().equals(m2.getDataSix())
+                        && m1.getDataSeven().equals(m2.getDataSeven()) && m1.getDataEight().equals(m2.getDataEight()) && m1.getDataNine().equals(m2.getDataNine())
+                        && m1.getDataTen().equals(m2.getDataTen());
+            }
+        } catch (Exception e) {
+
+        }
+
+        return false;
+    }
+
+}

+ 27 - 0
app/src/main/java/com/wdkl/nursewatch/entity/MessageEvent.java

@@ -0,0 +1,27 @@
+package com.wdkl.nursewatch.entity;
+
+public class MessageEvent {
+    private Object message;
+    private int type;
+
+    public MessageEvent(Object message, int type) {
+        this.message = message;
+        this.type = type;
+    }
+
+    public Object getMessage() {
+        return message;
+    }
+
+    public void setMessage(Object message) {
+        this.message = message;
+    }
+
+    public int getType() {
+        return type;
+    }
+
+    public void setType(int type) {
+        this.type = type;
+    }
+}

+ 81 - 0
app/src/main/java/com/wdkl/nursewatch/entity/WebsocketEntity.java

@@ -0,0 +1,81 @@
+package com.wdkl.nursewatch.entity;
+
+public class WebsocketEntity {
+    /**
+     * DeviceType : 0
+     * MachineID : TA178110032400E84C68B45E_ 89860617070010091006
+     * UDPData : $call_1|2333|2338|2339|4000005620|02|05|129|3|零伍|0#
+     */
+    private Long id;
+    //服务器ID
+
+    private String ServerID;
+    //科室ID
+    private String DepartmentsID;
+    //护士ID号
+    private String NurseID;
+    //UDP原始报文
+    private String UDPData;
+    //设备类型
+    private String DeviceType;
+
+    public WebsocketEntity(Long id, String ServerID,String DepartmentsID, String NurseID, String UDPData, String DeviceType) {
+        this.id = id;
+        this.ServerID = ServerID;
+        this.DepartmentsID = DepartmentsID;
+        this.NurseID = NurseID;
+        this.UDPData = UDPData;
+        this.DeviceType = DeviceType;
+    }
+
+    public WebsocketEntity() {
+    }
+
+    public String getServerID() {
+        return ServerID;
+        }
+
+    public void setServerID(String serverID) {
+        ServerID = serverID;
+       }
+
+    public String getDepartmentsID() {
+        return DepartmentsID == null ? "" : DepartmentsID;
+
+    }
+    public void setDepartmentsID(String DepartmentsID) {
+        this.DepartmentsID = DepartmentsID;
+
+    }
+    public String getNurseID() {
+        return NurseID;
+    }
+
+    public void setNurseID(String nurseID) {
+        NurseID = nurseID;
+    }
+
+    public String getUDPData() {
+        return UDPData == null ? "" : UDPData;
+    }
+
+    public void setUDPData(String UDPData) {
+        this.UDPData = UDPData;
+    }
+
+    public String getDeviceType() {
+        return DeviceType == null ? "" : DeviceType;
+    }
+
+    public void setDeviceType(String deviceType) {
+        DeviceType = deviceType;
+    }
+
+    public Long getId() {
+        return this.id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+}

+ 42 - 0
app/src/main/java/com/wdkl/nursewatch/entity/WebsocketEntityReal.java

@@ -0,0 +1,42 @@
+package com.wdkl.nursewatch.entity;
+
+public class  WebsocketEntityReal {
+    /**
+     * DeviceType : 0
+     * MachineID : TA178110032400E84C68B45E_ 89860617070010091006
+     * UDPData : $call_1|2333|2338|2339|4000005620|02|05|129|3|零伍|0#
+     */
+    //服务器ID号
+    private String MachineID;
+    //UDP原始报文
+    private String UDPData;
+    //设备类型
+    private String DeviceType;
+
+
+    public String getMachineID() {
+        return MachineID == null ? "" : MachineID;
+    }
+
+    public void setMachineID(String machineID) {
+        MachineID = machineID;
+    }
+
+    public String getUDPData() {
+        return UDPData == null ? "" : UDPData;
+    }
+
+    public void setUDPData(String UDPData) {
+        this.UDPData = UDPData;
+    }
+
+    public String getDeviceType() {
+        return DeviceType == null ? "" : DeviceType;
+    }
+
+    public void setDeviceType(String deviceType) {
+        DeviceType = deviceType;
+    }
+
+
+}

+ 421 - 0
app/src/main/java/com/wdkl/nursewatch/presentation/ui/activities/HomeActivity.java

@@ -0,0 +1,421 @@
+package com.wdkl.nursewatch.presentation.ui.activities;
+
+import android.Manifest;
+import android.bluetooth.BluetoothAdapter;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.graphics.Color;
+import android.location.LocationManager;
+import android.os.Build;
+import android.os.Handler;
+import android.os.Message;
+import android.provider.Settings;
+import android.support.annotation.NonNull;
+import android.support.v4.app.ActivityCompat;
+import android.support.v4.content.ContextCompat;
+import android.telephony.PhoneStateListener;
+import android.telephony.SignalStrength;
+import android.telephony.TelephonyManager;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.View;
+import android.widget.FrameLayout;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.wdkl.nursewatch.R;
+import com.wdkl.nursewatch.broadcast.BatteryBroadcastReceiver;
+import com.wdkl.nursewatch.common.Constants;
+import com.wdkl.nursewatch.entity.MessageEntity;
+import com.wdkl.nursewatch.entity.MessageEvent;
+import com.wdkl.nursewatch.presentation.ui.base.BaseActivity;
+import com.wdkl.nursewatch.presentation.ui.views.BatteryView;
+import com.wdkl.nursewatch.service.BeaconService;
+import com.wdkl.nursewatch.utils.NetworkUtil;
+import com.wdkl.nursewatch.utils.PhoneUtils;
+import com.wdkl.nursewatch.utils.ReceiverUtil;
+import com.wdkl.nursewatch.utils.SaveCallListUtil;
+import com.wdkl.nursewatch.utils.SharedPreferencesUtil;
+import com.wdkl.nursewatch.utils.StringUtils;
+import com.wdkl.nursewatch.utils.TimeUtil;
+import com.wdkl.nursewatch.utils.ToastUtil;
+import com.wdkl.nursewatch.utils.WebsocketUtil;
+
+import org.altbeacon.beacon.Beacon;
+import org.altbeacon.beacon.BeaconConsumer;
+import org.altbeacon.beacon.BeaconManager;
+import org.altbeacon.beacon.RangeNotifier;
+import org.altbeacon.beacon.Region;
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import butterknife.Bind;
+
+public class HomeActivity extends BaseActivity implements View.OnClickListener {
+
+    @Bind(R.id.tv_home_times)
+    TextView tv_home_times;
+    @Bind(R.id.tv_nurse_name)
+    TextView tv_nurse_name;
+    @Bind(R.id.tv_home_date_times)
+    TextView tv_home_date_times;
+    @Bind(R.id.ll_home_all)
+    LinearLayout ll_home_all;
+    @Bind(R.id.list_item_img_icon_num)
+    TextView list_item_img_icon_num;
+    @Bind(R.id.tv_home_network_power)
+    TextView tv_home_network_power;
+    @Bind(R.id.tv_home_version)
+    TextView tv_home_version;
+    @Bind(R.id.tv_home_call_num)
+    TextView tv_home_call_num;
+
+    @Bind(R.id.fl_home_nor_call_img_icon)
+    FrameLayout fl_home_nor_call_img_icon;
+    @Bind(R.id.battery_view)
+    BatteryView battery_view;
+
+    BatteryBroadcastReceiver batteryBroadcastReceiver;
+
+    public TelephonyManager mTelephonyManager;
+    public PhoneStatListener mListener;
+
+    String departmentsId  = "";
+
+    List<MessageEntity> callList;
+
+    //ibeancon
+    private static final int REQUEST_ENABLE_BT = 1;
+    private static final int REQUEST_ENABLE_LOCATION = 1;
+    private boolean isEnabledBT = false;
+    private boolean isEnabledLocation = false;
+    private boolean beanconServiceStarted = false;
+
+    String[] allPermissions = new String[]{Manifest.permission.CAMERA, Manifest.permission.CHANGE_NETWORK_STATE,
+            Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE,
+            Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION};
+
+    @Override
+    public int getLayoutId() {
+        return R.layout.activity_home;
+    }
+
+    @Override
+    protected void initView() {
+        applyPermission();
+        ll_home_all.setOnClickListener(this);
+            battery_view.setVisibility(View.VISIBLE);
+            tv_home_network_power.setVisibility(View.VISIBLE);
+            checkBT();
+            checkLocation();
+
+
+        tv_home_version.setOnLongClickListener(new View.OnLongClickListener() {//这里是有的腕表连不上USB,检测用的
+            @Override
+            public boolean onLongClick(View v) {
+                Intent intent2 = new Intent(Settings.ACTION_SETTINGS);
+                startActivity(intent2);
+                return false;
+            }
+        });
+
+    }
+
+    /**
+     * 动态申请权限
+     */
+    public void applyPermission() {
+        if (Build.VERSION.SDK_INT >= 23) {
+            boolean needapply = false;
+            for (int i = 0; i < allPermissions.length; i++) {
+                int chechpermission = ContextCompat.checkSelfPermission(getApplicationContext(), allPermissions[i]);
+                if (chechpermission != PackageManager.PERMISSION_GRANTED) {
+                    needapply = true;
+                }
+            }
+            if (needapply) {
+                ActivityCompat.requestPermissions(HomeActivity.this, allPermissions, 1);
+            }
+        }
+    }
+
+    @Override
+    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
+        for (int i = 0; i < grantResults.length; i++) {
+            if (grantResults[i] == PackageManager.PERMISSION_GRANTED) {
+            } else {
+                ToastUtil.showToast(HomeActivity.this, "未指定权限,请先授权!");
+            }
+        }
+    }
+
+    @Override
+    protected void initData() {
+
+        departmentsId = SharedPreferencesUtil.getStringSp( SharedPreferencesUtil.LOGIN_DEPARTMENTSID);
+
+        handler.sendEmptyMessage(TIME_WHAT);
+        tv_home_date_times.setText(TimeUtil.getInstance().getDataTime());
+        tv_home_version.setText("V" + StringUtils.getAppVersionName(this));
+
+        batteryBroadcastReceiver = new BatteryBroadcastReceiver(battery_view);
+        ReceiverUtil.registReceiver(this, batteryBroadcastReceiver, Intent.ACTION_BATTERY_CHANGED);
+
+    }
+
+    private void checkBT() {
+        BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+        if (bluetoothAdapter != null) {
+            if (bluetoothAdapter.isEnabled()) {
+                isEnabledBT = true;
+            } else {
+                Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
+                startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
+            }
+        }
+    }
+
+    private void checkLocation() {
+        LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
+        boolean gps = lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
+        boolean network = lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
+        if (gps || network) {
+            isEnabledLocation = true;
+        } else {
+            Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
+            startActivityForResult(intent, REQUEST_ENABLE_LOCATION);
+        }
+    }
+
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+        if (requestCode == REQUEST_ENABLE_BT && resultCode == RESULT_OK) {
+            isEnabledBT = true;
+        }
+        if (requestCode == REQUEST_ENABLE_LOCATION && resultCode == RESULT_OK) {
+            isEnabledLocation = true;
+        }
+
+    }
+
+
+    final int TIME_WHAT = 1000;
+
+    public Handler handler = new Handler() {
+        public void handleMessage(Message msg) {
+            switch (msg.what) {
+                case TIME_WHAT:
+                    try {
+                        handler.sendEmptyMessageDelayed(TIME_WHAT, 1000);
+                        tv_home_times.setText(TimeUtil.getInstance().getTime());
+                        String timeStr = tv_home_times.getText().toString();
+                        if (timeStr.equals("00:00:01") || timeStr.equals("00:00:10") || timeStr.equals("05:00:00") || timeStr.equals("09:00:00") || timeStr.equals("11:30:00") || timeStr.equals("14:00:00") || timeStr.equals("17:00:00") || timeStr.equals("20:30:00")) {
+                            tv_home_date_times.setText(TimeUtil.getInstance().getDataTime());
+                        }
+                    } catch (Exception e) {
+
+                    }
+                    break;
+            }
+        }
+    };
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        refreshCallList();
+
+        if (!NetworkUtil.checkNetworkAvailable()) {
+            tv_home_times.setTextColor(Color.RED);
+            tv_home_network_power.setText("当前无网络");
+            tv_home_network_power.setTextColor(Color.RED);
+        }
+        String serverId = SharedPreferencesUtil.getStringSp(SharedPreferencesUtil.LOGIN_SERVERID);
+        departmentsId = SharedPreferencesUtil.getStringSp( SharedPreferencesUtil.LOGIN_DEPARTMENTSID);
+        String nurseID = SharedPreferencesUtil.getStringSp(SharedPreferencesUtil.LOGIN_NURSE_ID);
+        String nurseName = SharedPreferencesUtil.getStringSp(SharedPreferencesUtil.LOGIN_NURSE_NAME);
+        if (StringUtils.notEmpty(nurseName)) {
+            tv_nurse_name.setText(nurseName);
+        } else {
+            tv_nurse_name.setText("--");
+        }
+
+        if (StringUtils.notEmpty(departmentsId)) {
+            Constants.IS_LOGOUT = false;
+
+            if (WebsocketUtil.WEBSOCKET_STATE != WebsocketUtil.WEBSOCKET_SUCCESS) {
+                WebsocketUtil.connectWS();
+                tv_home_times.setTextColor(Color.RED);
+            } else {
+                tv_home_times.setTextColor(Color.WHITE);
+            }
+
+            //启动蓝牙信标扫描服务
+            final Intent intent = new Intent(this, BeaconService.class);
+            intent.putExtra(BeaconService.SERVER_ID_KEY, serverId);
+            intent.putExtra(BeaconService.DEPARTMENTS_ID_KEY, departmentsId);
+            intent.putExtra(BeaconService.NURSE_ID_KEY, nurseID);
+            intent.putExtra(BeaconService.NURSE_NAME_KEY, nurseName);
+            startService(intent);
+        } else {
+            Constants.IS_LOGOUT = true;
+        }
+        setNetWorkListener();
+    }
+
+    /**
+     * 检测网络变化
+     */
+    public void setNetWorkListener() {
+        if (null == mTelephonyManager)
+            mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
+        if (null == mListener) mListener = new PhoneStatListener();
+        mTelephonyManager.listen(mListener, PhoneStatListener.LISTEN_SIGNAL_STRENGTHS);
+    }
+
+    @Override
+    public void onPause() {
+        super.onPause();
+        //用户不在当前页面时,停止监听
+        mTelephonyManager.listen(mListener, PhoneStatListener.LISTEN_NONE);
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        if (null != batteryBroadcastReceiver) {
+            unregisterReceiver(batteryBroadcastReceiver);
+        }
+    }
+
+    @Override
+    public void onClick(View v) {
+        switch (v.getId()) {
+            case R.id.ll_home_all:
+                if (StringUtils.notEmpty(departmentsId)) {
+                    startingActivity(MainActivity.class);
+                } else {
+                    startingActivity(LoginActivity.class);
+                }
+                break;
+        }
+    }
+
+    @Subscribe(threadMode = ThreadMode.MAIN)
+    public void onMoonEvent(MessageEvent messageEvent) {
+        switch (messageEvent.getType()) {
+            case Constants.EVENT_NEW_UDPDATA:
+                refreshCallList();
+                break;
+            case Constants.EVENT_LOGIN_STATUS_MESSAGE:
+                String status = (String) messageEvent.getMessage();
+                switch (status) {
+                    case "onOpen":
+                    case "success":
+                        tv_home_times.setTextColor(Color.WHITE);
+                        setNetWorkListener();
+                        break;
+//                    case "onOpen":
+//                        break;
+                    case "onClosing":
+                    case "onFailure":
+                        tv_home_times.setTextColor(Color.RED);
+                        setNetWorkListener();
+                        if (!NetworkUtil.checkNetworkAvailable()) {
+                            tv_home_network_power.setText("当前无网络");
+                            tv_home_network_power.setTextColor(Color.RED);
+                        }
+                        break;
+                }
+                break;
+        }
+    }
+
+    public void refreshCallList() {
+        callList = SaveCallListUtil.getCallListNow();
+        if (StringUtils.listNotEmpty(callList)) {
+            tv_home_call_num.setText("当前呼叫: " + callList.size());
+        } else {
+            tv_home_call_num.setText("当前呼叫: 0");
+        }
+    }
+
+    @SuppressWarnings("deprecation")
+    private class PhoneStatListener extends PhoneStateListener {
+        //获取信号强度
+        @Override
+        public void onSignalStrengthChanged(int asu) {
+            super.onSignalStrengthChanged(asu);
+        }
+
+        @Override
+        public void onSignalStrengthsChanged(SignalStrength signalStrength) {
+            super.onSignalStrengthsChanged(signalStrength);
+            super.onSignalStrengthsChanged(signalStrength);
+            //获取网络信号强度
+            //获取0-4的5种信号级别,越大信号越好,但是api23开始才能用
+            //if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
+            //int level = signalStrength.getLevel();
+            //}
+            int gsmSignalStrength = signalStrength.getGsmSignalStrength();//信号强度
+            int netWorkType = NetworkUtil.getNetworkState(HomeActivity.this); //获取网络类型
+            switch (netWorkType) {
+                case NetworkUtil.NETWORK_WIFI:
+                    tv_home_network_power.setText("WIFI " + gsmSignalStrength + "%");
+                    tv_home_network_power.setTextColor(Color.WHITE);
+                    break;
+                case NetworkUtil.NETWORK_2G:
+                    tv_home_network_power.setText("2G " + gsmSignalStrength + "%");
+                    tv_home_network_power.setTextColor(Color.WHITE);
+                    break;
+                case NetworkUtil.NETWORK_3G:
+                    tv_home_network_power.setText("3G " + gsmSignalStrength + "%");
+                    tv_home_network_power.setTextColor(Color.WHITE);
+                    break;
+                case NetworkUtil.NETWORK_4G:
+                    tv_home_network_power.setText("4G " + gsmSignalStrength + "%");
+                    tv_home_network_power.setTextColor(Color.WHITE);
+                    break;
+                case NetworkUtil.NETWORK_NONE:
+                    tv_home_network_power.setText("当前无网络");
+                    tv_home_network_power.setTextColor(Color.RED);
+                    break;
+                case -1:
+                    tv_home_network_power.setText("当前网络错误");
+                    tv_home_network_power.setTextColor(Color.RED);
+                    break;
+            }
+        }
+    }
+
+
+    @Override
+    public boolean onKeyUp(int keyCode, KeyEvent event) {
+        if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
+
+            //不执行父类点击事件
+            return true;
+        }
+        //继续执行父类其他点击事件
+        return super.onKeyUp(keyCode, event);
+    }
+
+
+
+    @Override
+    protected void onUserLeaveHint() {
+        super.onUserLeaveHint();
+//        Toast.makeText(this, "不能返回", Toast.LENGTH_LONG).show();
+    }
+
+}

+ 287 - 0
app/src/main/java/com/wdkl/nursewatch/presentation/ui/activities/LoginActivity.java

@@ -0,0 +1,287 @@
+package com.wdkl.nursewatch.presentation.ui.activities;
+
+import android.content.Intent;
+import android.provider.Settings;
+import android.support.v4.view.ViewPager;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.Button;
+import android.widget.RadioButton;
+import android.widget.RadioGroup;
+import android.widget.TextView;
+
+import com.wdkl.nursewatch.MyApplication;
+import com.wdkl.nursewatch.R;
+import com.wdkl.nursewatch.adapters.MainViewAdapter;
+import com.wdkl.nursewatch.common.Constants;
+import com.wdkl.nursewatch.entity.MessageEvent;
+import com.wdkl.nursewatch.presentation.ui.base.BaseActivity;
+import com.wdkl.nursewatch.service.BeaconService;
+import com.wdkl.nursewatch.utils.LogUtil;
+import com.wdkl.nursewatch.utils.NetworkUtil;
+import com.wdkl.nursewatch.utils.SharedPreferencesUtil;
+import com.wdkl.nursewatch.utils.StringUtils;
+import com.wdkl.nursewatch.utils.ToastUtil;
+import com.wdkl.nursewatch.utils.WebsocketUtil;
+import com.yzq.zxinglibrary.android.CaptureActivity;
+import com.yzq.zxinglibrary.bean.ZxingConfig;
+import com.yzq.zxinglibrary.common.Constant;
+
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+import java.util.ArrayList;
+
+import butterknife.Bind;
+
+public class LoginActivity extends BaseActivity implements View.OnClickListener {
+
+    public static final int REQUEST_CODE_SCAN = 1000;
+
+    @Bind(R.id.main_slide_pager)
+    ViewPager main_slide_pager;
+
+    MainViewAdapter mainPagerAdapter;
+
+    ArrayList<View> viewList;
+    LayoutInflater inflater;
+    View loginView, settingView;
+
+    TextView mTextViewWelcome,output;
+    Button start;
+
+    Button setting_more_button;
+    RadioGroup rg_setting_rong, rg_setting_shake,rg_setting_roomnum;
+    RadioButton rg_setting_rong_one, rg_setting_rong_two,rg_setting_roomnum_one,rg_setting_roomnum_two, rg_setting_shake_one, rg_setting_shake_two;
+
+    private  String serverId = "",departmentsId = "",nurseID = "", nurseName = "";
+
+    @Override
+    public int getLayoutId() {
+        return R.layout.activity_main;
+    }
+
+    @Override
+    protected void initView() {
+        inflater = LayoutInflater.from(this);
+
+        loginView = inflater.inflate(R.layout.activity_login, null);
+        settingView = inflater.inflate(R.layout.fragment_setting, null);
+
+        viewList = new ArrayList<>();
+        viewList.add(loginView);
+        viewList.add(settingView);
+
+        mainPagerAdapter = new MainViewAdapter(viewList);
+
+        main_slide_pager.setAdapter(mainPagerAdapter);
+        main_slide_pager.setCurrentItem(0);
+
+        mTextViewWelcome = loginView.findViewById(R.id.activity_main_layout_tv_welcome);
+        output = loginView.findViewById(R.id.output);
+        start = loginView.findViewById(R.id.start);
+
+        setting_more_button = settingView.findViewById(R.id.setting_more_button);
+        rg_setting_rong = settingView.findViewById(R.id.rg_setting_rong);
+        rg_setting_roomnum = settingView.findViewById(R.id.rg_setting_roomnum);
+        rg_setting_shake = settingView.findViewById(R.id.rg_setting_shake);
+        rg_setting_rong_one = settingView.findViewById(R.id.rg_setting_rong_one);
+        rg_setting_rong_two = settingView.findViewById(R.id.rg_setting_rong_two);
+        rg_setting_roomnum_one = settingView.findViewById(R.id.rg_setting_roomnum_one);
+        rg_setting_roomnum_two = settingView.findViewById(R.id.rg_setting_roomnum_two);
+        rg_setting_shake_one = settingView.findViewById(R.id.rg_setting_shake_one);
+        rg_setting_shake_two = settingView.findViewById(R.id.rg_setting_shake_two);
+
+        start.setOnClickListener(this);
+        setting_more_button.setOnClickListener(this);
+
+        rg_setting_rong.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
+            @Override
+            public void onCheckedChanged(RadioGroup group, int checkedId) {
+                if (checkedId == R.id.rg_setting_rong_one) {
+                    MyApplication.IS_HAVE_SPEAK = true;
+                    SharedPreferencesUtil.putBooleanSp(SharedPreferencesUtil.SETTING_VOICE_BROADCAST, true);
+                } else {
+                    MyApplication.IS_HAVE_SPEAK = false;
+                    SharedPreferencesUtil.putBooleanSp( SharedPreferencesUtil.SETTING_VOICE_BROADCAST, false);
+                }
+            }
+        });
+        rg_setting_roomnum.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
+            @Override
+            public void onCheckedChanged(RadioGroup group, int checkedId) {
+                if (checkedId == R.id.rg_setting_roomnum_one) {
+                    SharedPreferencesUtil.putBooleanSp(SharedPreferencesUtil.SETTING_BROADCASTING_ROOM_NUMBER, true);
+                } else {
+                    SharedPreferencesUtil.putBooleanSp( SharedPreferencesUtil.SETTING_BROADCASTING_ROOM_NUMBER, false);
+                }
+            }
+        });
+        rg_setting_shake.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
+            @Override
+            public void onCheckedChanged(RadioGroup group, int checkedId) {
+                if (checkedId == R.id.rg_setting_shake_one) {
+                    SharedPreferencesUtil.putBooleanSp( SharedPreferencesUtil.SETTING_SHAKE, true);
+                } else {
+                    SharedPreferencesUtil.putBooleanSp( SharedPreferencesUtil.SETTING_SHAKE, false);
+                }
+            }
+        });
+
+    }
+
+    @Override
+    protected void initData() {
+        boolean isRong = SharedPreferencesUtil.getBooleanSp( SharedPreferencesUtil.SETTING_VOICE_BROADCAST);
+        boolean isRoom = SharedPreferencesUtil.getBooleanSp( SharedPreferencesUtil.SETTING_BROADCASTING_ROOM_NUMBER);
+        boolean isShake = SharedPreferencesUtil.getBooleanSp( SharedPreferencesUtil.SETTING_SHAKE);
+        if (isRong) {
+            rg_setting_rong_one.setChecked(true);
+        } else {
+            rg_setting_rong_two.setChecked(true);
+        }
+        if (isRoom) {
+            rg_setting_roomnum_one.setChecked(true);
+        } else {
+            rg_setting_roomnum_two.setChecked(true);
+        }
+        if (isShake) {
+            rg_setting_shake_one.setChecked(true);
+        } else {
+            rg_setting_shake_two.setChecked(true);
+        }
+    }
+
+
+    private void startQT() {
+        Intent intent = new Intent(LoginActivity.this, CaptureActivity.class);
+        /*ZxingConfig是配置类
+         *可以设置是否显示底部布局,闪光灯,相册,
+         * 是否播放提示音  震动
+         * 设置扫描框颜色等
+         * 也可以不传这个参数
+         * */
+        ZxingConfig config = new ZxingConfig();
+        config.setPlayBeep(true);//是否播放扫描声音 默认为true
+        config.setShake(true);//是否震动  默认为true
+        config.setDecodeBarCode(true);//是否扫描条形码 默认为true
+        config.setReactColor(R.color.colorAccent);//设置扫描框四个角的颜色 默认为白色
+        config.setFrameLineColor(R.color.colorAccent);//设置扫描框边框颜色 默认无色
+        config.setScanLineColor(R.color.colorAccent);//设置扫描线的颜色 默认白色
+        config.setShowAlbum(false);//
+        config.setShowFlashLight(true);//
+        config.setFullScreenScan(true);//是否全屏扫描  默认为true  设为false则只会在扫描框中扫描
+        intent.putExtra(Constant.INTENT_ZXING_CONFIG, config);
+        startActivityForResult(intent, REQUEST_CODE_SCAN);
+    }
+
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+        // 扫描二维码/条码回传
+        if (requestCode == REQUEST_CODE_SCAN && resultCode == RESULT_OK) {
+            if (data != null) {
+                try {
+                    String content = data.getStringExtra(Constant.CODED_CONTENT);
+                    LogUtil.d("ZXResult", "扫描结果为:" + content);
+                    String tempContent[] = content.split("&&");
+                    for (int i = 0; i < tempContent.length; i++) {
+                        if (StringUtils.vagueInquiry(tempContent[i], "SERVERID=")) {
+                            serverId = tempContent[i].split("=")[1];
+                        }else if (StringUtils.vagueInquiry(tempContent[i], "PARTID=")) {
+                            departmentsId = tempContent[i].split(
+                                    "=")[1];
+                        } else if (StringUtils.vagueInquiry(tempContent[i], "NURSEID=")) {//20190626
+                            nurseID = tempContent[i].split("=")[1];
+                        } else if (StringUtils.vagueInquiry(tempContent[i], "NURSENAME=")) {//20190626
+                            nurseName = tempContent[i].split("=")[1];
+                        }
+                    }
+                    LogUtil.d("ZXResult", "serverID==" + serverId+"departmentsId==" + departmentsId + "---nurseID==" + nurseID + "---nurseName==" + nurseName);
+
+                    if (StringUtils.notEmpty(serverId)&&StringUtils.notEmpty(departmentsId)) {
+                        if (NetworkUtil.checkNetworkAvailable()) {
+                            WebsocketUtil.getInstance().connect(serverId,departmentsId,nurseID);
+                            //启动蓝牙信标扫描服务
+                            final Intent intent = new Intent(this, BeaconService.class);
+                            intent.putExtra(BeaconService.SERVER_ID_KEY, serverId);
+                            intent.putExtra(BeaconService.DEPARTMENTS_ID_KEY, departmentsId);
+                            intent.putExtra(BeaconService.NURSE_ID_KEY, nurseID);
+                            intent.putExtra(BeaconService.NURSE_NAME_KEY, nurseName);
+                            startService(intent);
+                        }
+                    } else {
+                        ToastUtil.showToast(LoginActivity.this, "非法二维码!");
+                    }
+                } catch (Exception e) {
+                    LogUtil.d("ZXResult", "扫描结果为:Exception");
+                }
+            }
+        }
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        NetworkUtil.checkNetworkAvailable();
+    }
+
+    @Override
+    public void onClick(View v) {
+        switch (v.getId()) {
+            case R.id.start:
+                startQT();
+                break;
+            case R.id.setting_more_button:
+                Intent intent2 = new Intent(Settings.ACTION_SETTINGS);
+                startActivity(intent2);
+                break;
+        }
+    }
+
+    @Subscribe(threadMode = ThreadMode.MAIN)
+    public void onMoonEvent(MessageEvent messageEvent) {
+        switch (messageEvent.getType()) {
+            case Constants.EVENT_LOGIN_STATUS_MESSAGE:
+                String status = (String) messageEvent.getMessage();
+                switch (status) {
+                    case "onOpen":
+                    case "success":
+                        Log.e("login..","绑定成功。。。。。");
+                        if (StringUtils.notEmpty(serverId)&&StringUtils.notEmpty(departmentsId)) {
+                            ToastUtil.showToast(LoginActivity.this, "绑定成功!");
+                            SharedPreferencesUtil.putStringSp(SharedPreferencesUtil.LOGIN_SERVERID, serverId);
+                            SharedPreferencesUtil.putStringSp(SharedPreferencesUtil.LOGIN_DEPARTMENTSID, departmentsId);
+                            SharedPreferencesUtil.putStringSp(SharedPreferencesUtil.LOGIN_NURSE_ID, nurseID);
+                            SharedPreferencesUtil.putStringSp( SharedPreferencesUtil.LOGIN_NURSE_NAME, nurseName);
+                            Constants.IS_LOGOUT = false;
+
+                            SharedPreferencesUtil.putStringSp(SharedPreferencesUtil.LOGIN_TAG, "Login");
+
+                            startingActivity(MainActivity.class);
+
+                            LoginActivity.this.finish();
+
+                        } else {
+                            ToastUtil.showToast(LoginActivity.this, "失败请重新扫描!");
+                        }
+                        break;
+//                    case "onOpen":
+//
+//                        break;
+                    case "onClosing":
+                    case "onFailure":
+                        ToastUtil.showToast(LoginActivity.this, "连接失败,请重新扫描!");
+                        break;
+                }
+
+                break;
+        }
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+    }
+}

+ 310 - 0
app/src/main/java/com/wdkl/nursewatch/presentation/ui/activities/MainActivity.java

@@ -0,0 +1,310 @@
+package com.wdkl.nursewatch.presentation.ui.activities;
+
+import android.content.Intent;
+import android.provider.Settings;
+import android.support.v4.view.ViewPager;
+import android.support.v4.widget.SwipeRefreshLayout;
+import android.support.v7.widget.LinearLayoutManager;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.RadioButton;
+import android.widget.RadioGroup;
+import android.widget.TextView;
+
+import com.wdkl.nursewatch.MyApplication;
+import com.wdkl.nursewatch.R;
+import com.wdkl.nursewatch.adapters.HistoryCallAdapter;
+import com.wdkl.nursewatch.adapters.MainViewAdapter;
+import com.wdkl.nursewatch.common.Constants;
+import com.wdkl.nursewatch.entity.MessageEntity;
+import com.wdkl.nursewatch.entity.MessageEvent;
+import com.wdkl.nursewatch.presentation.ui.base.BaseActivity;
+import com.wdkl.nursewatch.presentation.ui.views.XWEasyRecyclerView;
+import com.wdkl.nursewatch.utils.LogUtil;
+import com.wdkl.nursewatch.utils.NetworkUtil;
+import com.wdkl.nursewatch.utils.PalyPhonetics;
+import com.wdkl.nursewatch.utils.SaveCallListUtil;
+import com.wdkl.nursewatch.utils.SharedPreferencesUtil;
+import com.wdkl.nursewatch.utils.StringUtils;
+import com.wdkl.nursewatch.utils.ToastUtil;
+import com.wdkl.nursewatch.utils.WebsocketUtil;
+
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import butterknife.Bind;
+
+
+public class MainActivity extends BaseActivity implements View.OnClickListener, SwipeRefreshLayout.OnRefreshListener {
+
+    @Bind(R.id.main_slide_pager)
+    ViewPager main_slide_pager;
+
+    XWEasyRecyclerView ecl_history_records;
+    HistoryCallAdapter adapter;
+
+    TextView tv_call_history_records;
+
+    TextView list_item_img_icon_num;
+    ImageView list_item_img_icon;
+
+    Button unbind_nurse_station, setting_more_button;
+
+    RadioGroup rg_setting_rong, rg_setting_shake, rg_setting_roomnum;
+    RadioButton rg_setting_rong_one, rg_setting_rong_two, rg_setting_roomnum_one, rg_setting_roomnum_two, rg_setting_shake_one, rg_setting_shake_two;
+
+    MainViewAdapter mainPagerAdapter;
+
+    String loginMachineId = "";
+
+    ArrayList<View> viewList;
+    LayoutInflater inflater;
+    View callingMationView, historyCallView, settingView, unbindNurseStationView;
+
+    List<MessageEntity> callList;
+
+    public int dialogType = -1;
+
+    @Override
+    public int getLayoutId() {
+        return R.layout.activity_main;
+    }
+
+    @Override
+    protected void initView() {
+        inflater = LayoutInflater.from(this);
+
+        callingMationView = inflater.inflate(R.layout.fragment_calling_mation, null);
+        historyCallView = inflater.inflate(R.layout.fragment_history_call, null);
+        settingView = inflater.inflate(R.layout.fragment_setting, null);
+        unbindNurseStationView = inflater.inflate(R.layout.fragment_unbind_nurse_station, null);
+        viewList = new ArrayList<>();
+        viewList.add(callingMationView);
+        viewList.add(historyCallView);
+        viewList.add(settingView);
+        viewList.add(unbindNurseStationView);
+
+        mainPagerAdapter = new MainViewAdapter(viewList);
+
+        main_slide_pager.setAdapter(mainPagerAdapter);
+        main_slide_pager.setCurrentItem(0);
+
+        list_item_img_icon_num = callingMationView.findViewById(R.id.list_item_img_icon_num);
+        list_item_img_icon = callingMationView.findViewById(R.id.list_item_img_icon);
+
+        tv_call_history_records = historyCallView.findViewById(R.id.tv_call_history_records);
+        ecl_history_records = historyCallView.findViewById(R.id.ecl_history_records);
+
+        setting_more_button = settingView.findViewById(R.id.setting_more_button);
+        rg_setting_rong = settingView.findViewById(R.id.rg_setting_rong);
+        rg_setting_roomnum = settingView.findViewById(R.id.rg_setting_roomnum);
+        rg_setting_shake = settingView.findViewById(R.id.rg_setting_shake);
+        rg_setting_rong_one = settingView.findViewById(R.id.rg_setting_rong_one);
+        rg_setting_rong_two = settingView.findViewById(R.id.rg_setting_rong_two);
+        rg_setting_roomnum_one = settingView.findViewById(R.id.rg_setting_roomnum_one);
+        rg_setting_roomnum_two = settingView.findViewById(R.id.rg_setting_roomnum_two);
+        rg_setting_shake_one = settingView.findViewById(R.id.rg_setting_shake_one);
+        rg_setting_shake_two = settingView.findViewById(R.id.rg_setting_shake_two);
+
+        unbind_nurse_station = unbindNurseStationView.findViewById(R.id.unbind_nurse_station);
+
+        unbind_nurse_station.setOnClickListener(this);
+        setting_more_button.setOnClickListener(this);
+        list_item_img_icon.setOnClickListener(this);
+
+        rg_setting_rong.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
+            @Override
+            public void onCheckedChanged(RadioGroup group, int checkedId) {
+                if (checkedId == R.id.rg_setting_rong_one) {
+                    MyApplication.IS_HAVE_SPEAK = true;
+                    SharedPreferencesUtil.putBooleanSp(SharedPreferencesUtil.SETTING_VOICE_BROADCAST, true);
+                } else {
+                    MyApplication.IS_HAVE_SPEAK = false;
+                    SharedPreferencesUtil.putBooleanSp(SharedPreferencesUtil.SETTING_VOICE_BROADCAST, false);
+                }
+            }
+        });
+        rg_setting_roomnum.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
+            @Override
+            public void onCheckedChanged(RadioGroup group, int checkedId) {
+                if (checkedId == R.id.rg_setting_roomnum_one) {
+                    SharedPreferencesUtil.putBooleanSp(SharedPreferencesUtil.SETTING_BROADCASTING_ROOM_NUMBER, true);
+                } else {
+                    SharedPreferencesUtil.putBooleanSp(SharedPreferencesUtil.SETTING_BROADCASTING_ROOM_NUMBER, false);
+                }
+            }
+        });
+        rg_setting_shake.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
+            @Override
+            public void onCheckedChanged(RadioGroup group, int checkedId) {
+                if (checkedId == R.id.rg_setting_shake_one) {
+                    SharedPreferencesUtil.putBooleanSp(SharedPreferencesUtil.SETTING_SHAKE, true);
+                } else {
+                    SharedPreferencesUtil.putBooleanSp(SharedPreferencesUtil.SETTING_SHAKE, false);
+                }
+            }
+        });
+
+        tv_call_history_records.setOnLongClickListener(new View.OnLongClickListener() {
+            @Override
+            public boolean onLongClick(View v) {
+                dialogType = 0;
+                showDialog(MainActivity.this, "温馨提示", "删除呼叫历史记录?", "取消", "确定");
+                return false;
+            }
+        });
+
+    }
+
+    @Override
+    protected void initData() {
+        loginMachineId = SharedPreferencesUtil.getStringSp(SharedPreferencesUtil.LOGIN_DEPARTMENTSID);
+        boolean isRong = SharedPreferencesUtil.getBooleanSp(SharedPreferencesUtil.SETTING_VOICE_BROADCAST);
+        boolean isRoom = SharedPreferencesUtil.getBooleanSp(SharedPreferencesUtil.SETTING_BROADCASTING_ROOM_NUMBER);
+        boolean isShake = SharedPreferencesUtil.getBooleanSp(SharedPreferencesUtil.SETTING_SHAKE);
+        if (isRong) {
+            rg_setting_rong_one.setChecked(true);
+        } else {
+            rg_setting_rong_two.setChecked(true);
+        }
+        if (isRoom) {
+            rg_setting_roomnum_one.setChecked(true);
+        } else {
+            rg_setting_roomnum_two.setChecked(true);
+        }
+        if (isShake) {
+            rg_setting_shake_one.setChecked(true);
+        } else {
+            rg_setting_shake_two.setChecked(true);
+        }
+
+        adapter = new HistoryCallAdapter(this);
+        LinearLayoutManager linearLayoutDutyNurse = new LinearLayoutManager(this);
+        linearLayoutDutyNurse.setOrientation(LinearLayoutManager.VERTICAL);
+        ecl_history_records.setLayoutManager(linearLayoutDutyNurse);
+        ecl_history_records.setAdapter(adapter);
+        //ecl_history_records.setRefreshListener(this);
+        ecl_history_records.setRefreshing(false);
+
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        NetworkUtil.checkNetworkAvailable();
+        refreshCallList();
+        loginMachineId = SharedPreferencesUtil.getStringSp(SharedPreferencesUtil.LOGIN_DEPARTMENTSID);
+        if (StringUtils.notEmpty(loginMachineId) && WebsocketUtil.WEBSOCKET_STATE != WebsocketUtil.WEBSOCKET_SUCCESS) {
+            WebsocketUtil.connectWS();
+        }
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+    }
+
+    @Subscribe(threadMode = ThreadMode.MAIN)
+    public void onMoonEvent(MessageEvent messageEvent) {
+        switch (messageEvent.getType()) {
+            case Constants.EVENT_NEW_UDPDATA:
+                MessageEntity messageEntityNewUdpdata = (MessageEntity) messageEvent.getMessage();
+                LogUtil.d("waderson", "收到信息:getMachineID==" + messageEntityNewUdpdata.getMachineID());
+                refreshCallList();
+
+                break;
+//            case Constants.EVENT_LOGIN_STATUS_MESSAGE:
+//                String status = (String) messageEvent.getMessage();
+//                switch (status) {
+//                    case "success":
+//                        break;
+//                    case "onOpen":
+//                        break;
+//                    case "onClosing":
+//                    case "onFailure":
+//                        break;
+//                }
+//                break;
+        }
+    }
+
+    public void refreshCallList() {
+        callList = SaveCallListUtil.getCallList();
+        List<MessageEntity> callListNow = SaveCallListUtil.getCallListNow();
+
+        if (StringUtils.listNotEmpty(callListNow)) {
+            list_item_img_icon_num.setText(callListNow.size() + "");
+        } else {
+            list_item_img_icon_num.setText("0");
+        }
+        if (StringUtils.listNotEmpty(callList)) {
+            adapter.clear();
+            adapter.addAll(callList);
+        } else {
+            adapter.clear();
+        }
+    }
+
+    @Override
+    public void onRefresh() {
+        ecl_history_records.setRefreshing(false);
+    }
+
+    @Override
+    public void onClick(View v) {
+        switch (v.getId()) {
+            case R.id.unbind_nurse_station:
+                dialogType = 1;
+                showDialog(MainActivity.this, "温馨提示", "解绑当前护士站吗?", "取消", "确定");
+                break;
+            case R.id.setting_more_button:
+                Intent intent2 = new Intent(Settings.ACTION_SETTINGS);
+                startActivity(intent2);
+                break;
+            case R.id.list_item_img_icon:
+                if (StringUtils.listNotEmpty(SaveCallListUtil.getCallListNow())) {
+                    startingActivity(VoiceMessageActivity.class);
+                } else {
+                    ToastUtil.showToast(MainActivity.this, "当前无呼叫请求");
+                }
+                break;
+        }
+    }
+
+    @Override
+    public void onClickButtonTwo() {
+        try {
+            if (dialogType == 0) {
+                callList = null;
+                SaveCallListUtil.deleteAllEntity();
+                SaveCallListUtil.deleteAllEntityNow();
+                PalyPhonetics.setPalyDismiss(true);
+                MyApplication.speakEntityList.clear();
+                refreshCallList();
+            } else if (dialogType == 1) {
+                SharedPreferencesUtil.putStringSp(SharedPreferencesUtil.LOGIN_SERVERID, "");
+                SharedPreferencesUtil.putStringSp(SharedPreferencesUtil.LOGIN_DEPARTMENTSID, "");
+                SharedPreferencesUtil.putStringSp(SharedPreferencesUtil.LOGIN_NURSE_ID, "");
+                SharedPreferencesUtil.putStringSp(SharedPreferencesUtil.LOGIN_NURSE_NAME, "");
+                Intent intent = new Intent(this, HomeActivity.class);
+                startActivity(intent);
+                Constants.IS_LOGOUT = true;
+                WebsocketUtil.getInstance().getWebSocket().cancel();
+                PalyPhonetics.setPalyDismiss(true);
+                MyApplication.speakEntityList.clear();
+                SaveCallListUtil.deleteAllEntity();
+                SaveCallListUtil.deleteAllEntityNow();
+                ToastUtil.showToast(this, "解绑成功,请重新绑定");
+                WebsocketUtil.WEBSOCKET_STATE = WebsocketUtil.WEBSOCKET_ONCLOSED;
+                finish();
+            }
+        } catch (Exception e) {
+        }
+    }
+
+}

+ 223 - 0
app/src/main/java/com/wdkl/nursewatch/presentation/ui/activities/VoiceMessageActivity.java

@@ -0,0 +1,223 @@
+package com.wdkl.nursewatch.presentation.ui.activities;
+
+import android.view.View;
+import android.widget.Button;
+import android.widget.ImageView;
+
+import com.wdkl.nursewatch.R;
+import com.wdkl.nursewatch.common.Constants;
+import com.wdkl.nursewatch.entity.MessageEntity;
+import com.wdkl.nursewatch.entity.MessageEvent;
+import com.wdkl.nursewatch.presentation.ui.base.BaseActivity;
+import com.wdkl.nursewatch.presentation.ui.views.MarqueeText;
+import com.wdkl.nursewatch.utils.NetworkUtil;
+import com.wdkl.nursewatch.utils.PalyPhonetics;
+import com.wdkl.nursewatch.utils.SaveCallListUtil;
+import com.wdkl.nursewatch.utils.SharedPreferencesUtil;
+import com.wdkl.nursewatch.utils.StringUtils;
+import com.wdkl.nursewatch.utils.WebsocketUtil;
+
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+import java.util.List;
+
+import butterknife.Bind;
+
+public class VoiceMessageActivity extends BaseActivity implements View.OnClickListener {
+
+    @Bind(R.id.tv_popupwindow_icon)
+    MarqueeText mContentName;
+    @Bind(R.id.tv_popupwindow_num)
+    MarqueeText tv_num;
+    @Bind(R.id.img_popupwindow_back)
+    Button back;
+    @Bind(R.id.btn_popupwindow_icon)
+    Button doIcon;
+    @Bind(R.id.img_popupwindow_icon)
+    ImageView window_icon;
+
+    List<MessageEntity> callList;
+
+    MessageEntity messageEntity ;
+
+    @Override
+    public int getLayoutId() {
+        return R.layout.activity_voice_message;
+    }
+
+    @Override
+    protected void initView() {
+        back.setOnClickListener(this);
+        doIcon.setOnClickListener(this);
+
+        window_icon.setOnLongClickListener(new View.OnLongClickListener() {
+            @Override
+            public boolean onLongClick(View v) {
+                showDialog(VoiceMessageActivity.this, "温馨提示", "删除全部呼叫?", "取消", "确定");
+                return false;
+            }
+        });
+    }
+
+    @Override
+    protected void initData() {
+
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        NetworkUtil.checkNetworkAvailable();
+        setTvData();
+    }
+
+    protected void setTvData() {
+        callList = SaveCallListUtil.getCallListNow();
+        if (StringUtils.listNotEmpty(callList)) {
+            // if(callList.size()>1) Collections.reverse(callList);//倒序
+            messageEntity = callList.get(callList.size() - 1);
+            mContentName.setText(messageEntity.getPatientName());
+            tv_num.setText(callList.size()+"");
+        } else {
+            messageEntity =null;
+            mContentName.setText("----");
+            tv_num.setText("0");
+        }
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+    }
+
+    @Override
+    public void onClick(View v) {
+        switch (v.getId()) {
+            case R.id.img_popupwindow_back:
+                VoiceMessageActivity.this.finish();
+                break;
+            case R.id.btn_popupwindow_icon:
+                if(null==messageEntity) return;
+                String serverId = SharedPreferencesUtil.getStringSp(SharedPreferencesUtil.LOGIN_SERVERID);
+                String machineId = SharedPreferencesUtil.getStringSp( SharedPreferencesUtil.LOGIN_DEPARTMENTSID);
+
+//                String cancelUdpCall = "{\"DeviceType\":\"2\",\"MachineID\":"
+//                        + "\"" + machineId + "\""
+//                        + ",\"UDPData\":" +
+//                        "\"$call_8_upremove|"
+//                        + messageEntity.getDataOne() +
+//                        "|" +
+//                        messageEntity.getDataTwo() +
+//                        "|" +
+//                        messageEntity.getDataThree() +
+//                        "|" +
+//                        messageEntity.getDataFour() +
+//                        "|" +
+//                        messageEntity.getDataFive() +
+//                        "|" +
+//                        messageEntity.getDataSix() +
+//                        "|" +
+//                        messageEntity.getDataSeven() +
+//                        "|" +
+//                        messageEntity.getDataEight() +
+//                        "|" +
+//                        messageEntity.getDataNine() +
+//                        "|" +
+//                        messageEntity.getDataTen() +
+//                        "#\"}";
+
+                String cancelUdpCall = "{\"serverSystemId\":"+ "\""+serverId+"\"" +
+                        ",\"msgData\": " +
+                        "{\"type\":" + "2" +
+                        ",\"msgData\": " +
+                        "{\"partId\":" + "\""+machineId+"\"" +
+                        ",\"udpStr\":" +
+                        "\"$call_1_hang_up"+Character.toString((char) 3)
+                        + messageEntity.getDataOne() +
+                        Character.toString((char) 3) +
+                        messageEntity.getDataTwo() +
+                        Character.toString((char) 3) +
+                        messageEntity.getDataThree() +
+                        Character.toString((char) 3) +
+                        messageEntity.getDataFour() +
+                        Character.toString((char) 3) +
+                        messageEntity.getDataFive() +
+                        Character.toString((char) 3) +
+                        messageEntity.getDataSix() +
+                        Character.toString((char) 3) +
+                        messageEntity.getDataSeven() +
+                        Character.toString((char) 3) +
+                        messageEntity.getDataEight() +
+                        Character.toString((char) 3) +
+                        messageEntity.getDataNine() +
+                        Character.toString((char) 3) +
+                        messageEntity.getDataTen() +
+                        Character.toString((char) 3) +
+                        "1"+
+                        "#\"}"+
+                        "}"+
+                        "}";
+
+                WebsocketUtil.getInstance().getWebSocket().send(cancelUdpCall);
+
+//                String noany_request = "{\"DeviceType\":\"2\",\"MachineID\":"
+//                        + "\"" + machineId + "\""
+//                        + ",\"UDPData\":" +
+//                        "\"noany_request|"
+//                        + messageEntity.getDataOne() +
+//                        "|" +
+//                        messageEntity.getDataTwo() +
+//                        "|" +
+//                        messageEntity.getDataThree() +
+//                        "|" +
+//                        messageEntity.getDataFour() +
+//                        "|" +
+//                        messageEntity.getDataFive() +
+//                        "|" +
+//                        messageEntity.getDataSix() +
+//                        "|" +
+//                        messageEntity.getDataSeven() +
+//                        "|" +
+//                        messageEntity.getDataEight() +
+//                        "|" +
+//                        messageEntity.getDataNine() +
+//                        "|" +
+//                        messageEntity.getDataTen() +
+//                        "#\"}";
+//
+//                WebsocketUtil.getInstance().getWebSocket().send(noany_request);
+
+                PalyPhonetics.deleteCallEntity(messageEntity);
+                SaveCallListUtil.deleteCallEntityNow(messageEntity);
+
+                if(PalyPhonetics.thisEntityIsSpeaking(messageEntity)){
+                    PalyPhonetics.setPalyDismiss(true);
+                }
+                setTvData();
+
+                if(!StringUtils.listNotEmpty(SaveCallListUtil.getCallListNow())){
+                    VoiceMessageActivity.this.finish();
+                }
+
+                break;
+        }
+    }
+
+    @Override
+    public void onClickButtonTwo() {
+        SaveCallListUtil.deleteAllEntityNow();
+        callList.clear();
+        setTvData();
+    }
+
+    @Subscribe(threadMode = ThreadMode.MAIN)
+    public void onMoonEvent(MessageEvent messageEvent) {
+        switch (messageEvent.getType()) {
+            case Constants.EVENT_NEW_UDPDATA:
+                setTvData();
+                break;
+        }
+    }
+
+}

+ 90 - 0
app/src/main/java/com/wdkl/nursewatch/presentation/ui/activities/WelcomeActivity.java

@@ -0,0 +1,90 @@
+package com.wdkl.nursewatch.presentation.ui.activities;
+
+import android.content.Intent;
+import android.os.Handler;
+
+import com.wdkl.nursewatch.MyApplication;
+import com.wdkl.nursewatch.R;
+import com.wdkl.nursewatch.entity.MessageEvent;
+import com.wdkl.nursewatch.presentation.ui.activitiesphone.LoginActivityPhone;
+import com.wdkl.nursewatch.presentation.ui.activitiesphone.MainActivityPhone;
+import com.wdkl.nursewatch.presentation.ui.base.BaseActivity;
+import com.wdkl.nursewatch.utils.SharedPreferencesUtil;
+import com.wdkl.nursewatch.utils.StringUtils;
+
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+public class WelcomeActivity extends BaseActivity {
+
+    @Override
+    public int getLayoutId() {
+        if(isWatch()){
+            return R.layout.activity_welcome;
+        }else{
+            return R.layout.activity_welcome_phone;
+        }
+    }
+
+    @Override
+    protected void initView() {
+
+    }
+
+    @Override
+    protected void initData() {
+
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+
+        String login_tag = SharedPreferencesUtil.getStringSp( SharedPreferencesUtil.LOGIN_TAG);
+        if (StringUtils.notEmpty(login_tag)) {
+            if(isWatch()){
+                startActivity(new Intent(WelcomeActivity.this, HomeActivity.class));
+            }else{
+                String loginMachineId = SharedPreferencesUtil.getStringSp(SharedPreferencesUtil.LOGIN_DEPARTMENTSID);
+                if (StringUtils.notEmpty(loginMachineId)) {
+                    startingActivity(MainActivityPhone.class);
+                } else {
+                    startingActivity(LoginActivityPhone.class);
+                }
+            }
+
+            WelcomeActivity.this.finish();
+
+        }else{
+            new Handler().postDelayed(new Runnable() {
+                @Override
+                public void run() {
+                    if(isWatch()){
+                        startActivity(new Intent(WelcomeActivity.this, HomeActivity.class));
+                    }else{
+                        String loginMachineId = SharedPreferencesUtil.getStringSp(SharedPreferencesUtil.LOGIN_DEPARTMENTSID);
+                        if (StringUtils.notEmpty(loginMachineId)) {
+                            startingActivity(MainActivityPhone.class);
+                        } else {
+                            startingActivity(LoginActivityPhone.class);
+                        }
+                    }
+                    WelcomeActivity.this.finish();
+                }
+            }, 2000);
+        }
+    }
+
+    @Subscribe(threadMode = ThreadMode.MAIN)
+    public void onMoonEvent(MessageEvent messageEvent) {
+        switch (messageEvent.getType()) {
+//            case EVENT_UPDATE_HOME_CALL_NUMBER:
+//                break;
+        }
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+    }
+}

+ 273 - 0
app/src/main/java/com/wdkl/nursewatch/presentation/ui/activitiesphone/LoginActivityPhone.java

@@ -0,0 +1,273 @@
+package com.wdkl.nursewatch.presentation.ui.activitiesphone;
+
+import android.Manifest;
+import android.bluetooth.BluetoothAdapter;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.os.Build;
+import android.provider.Settings;
+import android.support.annotation.NonNull;
+import android.support.v4.app.ActivityCompat;
+import android.support.v4.content.ContextCompat;
+import android.view.View;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.wdkl.nursewatch.R;
+import com.wdkl.nursewatch.common.Constants;
+import com.wdkl.nursewatch.entity.MessageEvent;
+import com.wdkl.nursewatch.presentation.ui.base.BaseActivity;
+import com.wdkl.nursewatch.service.BeaconService;
+import com.wdkl.nursewatch.utils.LogUtil;
+import com.wdkl.nursewatch.utils.NetworkUtil;
+import com.wdkl.nursewatch.utils.SharedPreferencesUtil;
+import com.wdkl.nursewatch.utils.StringUtils;
+import com.wdkl.nursewatch.utils.ToastUtil;
+import com.wdkl.nursewatch.utils.WebsocketUtil;
+import com.yzq.zxinglibrary.android.CaptureActivity;
+import com.yzq.zxinglibrary.bean.ZxingConfig;
+import com.yzq.zxinglibrary.common.Constant;
+
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+import butterknife.Bind;
+
+public class LoginActivityPhone extends BaseActivity implements View.OnClickListener {
+
+    public static final int REQUEST_CODE_SCAN = 1000;
+
+    @Bind(R.id.activity_main_layout_tv_welcome)
+    TextView tv_welcome;
+
+    @Bind(R.id.view_title_left_tv)
+    TextView titleLeftText;
+    @Bind(R.id.view_title_right_tv)
+    TextView titleRightText;
+    @Bind(R.id.view_title_layout_tv_time)
+    TextView titleText;
+    @Bind(R.id.view_title_left_iv)
+    ImageView leftImageView;
+    @Bind(R.id.view_title_right_iv)
+    ImageView rightImageView;
+
+    @Bind(R.id.output)//
+            TextView output;
+    @Bind(R.id.start)
+    Button start;
+    @Bind(R.id.into_set)
+    Button into_set;
+
+    private String serverId = "",departmentsId = "", nurseID = "", nurseName = "";
+    private static final int REQUEST_ENABLE_BT = 1;
+
+
+    @Override
+    public int getLayoutId() {
+        return R.layout.activity_login_phone;
+    }
+
+    @Override
+    protected void initView() {
+
+        titleText.setText("绑定护士站");
+        tv_welcome.setText("请扫描设备二维码" + "\r\n当前版本:V" + StringUtils.getAppVersionName(this));
+        leftImageView.setImageResource(R.drawable.img_back_white);
+        leftImageView.setOnClickListener(this);
+        start.setOnClickListener(this);
+        into_set.setOnClickListener(this);
+    }
+
+    @Override
+    protected void initData() {
+        applyPermission();
+        checkBT();
+    }
+
+    /**
+     * 开启蓝牙
+     */
+    private void checkBT() {
+        BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+        if (bluetoothAdapter != null) {
+            if (bluetoothAdapter.isEnabled()) {
+
+            } else {
+                Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
+                startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
+            }
+        }
+    }
+    String[] allPermissions = new String[]{Manifest.permission.CAMERA,
+            Manifest.permission.CHANGE_NETWORK_STATE,
+            Manifest.permission.READ_EXTERNAL_STORAGE,
+            Manifest.permission.WRITE_EXTERNAL_STORAGE,
+            Manifest.permission.ACCESS_COARSE_LOCATION,
+            };
+
+    public void applyPermission() {
+        if (Build.VERSION.SDK_INT >= 23) {
+            boolean needapply = false;
+            for (int i = 0; i < allPermissions.length; i++) {
+                int chechpermission = ContextCompat.checkSelfPermission(getApplicationContext(), allPermissions[i]);
+                if (chechpermission != PackageManager.PERMISSION_GRANTED) {
+                    needapply = true;
+                }
+            }
+            if (needapply) {
+                ActivityCompat.requestPermissions(LoginActivityPhone.this, allPermissions, 1);
+            }
+        }
+    }
+
+    @Override
+    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
+        for (int i = 0; i < grantResults.length; i++) {
+            if (grantResults[i] == PackageManager.PERMISSION_GRANTED) {
+            } else {
+                ToastUtil.showToast(LoginActivityPhone.this, "未指定权限,请先授权!");
+            }
+        }
+    }
+
+    private void startQT() {
+        Intent intent = new Intent(LoginActivityPhone.this, CaptureActivity.class);
+        /*ZxingConfig是配置类
+         *可以设置是否显示底部布局,闪光灯,相册,
+         * 是否播放提示音  震动
+         * 设置扫描框颜色等
+         * 也可以不传这个参数
+         * */
+        ZxingConfig config = new ZxingConfig();
+        config.setPlayBeep(true);//是否播放扫描声音 默认为true
+        config.setShake(true);//是否震动  默认为true
+        config.setDecodeBarCode(true);//是否扫描条形码 默认为true
+        config.setReactColor(R.color.colorAccent);//设置扫描框四个角的颜色 默认为白色
+        config.setFrameLineColor(R.color.colorAccent);//设置扫描框边框颜色 默认无色
+        config.setScanLineColor(R.color.colorAccent);//设置扫描线的颜色 默认白色
+        config.setShowAlbum(false);//
+        config.setShowFlashLight(true);//
+        config.setFullScreenScan(true);//是否全屏扫描  默认为true  设为false则只会在扫描框中扫描
+        intent.putExtra(Constant.INTENT_ZXING_CONFIG, config);
+        startActivityForResult(intent, REQUEST_CODE_SCAN);
+    }
+
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+        // 扫描二维码/条码回传
+        if (requestCode == REQUEST_CODE_SCAN && resultCode == RESULT_OK) {
+            if (data != null) {
+                try {
+                    String content = data.getStringExtra(Constant.CODED_CONTENT);
+                    LogUtil.d("ZXResult", "扫描结果为:" + content);
+                    String tempContent[] = content.split("&&");
+                    for (int i = 0; i < tempContent.length; i++) {
+                        if (StringUtils.vagueInquiry(tempContent[i], "SERVERID=")) {
+                            serverId = tempContent[i].split("=")[1];
+                        }else if (StringUtils.vagueInquiry(tempContent[i], "PARTID=")) {
+                            departmentsId = tempContent[i].split("=")[1];
+                        } else if (StringUtils.vagueInquiry(tempContent[i], "NURSEID=")) {//20190626
+                            nurseID = tempContent[i].split("=")[1];
+                        } else if (StringUtils.vagueInquiry(tempContent[i], "NURSENAME=")) {//20190626
+                            nurseName = tempContent[i].split("=")[1];
+                        }
+                    }
+                    LogUtil.d("ZXResult", "serverID==" + serverId+"departmentsId==" + departmentsId + "---nurseID==" + nurseID + "---nurseName==" + nurseName);
+
+                    if (StringUtils.notEmpty(serverId)&&StringUtils.notEmpty(departmentsId)) {
+                        if (NetworkUtil.checkNetworkAvailable()) {
+                            WebsocketUtil.getInstance().connect(serverId,departmentsId, nurseID);
+                            output.setText("扫描成功,正在连接中...");
+
+                            //启动蓝牙信标扫描服务
+                            final Intent intent = new Intent(this, BeaconService.class);
+                            intent.putExtra(BeaconService.SERVER_ID_KEY, serverId);
+                            intent.putExtra(BeaconService.DEPARTMENTS_ID_KEY, departmentsId);
+                            intent.putExtra(BeaconService.NURSE_ID_KEY, nurseID);
+                            intent.putExtra(BeaconService.NURSE_NAME_KEY, nurseName);
+                            startService(intent);
+                        }
+                    } else {
+                        ToastUtil.showToast(LoginActivityPhone.this, "非法二维码!");
+                        output.setText("非法二维码!");
+                    }
+                } catch (Exception e) {
+                    LogUtil.d("ZXResult", "扫描结果为:Exception");
+                    output.setText("扫描结果为:Exception");
+                }
+            }
+        }
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        NetworkUtil.checkNetworkAvailable();
+    }
+
+
+
+    @Override
+    public void onClick(View v) {
+        switch (v.getId()) {
+            case R.id.start:
+                startQT();
+                break;
+            case R.id.into_set:
+                Intent intent2 = new Intent(Settings.ACTION_SETTINGS);
+                startActivity(intent2);
+                break;
+            case R.id.view_title_left_iv:
+                LoginActivityPhone.this.finish();
+                break;
+        }
+    }
+
+    @Subscribe(threadMode = ThreadMode.MAIN)
+    public void onMoonEvent(MessageEvent messageEvent) {
+        switch (messageEvent.getType()) {
+            case Constants.EVENT_LOGIN_STATUS_MESSAGE:
+                String status = (String) messageEvent.getMessage();
+                switch (status) {
+                    case "success":
+                    case "onOpen":
+                        if (StringUtils.notEmpty(serverId)&&StringUtils.notEmpty(departmentsId)) {
+                            ToastUtil.showToast(LoginActivityPhone.this, "绑定成功!");
+                            SharedPreferencesUtil.putStringSp(SharedPreferencesUtil.LOGIN_SERVERID, serverId);
+                            SharedPreferencesUtil.putStringSp(SharedPreferencesUtil.LOGIN_DEPARTMENTSID, departmentsId);
+                            SharedPreferencesUtil.putStringSp(SharedPreferencesUtil.LOGIN_NURSE_ID, nurseID);
+                            SharedPreferencesUtil.putStringSp(SharedPreferencesUtil.LOGIN_NURSE_NAME, nurseName);
+                            Constants.IS_LOGOUT = false;
+
+                            SharedPreferencesUtil.putStringSp(SharedPreferencesUtil.LOGIN_TAG, "Login");
+
+                            startingActivity(MainActivityPhone.class);
+
+                            LoginActivityPhone.this.finish();
+
+                        } else {
+                            ToastUtil.showToast(LoginActivityPhone.this, "失败请重新扫描!");
+                            output.setText("失败,请重新扫描!");
+                        }
+                        break;
+                    case "onClosing":
+                    case "onFailure":
+                        ToastUtil.showToast(LoginActivityPhone.this, "连接失败,请重新扫描!");
+                        output.setText("连接失败,请重新扫描!");
+                        break;
+                }
+
+                break;
+        }
+
+
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+    }
+}

+ 332 - 0
app/src/main/java/com/wdkl/nursewatch/presentation/ui/activitiesphone/MainActivityPhone.java

@@ -0,0 +1,332 @@
+package com.wdkl.nursewatch.presentation.ui.activitiesphone;
+
+import android.content.Intent;
+import android.support.v4.widget.SwipeRefreshLayout;
+import android.support.v7.widget.LinearLayoutManager;
+import android.util.Log;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.jude.easyrecyclerview.EasyRecyclerView;
+import com.wdkl.nursewatch.MyApplication;
+import com.wdkl.nursewatch.R;
+import com.wdkl.nursewatch.adapters.HistoryCallAdapterPhone;
+import com.wdkl.nursewatch.common.Constants;
+import com.wdkl.nursewatch.entity.MessageEntity;
+import com.wdkl.nursewatch.entity.MessageEvent;
+import com.wdkl.nursewatch.presentation.ui.base.BaseActivity;
+import com.wdkl.nursewatch.service.BeaconService;
+import com.wdkl.nursewatch.utils.LogUtil;
+import com.wdkl.nursewatch.utils.NetworkUtil;
+import com.wdkl.nursewatch.utils.PalyPhonetics;
+import com.wdkl.nursewatch.utils.SaveCallListUtil;
+import com.wdkl.nursewatch.utils.SharedPreferencesUtil;
+import com.wdkl.nursewatch.utils.StringUtils;
+import com.wdkl.nursewatch.utils.WebsocketUtil;
+
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+import java.util.List;
+
+import butterknife.Bind;
+
+
+public class MainActivityPhone extends BaseActivity implements View.OnClickListener, HistoryCallAdapterPhone.AdapterOnClickListener, SwipeRefreshLayout.OnRefreshListener {
+
+    @Bind(R.id.ecl_history_recyclerview)
+    EasyRecyclerView ecl_history_recyclerview;
+    @Bind(R.id.view_title_left_tv)
+    TextView titleLeftText;
+    @Bind(R.id.view_title_right_tv)
+    TextView titleRightText;
+    @Bind(R.id.view_title_layout_tv_time)
+    TextView titleText;
+    @Bind(R.id.view_title_left_iv)
+    ImageView leftImageView;
+    @Bind(R.id.view_title_right_iv)
+    ImageView rightImageView;
+
+    HistoryCallAdapterPhone adapter;
+    List<MessageEntity> callList;
+    String departmentsId = "";
+    public int dialogType = -1;
+
+    @Override
+    public int getLayoutId() {
+        return R.layout.activity_main_phone;
+    }
+
+    @Override
+    protected void initView() {
+        titleText.setText("当前呼叫");
+        titleRightText.setText("清除");
+        leftImageView.setImageResource(R.drawable.img_back_white);
+        rightImageView.setImageResource(R.drawable.img_white_more);
+        titleRightText.setOnClickListener(this);
+        leftImageView.setOnClickListener(this);
+        rightImageView.setOnClickListener(this);
+    }
+
+    @Override
+    protected void initData() {
+        adapter = new HistoryCallAdapterPhone(this);
+        LinearLayoutManager linearLayoutDutyNurse = new LinearLayoutManager(this);
+        linearLayoutDutyNurse.setOrientation(LinearLayoutManager.VERTICAL);
+        ecl_history_recyclerview.setLayoutManager(linearLayoutDutyNurse);
+        ecl_history_recyclerview.setAdapter(adapter);
+        adapter.setAdapterOnClickListener(this);
+        ecl_history_recyclerview.setRefreshing(false);
+
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        NetworkUtil.checkNetworkAvailable();
+        refreshCallList();
+        String serverId = SharedPreferencesUtil.getStringSp(SharedPreferencesUtil.LOGIN_SERVERID);
+        departmentsId = SharedPreferencesUtil.getStringSp(SharedPreferencesUtil.LOGIN_DEPARTMENTSID);
+        String nurseID = SharedPreferencesUtil.getStringSp(SharedPreferencesUtil.LOGIN_NURSE_ID);
+        String nurseName = SharedPreferencesUtil.getStringSp(SharedPreferencesUtil.LOGIN_NURSE_NAME);
+
+        if (StringUtils.notEmpty(departmentsId) && WebsocketUtil.WEBSOCKET_STATE != WebsocketUtil.WEBSOCKET_SUCCESS) {
+            WebsocketUtil.connectWS();
+        }
+        //启动蓝牙信标扫描服务
+        final Intent intent = new Intent(this, BeaconService.class);
+        intent.putExtra(BeaconService.SERVER_ID_KEY, serverId);
+        intent.putExtra(BeaconService.DEPARTMENTS_ID_KEY, departmentsId);
+        intent.putExtra(BeaconService.NURSE_ID_KEY, nurseID);
+        intent.putExtra(BeaconService.NURSE_NAME_KEY, nurseName);
+        startService(intent);
+
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+    }
+
+    @Subscribe(threadMode = ThreadMode.MAIN)
+    public void onMoonEvent(MessageEvent messageEvent) {
+        switch (messageEvent.getType()) {
+            case Constants.EVENT_NEW_UDPDATA:
+                MessageEntity messageEntityNewUdpdata = (MessageEntity) messageEvent.getMessage();
+                LogUtil.d(TAG, "onMoonEvent 收到信息:getMachineID==" + messageEntityNewUdpdata.getMachineID());
+                refreshCallList();
+
+                break;
+        }
+    }
+
+    public void refreshCallList() {
+        callList = SaveCallListUtil.getCallList();
+
+        if (StringUtils.listNotEmpty(callList)) {
+            titleLeftText.setText(callList.size() + "");
+        } else {
+            titleLeftText.setText("0");
+        }
+        if (StringUtils.listNotEmpty(callList)) {
+            adapter.clear();
+            adapter.addAll(callList);
+        } else {
+            adapter.clear();
+        }
+    }
+
+    @Override
+    public void onRefresh() {
+        ecl_history_recyclerview.setRefreshing(false);
+        refreshCallList();
+    }
+
+    @Override
+    public void onClick(View v) {
+        switch (v.getId()) {
+            case R.id.view_title_right_tv:
+                dialogType = 1;
+                showDialog(MainActivityPhone.this, "温馨提示", "清除所有的呼叫记录吗?", "取消", "确定");
+                break;
+            case R.id.view_title_right_iv:
+                startingActivity(SettingActivityPhone.class);//去设置页面
+                break;
+            case R.id.view_title_left_iv:
+                MainActivityPhone.this.finish();
+                break;
+        }
+    }
+
+    @Override
+    public void onClickButtonTwo() {
+        super.onClickButtonTwo();
+        try {
+            if (dialogType == 1) {//清除所有的呼叫记录
+                callList = null;
+                SaveCallListUtil.deleteAllEntity();
+                SaveCallListUtil.deleteAllEntityNow();
+                PalyPhonetics.setPalyDismiss(true);
+                MyApplication.speakEntityList.clear();
+                refreshCallList();
+            } else if (dialogType == 2) {
+                if (null == messageEntity) return;
+                SaveCallListUtil.deleteCallEntityNow(messageEntity);
+                SaveCallListUtil.deleteCallEntity(messageEntity);
+
+                if (PalyPhonetics.thisEntityIsSpeaking(messageEntity)) {
+                    PalyPhonetics.setPalyDismiss(true);
+                }
+                PalyPhonetics.deleteCallEntity(messageEntity);
+                refreshCallList();
+            }
+        } catch (Exception e) {
+
+        }
+    }
+
+    MessageEntity messageEntity;
+
+    @Override
+    public void adapterOnClick(View view, MessageEntity messageEntity) {
+        try {
+            this.messageEntity = messageEntity;
+            switch (view.getId()) {
+                case R.id.delete_button:
+                    dialogType = 2;
+                    showDialog(MainActivityPhone.this, "温馨提示", "删除该条呼叫记录吗?", "取消", "确定");
+                    break;
+                case R.id.handle_button:
+                    if (null == messageEntity) return;
+                    String serverId = SharedPreferencesUtil.getStringSp(SharedPreferencesUtil.LOGIN_SERVERID);
+                    String machineId = SharedPreferencesUtil.getStringSp(SharedPreferencesUtil.LOGIN_DEPARTMENTSID);
+//                    String cancelUdpCall = "{\"DeviceType\":\"2\",\"MachineID\":"
+//                            + "\"" + machineId + "\""
+//                            + ",\"UDPData\":" +
+//                            "\"$call_8_upremove|"
+//                            + messageEntity.getDataOne() +
+//                            "|" +
+//                            messageEntity.getDataTwo() +
+//                            "|" +
+//                            messageEntity.getDataThree() +
+//                           "|" +
+//                            messageEntity.getDataFour() +
+//                            "|" +
+//                            messageEntity.getDataFive() +
+//                            "|" +
+//                            messageEntity.getDataSix() +
+//                            "|" +
+//                            messageEntity.getDataSeven() +
+//                            "|" +
+//                            messageEntity.getDataEight() +
+//                            "|" +
+//                            messageEntity.getDataNine() +
+//                            "|" +
+//                            messageEntity.getDataTen() +
+//                            "#\"}";
+
+//                    Log.e("MainActivityPhone","serverId "+serverId+" machineId "+machineId);
+//                    serverId = "\"7155458a-c2c2-485c-b6f3-9c5aba3b1bd3\"";
+//                    machineId = "1";
+
+                    String cancelUdpCall = "{\"serverSystemId\":"+ "\""+serverId+"\"" +
+                            ",\"msgData\": " +
+                            "{\"type\":" + "2" +
+                            ",\"msgData\": " +
+                            "{\"partId\":" + "\""+machineId+"\"" +
+                            ",\"udpStr\":" +
+                            "\"$call_1_hang_up"+Character.toString((char) 3)
+                            + messageEntity.getDataOne() +
+                            Character.toString((char) 3) +
+                            messageEntity.getDataTwo() +
+                            Character.toString((char) 3) +
+                            messageEntity.getDataThree() +
+                            Character.toString((char) 3) +
+                            messageEntity.getDataFour() +
+                            Character.toString((char) 3) +
+                            messageEntity.getDataFive() +
+                            Character.toString((char) 3) +
+                            messageEntity.getDataSix() +
+                            Character.toString((char) 3) +
+                            messageEntity.getDataSeven() +
+                            Character.toString((char) 3) +
+                            messageEntity.getDataEight() +
+                            Character.toString((char) 3) +
+                            messageEntity.getDataNine() +
+                            Character.toString((char) 3) +
+                            messageEntity.getDataTen() +
+                            Character.toString((char) 3) +
+                            "1"+
+                            "#\"}"+
+                            "}"+
+                            "}";
+
+
+//                    String cancelUdpCall = "{\"serverSystemId\":"+ serverId +
+//                            ",\"msgData\": " +
+//                            "{\"type\":" + "2" +
+//                            ",\"msgData\": " +
+//                            "{\"partId\":" + machineId +
+//                            ",\"udpStr\":" +
+//                            "\"$call_1_hang_up"+Character.toString((char) 3)+
+//                            "1wewewewewewewee"+
+//                            "#\"}"+
+//                            "}"+
+//                            "}";
+
+
+//                    String ss =  "{"+"\"serverSystemId\": \"48041\"," +
+//                        "\"msgData\": " +
+//                        "{\"partId\": \"100\"," +
+//                        "\"udpStr\": \"udpStr\"}" +
+//                        "}";
+
+
+                    Log.e("MainActivityPhone","cancelUdpCall "+cancelUdpCall);
+                    WebsocketUtil.getInstance().getWebSocket().send(cancelUdpCall);
+
+
+//                    String noany_request = "{\"systemId\":"+serverId+
+//                            "\"UDPData\":" +
+//                            "\"$call_8_upremove"+Character.toString((char) 3)
+//                            + messageEntity.getDataOne() +
+//                            Character.toString((char) 3) +
+//                            messageEntity.getDataTwo() +
+//                            Character.toString((char) 3) +
+//                            messageEntity.getDataThree() +
+//                            Character.toString((char) 3) +
+//                            messageEntity.getDataFour() +
+//                            Character.toString((char) 3) +
+//                            messageEntity.getDataFive() +
+//                            Character.toString((char) 3) +
+//                            messageEntity.getDataSix() +
+//                            Character.toString((char) 3) +
+//                            messageEntity.getDataSeven() +
+//                            Character.toString((char) 3) +
+//                            messageEntity.getDataEight() +
+//                            Character.toString((char) 3) +
+//                            messageEntity.getDataNine() +
+//                            Character.toString((char) 3) +
+//                            messageEntity.getDataTen() +
+//                            "#\"}";
+
+//                    WebsocketUtil.getInstance().getWebSocket().send(noany_request);
+
+                    SaveCallListUtil.deleteCallEntityNow(messageEntity);
+                    SaveCallListUtil.deleteCallEntity(messageEntity);
+
+                    if (PalyPhonetics.thisEntityIsSpeaking(messageEntity)) {
+                        PalyPhonetics.setPalyDismiss(true);
+                    }
+                    PalyPhonetics.deleteCallEntity(messageEntity);
+                    refreshCallList();
+                    break;
+            }
+        } catch (Exception e) {
+
+        }
+    }
+
+
+}

+ 202 - 0
app/src/main/java/com/wdkl/nursewatch/presentation/ui/activitiesphone/SettingActivityPhone.java

@@ -0,0 +1,202 @@
+package com.wdkl.nursewatch.presentation.ui.activitiesphone;
+
+import android.content.Intent;
+import android.provider.Settings;
+import android.view.View;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.RadioButton;
+import android.widget.RadioGroup;
+import android.widget.TextView;
+
+import com.wdkl.nursewatch.MyApplication;
+import com.wdkl.nursewatch.R;
+import com.wdkl.nursewatch.common.Constants;
+import com.wdkl.nursewatch.entity.MessageEvent;
+import com.wdkl.nursewatch.presentation.ui.base.BaseActivity;
+import com.wdkl.nursewatch.utils.NetworkUtil;
+import com.wdkl.nursewatch.utils.PalyPhonetics;
+import com.wdkl.nursewatch.utils.SaveCallListUtil;
+import com.wdkl.nursewatch.utils.SharedPreferencesUtil;
+import com.wdkl.nursewatch.utils.StringUtils;
+import com.wdkl.nursewatch.utils.ToastUtil;
+import com.wdkl.nursewatch.utils.WebsocketUtil;
+
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+import butterknife.Bind;
+
+public class SettingActivityPhone extends BaseActivity implements View.OnClickListener {
+
+    @Bind(R.id.view_title_left_tv)
+    TextView titleLeftText;
+    @Bind(R.id.view_title_right_tv)
+    TextView titleRightText;
+    @Bind(R.id.view_title_layout_tv_time)
+    TextView titleText;
+    @Bind(R.id.view_title_left_iv)
+    ImageView leftImageView;
+    @Bind(R.id.view_title_right_iv)
+    ImageView rightImageView;
+
+    @Bind(R.id.rg_setting_rong)
+    RadioGroup rg_setting_rong;
+    @Bind(R.id.rg_setting_shake)
+    RadioGroup rg_setting_shake;
+    @Bind(R.id.rg_setting_roomnum)
+    RadioGroup rg_setting_roomnum;
+
+    @Bind(R.id.rg_setting_rong_one)
+    RadioButton rg_setting_rong_one;
+    @Bind(R.id.rg_setting_rong_two)
+    RadioButton rg_setting_rong_two;
+    @Bind(R.id.rg_setting_roomnum_one)
+    RadioButton rg_setting_roomnum_one;
+    @Bind(R.id.rg_setting_roomnum_two)
+    RadioButton rg_setting_roomnum_two;
+    @Bind(R.id.rg_setting_shake_one)
+    RadioButton rg_setting_shake_one;
+    @Bind(R.id.rg_setting_shake_two)
+    RadioButton rg_setting_shake_two;
+
+
+    @Bind(R.id.name_version)
+    TextView name_version;
+    @Bind(R.id.unbind_button)
+    Button unbind;
+    @Bind(R.id.into_set)
+    Button into_set;
+
+    @Override
+    public int getLayoutId() {
+        return R.layout.activity_setting_phone;
+    }
+
+    @Override
+    protected void initView() {
+
+        titleText.setText("系统设置");
+        leftImageView.setImageResource(R.drawable.img_back_white);
+        leftImageView.setOnClickListener(this);
+        unbind.setOnClickListener(this);
+        into_set.setOnClickListener(this);
+
+        rg_setting_rong.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
+            @Override
+            public void onCheckedChanged(RadioGroup group, int checkedId) {
+                if (checkedId == R.id.rg_setting_rong_one) {
+                    MyApplication.IS_HAVE_SPEAK = true;
+                    SharedPreferencesUtil.putBooleanSp(SharedPreferencesUtil.SETTING_VOICE_BROADCAST, true);
+                } else {
+                    MyApplication.IS_HAVE_SPEAK = false;
+                    SharedPreferencesUtil.putBooleanSp(SharedPreferencesUtil.SETTING_VOICE_BROADCAST, false);
+                }
+            }
+        });
+        rg_setting_roomnum.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
+            @Override
+            public void onCheckedChanged(RadioGroup group, int checkedId) {
+                if (checkedId == R.id.rg_setting_roomnum_one) {
+                    SharedPreferencesUtil.putBooleanSp(SharedPreferencesUtil.SETTING_BROADCASTING_ROOM_NUMBER, true);
+                } else {
+                    SharedPreferencesUtil.putBooleanSp(SharedPreferencesUtil.SETTING_BROADCASTING_ROOM_NUMBER, false);
+                }
+            }
+        });
+        rg_setting_shake.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
+            @Override
+            public void onCheckedChanged(RadioGroup group, int checkedId) {
+                if (checkedId == R.id.rg_setting_shake_one) {
+                    SharedPreferencesUtil.putBooleanSp(SharedPreferencesUtil.SETTING_SHAKE, true);
+                } else {
+                    SharedPreferencesUtil.putBooleanSp(SharedPreferencesUtil.SETTING_SHAKE, false);
+                }
+            }
+        });
+
+    }
+
+    @Override
+    protected void initData() {
+
+        name_version.setText("当前用户:"+ SharedPreferencesUtil.getStringSp(SharedPreferencesUtil.LOGIN_NURSE_NAME)+ "\r\n当前版本:V" + StringUtils.getAppVersionName(this));
+        boolean isRong = SharedPreferencesUtil.getBooleanSp(SharedPreferencesUtil.SETTING_VOICE_BROADCAST);
+        boolean isRoom = SharedPreferencesUtil.getBooleanSp(SharedPreferencesUtil.SETTING_BROADCASTING_ROOM_NUMBER);
+        boolean isShake = SharedPreferencesUtil.getBooleanSp(SharedPreferencesUtil.SETTING_SHAKE);
+
+        if (isRong) {
+            rg_setting_rong_one.setChecked(true);
+        } else {
+            rg_setting_rong_two.setChecked(true);
+        }
+        if (isRoom) {
+            rg_setting_roomnum_one.setChecked(true);
+        } else {
+            rg_setting_roomnum_two.setChecked(true);
+        }
+        if (isShake) {
+            rg_setting_shake_one.setChecked(true);
+        } else {
+            rg_setting_shake_two.setChecked(true);
+        }
+    }
+
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        NetworkUtil.checkNetworkAvailable();
+    }
+
+
+
+    @Override
+    public void onClick(View v) {
+        switch (v.getId()) {
+            case R.id.view_title_left_iv:
+                SettingActivityPhone.this.finish();
+                break;
+            case R.id.unbind_button:
+                showDialog(SettingActivityPhone.this, "温馨提示", "解绑当前护士站吗?", "取消", "确定");
+                break;
+            case R.id.into_set:
+                Intent intent2 = new Intent(Settings.ACTION_SETTINGS);
+                startActivity(intent2);
+                break;
+        }
+    }
+
+    @Override
+    public void onClickButtonTwo() {
+        try {
+            SharedPreferencesUtil.putStringSp(SharedPreferencesUtil.LOGIN_SERVERID, "");
+            SharedPreferencesUtil.putStringSp(SharedPreferencesUtil.LOGIN_DEPARTMENTSID, "");
+            SharedPreferencesUtil.putStringSp(SharedPreferencesUtil.LOGIN_NURSE_ID, "");
+            SharedPreferencesUtil.putStringSp(SharedPreferencesUtil.LOGIN_NURSE_NAME, "");
+            Intent intent = new Intent(this, LoginActivityPhone.class);
+            startActivity(intent);
+            Constants.IS_LOGOUT = true;
+            WebsocketUtil.getInstance().getWebSocket().cancel();
+            PalyPhonetics.setPalyDismiss(true);
+            MyApplication.speakEntityList.clear();
+            SaveCallListUtil.deleteAllEntity();
+            SaveCallListUtil.deleteAllEntityNow();
+            ToastUtil.showToast(this, "解绑成功,请重新绑定");
+            WebsocketUtil.WEBSOCKET_STATE = WebsocketUtil.WEBSOCKET_ONCLOSED;
+            finish();
+        } catch (Exception e) {
+        }
+    }
+
+
+    @Subscribe(threadMode = ThreadMode.MAIN)
+    public void onMoonEvent(MessageEvent messageEvent) {
+//        switch (messageEvent.getType()) {
+//        }
+    }
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+    }
+}

+ 214 - 0
app/src/main/java/com/wdkl/nursewatch/presentation/ui/base/BaseActivity.java

@@ -0,0 +1,214 @@
+package com.wdkl.nursewatch.presentation.ui.base;
+
+import android.app.ProgressDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.res.Configuration;
+import android.os.Build;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.annotation.RequiresApi;
+import android.support.v7.app.AppCompatActivity;
+import android.util.DisplayMetrics;
+import android.view.MotionEvent;
+
+import com.wdkl.nursewatch.MyApplication;
+import com.wdkl.nursewatch.utils.LogUtil;
+import com.wdkl.nursewatch.utils.PhoneUtils;
+
+import org.greenrobot.eventbus.EventBus;
+
+import butterknife.ButterKnife;
+
+
+public abstract class BaseActivity extends AppCompatActivity {
+
+    public String TAG = "";
+
+    static ProgressDialog circledialog = null;
+
+    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        onFirstStart();
+        setStatusBar();
+
+        setContentView(getLayoutId());
+
+        TAG = this.getClass().getSimpleName();
+        ButterKnife.bind(this);
+
+        initView();
+        initData();
+    }
+
+    public void onFirstStart() {
+
+    }
+
+    public void setStatusBar() {
+
+    }
+
+    /**
+     * Base基本类
+     */
+    public abstract int getLayoutId();
+
+    /**
+     * 设置initView
+     */
+    protected abstract void initView();
+
+    protected abstract void initData();
+
+    @Override
+    protected void onStart() {
+        EventBus.getDefault().register(this);
+        super.onStart();
+    }
+
+    @Override
+    protected void onStop() {
+        EventBus.getDefault().unregister(this);
+        super.onStop();
+    }
+
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        ButterKnife.unbind(this);
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+    }
+
+    @Override
+    public void onPause() {
+        super.onPause();
+    }
+
+    @Override
+    public boolean dispatchTouchEvent(MotionEvent ev) {
+        return super.dispatchTouchEvent(ev);
+    }
+
+    @Override
+    public boolean onTouchEvent(MotionEvent event) {
+        return false;
+    }
+
+    public void startingActivitys(Class<?> toclass, String key, int value) {
+        Intent intent = new Intent(this, toclass);
+        intent.putExtra(key, value);
+        startActivity(intent);
+
+    }
+
+    public void startingActivitys(Class<?> toclass, String key, String value) {
+        Intent intent = new Intent(this, toclass);
+        intent.putExtra(key, value);
+        startActivity(intent);
+    }
+
+    public void startingActivitys(Class<?> toclass, String key1, String value1, String
+            key2, String value2) {
+        Intent intent = new Intent(this, toclass);
+        intent.putExtra(key1, value1);
+        intent.putExtra(key2, value2);
+        startActivity(intent);
+    }
+
+    public void startingActivity(Class<?> toclass) {
+        Intent intent = new Intent(this, toclass);
+        startActivity(intent);
+    }
+
+    /**
+     * 弹出一个圆圈提示加载Dialog
+     */
+    public static void showCircleDialog(Context context, String message) {
+        try {
+            if (circledialog != null) {
+                circledialog.cancel();
+            }
+            circledialog = new ProgressDialog(context,
+                    ProgressDialog.THEME_HOLO_LIGHT);
+            circledialog.setMessage(message);
+            circledialog.setCanceledOnTouchOutside(false);
+            circledialog.setCancelable(true);
+            // 设置进度条是否不明确
+            circledialog.setIndeterminate(false);
+            circledialog.show();
+        } catch (Exception e) {
+
+        }
+    }
+
+    public static void DissmissCircleDialog() {
+        if (circledialog != null) {
+            circledialog.dismiss();
+        }
+    }
+
+    public static void CancelCircleDialog() {
+        if (circledialog != null) {
+            circledialog.cancel();
+        }
+    }
+
+    android.support.v7.app.AlertDialog.Builder builder;
+
+    public void showDialog(Context context, String title, String message, String button_t1, String button_t2) {
+        if (null == builder)
+            builder = new android.support.v7.app.AlertDialog.Builder(context);
+
+        builder.setTitle(title);
+        builder.setMessage(message);
+        builder.setPositiveButton(button_t1, new DialogInterface.OnClickListener() {
+            @Override
+            public void onClick(DialogInterface dialog, int which) {
+                onClickButtonOne();
+            }
+        });
+        builder.setNegativeButton(button_t2, new DialogInterface.OnClickListener() {
+            @Override
+            public void onClick(DialogInterface dialog, int which) {
+                onClickButtonTwo();
+            }
+        });
+        builder.show();
+    }
+
+    public void onClickButtonOne() {
+    }
+
+    public void onClickButtonTwo() {
+    }
+
+
+    /**
+     * 判断当前设备是手机还是平板
+     *
+     * @return 平板返回 True,手机返回 False
+     */
+    public boolean isPad() {
+        return PhoneUtils.isPad(MyApplication.getAppContext());
+    }
+
+    /**
+     * 判断当前设备是不是腕表
+     *
+     * @return 腕表返回 True,否则返回 False
+     */
+    public boolean isWatch() {
+        return PhoneUtils.isWatch(MyApplication.getAppContext());
+    }
+
+
+}

+ 137 - 0
app/src/main/java/com/wdkl/nursewatch/presentation/ui/base/BaseFragment.java

@@ -0,0 +1,137 @@
+package com.wdkl.nursewatch.presentation.ui.base;
+
+import android.app.ProgressDialog;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+public abstract class BaseFragment extends Fragment {
+
+    public String TAG = "";
+
+    static ProgressDialog circledialog = null;
+
+    public View mView;
+
+    @Nullable
+    @Override
+    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+        onFirstStart();
+        mView = inflater.inflate(getLayoutId(), null);
+        TAG = this.getClass().getSimpleName();
+        setStatusBar();
+        initView();
+        initData();
+        return mView;
+    }
+
+
+    public void onFirstStart() {
+
+    }
+
+    public void setStatusBar() {
+
+    }
+
+    /**
+     * Base基本类
+     */
+    public abstract int getLayoutId();
+
+    /**
+     * 设置initView
+     */
+    protected abstract void initView();
+
+    protected abstract void initData();
+
+    @Override
+    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
+        super.onActivityCreated(savedInstanceState);
+    }
+
+    @Override
+    public void onStart() {
+        super.onStart();
+    }
+
+    @Override
+    public void onResume() {
+        super.onResume();
+    }
+
+    @Override
+    public void onStop() {
+        super.onStop();
+    }
+
+    @Override
+    public void onDestroy() {
+        super.onDestroy();
+    }
+    public void startingActivitys(Class<?> toclass, String key, int value) {
+        Intent intent = new Intent(getActivity(), toclass);
+        intent.putExtra(key, value);
+        startActivity(intent);
+
+    }
+
+    public void startingActivitys(Class<?> toclass, String key, String value) {
+        Intent intent = new Intent(getActivity(), toclass);
+        intent.putExtra(key, value);
+        startActivity(intent);
+    }
+
+    public void startingActivitys(Class<?> toclass, String key1, String value1, String
+            key2, String value2) {
+        Intent intent = new Intent(getActivity(), toclass);
+        intent.putExtra(key1, value1);
+        intent.putExtra(key2, value2);
+        startActivity(intent);
+    }
+
+    public void startingActivity(Class<?> toclass) {
+        Intent intent = new Intent(getActivity(), toclass);
+        startActivity(intent);
+    }
+
+    /**
+     * 弹出一个圆圈提示加载Dialog
+     */
+    public static void showCircleDialog(Context context, String message) {
+        try {
+            if (circledialog != null) {
+                circledialog.cancel();
+            }
+            circledialog = new ProgressDialog(context,
+                    ProgressDialog.THEME_HOLO_LIGHT);
+            circledialog.setMessage(message);
+            circledialog.setCanceledOnTouchOutside(false);
+            circledialog.setCancelable(true);
+            // 设置进度条是否不明确
+            circledialog.setIndeterminate(false);
+            circledialog.show();
+        } catch (Exception e) {
+
+        }
+    }
+
+    public static void DissmissCircleDialog() {
+        if (circledialog != null) {
+            circledialog.dismiss();
+        }
+    }
+
+    public static void CancelCircleDialog() {
+        if (circledialog != null) {
+            circledialog.cancel();
+        }
+    }
+
+}

+ 77 - 0
app/src/main/java/com/wdkl/nursewatch/presentation/ui/views/BatteryView.java

@@ -0,0 +1,77 @@
+package com.wdkl.nursewatch.presentation.ui.views;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Rect;
+import android.util.AttributeSet;
+import android.view.View;
+
+public class BatteryView extends View {
+
+    private int mPower = 100;
+
+    public BatteryView(Context context) {
+        super(context);
+    }
+
+    public BatteryView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+    @Override
+    protected void onDraw(Canvas canvas) {
+        super.onDraw(canvas);
+
+        int battery_left = 0;
+        int battery_top = 0;
+        int battery_width = 25;
+        int battery_height = 15;
+
+        int battery_head_width = 3;
+        int battery_head_height = 3;
+
+        int battery_inside_margin = 3;
+
+        //先画外框
+        Paint paint = new Paint();
+        paint.setColor(Color.WHITE);
+        paint.setAntiAlias(true);
+        paint.setStyle(Paint.Style.STROKE);
+
+        Rect rect = new Rect(battery_left, battery_top,
+                battery_left + battery_width, battery_top + battery_height);
+        canvas.drawRect(rect, paint);
+
+        float power_percent = mPower / 100.0f;
+
+        Paint paint2 = new Paint(paint);
+        paint2.setStyle(Paint.Style.FILL);
+        //画电量
+        if (power_percent != 0) {
+            int p_left = battery_left + battery_inside_margin;
+            int p_top = battery_top + battery_inside_margin;
+            int p_right = p_left - battery_inside_margin + (int) ((battery_width - battery_inside_margin) * power_percent);
+            int p_bottom = p_top + battery_height - battery_inside_margin * 2;
+            Rect rect2 = new Rect(p_left, p_top, p_right, p_bottom);
+            canvas.drawRect(rect2, paint2);
+        }
+
+        //画电池头
+        int h_left = battery_left + battery_width;
+        int h_top = battery_top + battery_height / 2 - battery_head_height / 2;
+        int h_right = h_left + battery_head_width;
+        int h_bottom = h_top + battery_head_height;
+        Rect rect3 = new Rect(h_left, h_top, h_right, h_bottom);
+        canvas.drawRect(rect3, paint2);
+    }
+
+    public void setPower(int power) {
+        mPower = power;
+        if (mPower < 0) {
+            mPower = 0;
+        }
+        invalidate();
+    }
+}

+ 30 - 0
app/src/main/java/com/wdkl/nursewatch/presentation/ui/views/MarqueeText.java

@@ -0,0 +1,30 @@
+package com.wdkl.nursewatch.presentation.ui.views;
+
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.TextView;
+
+/**
+ * 轮播TextView
+ */
+@SuppressLint("AppCompatCustomView")
+public class MarqueeText extends TextView {
+    public MarqueeText(Context context) {
+        super(context);
+    }
+
+    @Override//实现了都获取焦点
+    public boolean isFocused() {
+        return true;
+    }
+
+    public MarqueeText(Context context, AttributeSet attrs, int defStyleAttr) {
+        super(context, attrs, defStyleAttr);
+    }
+
+    public MarqueeText(Context context, AttributeSet attrs) {
+        super(context, attrs);
+    }
+}

+ 61 - 0
app/src/main/java/com/wdkl/nursewatch/presentation/ui/views/XWEasyRecyclerView.java

@@ -0,0 +1,61 @@
+package com.wdkl.nursewatch.presentation.ui.views;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+
+import com.jude.easyrecyclerview.EasyRecyclerView;
+
+public class XWEasyRecyclerView extends EasyRecyclerView {
+
+    public XWEasyRecyclerView(Context context) {
+        super(context);
+    }
+
+    public XWEasyRecyclerView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+    public XWEasyRecyclerView(Context context, AttributeSet attrs, int defStyle) {
+        super(context, attrs, defStyle);
+    }
+
+    @Override
+    public boolean onTouchEvent(MotionEvent ev) {
+        return super.onTouchEvent(ev);
+    }
+
+    float x, y, xNow, yNow;
+
+    @Override
+    public boolean dispatchTouchEvent(MotionEvent ev) {
+
+        switch (ev.getAction()) {
+            case MotionEvent.ACTION_DOWN:
+                x = ev.getRawX();
+                y = ev.getRawY();
+                break;
+            case MotionEvent.ACTION_MOVE:
+                xNow = ev.getRawX();
+                yNow = ev.getRawY();
+                float x_abs = Math.abs(xNow - x);
+                float y_abs = Math.abs(yNow - y);
+                if (y_abs > 70) {
+                    return true;
+                }
+
+                break;
+            case MotionEvent.ACTION_UP:
+
+                break;
+        }
+        return super.dispatchTouchEvent(ev);
+
+    }
+
+    @Override
+    public boolean onInterceptTouchEvent(MotionEvent ev) {
+        return super.onInterceptTouchEvent(ev);
+    }
+
+}

+ 93 - 0
app/src/main/java/com/wdkl/nursewatch/service/APPService.java

@@ -0,0 +1,93 @@
+package com.wdkl.nursewatch.service;
+
+import android.app.Notification;
+import android.app.Service;
+import android.content.Intent;
+import android.os.Binder;
+import android.os.IBinder;
+import android.support.annotation.Nullable;
+
+import com.wdkl.nursewatch.utils.LogUtil;
+import com.wdkl.nursewatch.utils.SharedPreferencesUtil;
+import com.wdkl.nursewatch.utils.WebsocketUtil;
+
+import java.util.Timer;
+import java.util.TimerTask;
+
+public class APPService extends Service {
+
+    private String TAG = APPService.class.getSimpleName();
+    ServiceBinder myBinder = new ServiceBinder();
+
+    @Override
+
+    public void onCreate() {
+        super.onCreate();
+//        checkStatus();
+//        connectWebsocket();
+    }
+
+    @Override
+    public int onStartCommand(Intent intent, int flags, int startId) {
+        startForeground(110, new Notification());//开前台服务
+        return START_STICKY;//当服务被异常终止时,重启服务
+    }
+
+    @Nullable
+    @Override
+    public IBinder onBind(Intent intent) {
+        return myBinder;
+    }
+
+    public Timer timer;
+    public TimerTask timerTask;
+
+    private void checkStatus() {
+        if (timer != null) timer.purge();
+        if (timerTask != null) timerTask.cancel();
+        timer = new Timer();
+        timerTask = new TimerTask() {
+            @Override
+            public void run() {
+                try {
+                    String loginMachineId = SharedPreferencesUtil.getStringSp(SharedPreferencesUtil.LOGIN_DEPARTMENTSID);
+                    String message = "{\"type\":\"pong\",\"MachineID\":" + "\"" + loginMachineId + "\"" + ",\"DeviceType\":\"2\"}";
+                    LogUtil.d(TAG, "message==" + message);
+                    WebsocketUtil.getInstance().getWebSocket().send(message);
+                    LogUtil.d(TAG, "1_send_ok");
+                } catch (Exception e) {
+                    LogUtil.d(TAG, "WebSocket Send Message Was Exception");
+                }
+            }
+        };
+        timer.schedule(timerTask, 0, 30000);
+    }
+
+    public Timer timer2;
+    public TimerTask timerTask2;
+
+    private void connectWebsocket() {
+        if (timer2 != null) timer2.purge();
+        if (timerTask2 != null) timerTask2.cancel();
+        timer2 = new Timer();
+        timerTask2 = new TimerTask() {
+            @Override
+            public void run() {
+                WebsocketUtil.connectWS();//定时检测Websocket;如有断开;及时联接
+            }
+        };
+        timer2.schedule(timerTask2, 8000, 5000);
+
+    }
+
+    @Override
+    public void onDestroy() {
+        super.onDestroy();
+        stopForeground(true);// 停止前台服务--参数:表示是否移除之前的通知
+    }
+
+    public class ServiceBinder extends Binder {
+        public void doThings() {
+        }
+    }
+}

+ 333 - 0
app/src/main/java/com/wdkl/nursewatch/service/BeaconService.java

@@ -0,0 +1,333 @@
+package com.wdkl.nursewatch.service;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.Binder;
+import android.os.Build;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.support.annotation.Nullable;
+import android.util.Log;
+
+import androidx.annotation.RequiresApi;
+
+import com.wdkl.nursewatch.entity.BluetoothDataEntity;
+import com.wdkl.nursewatch.utils.StringUtils;
+
+import org.altbeacon.beacon.Beacon;
+import org.altbeacon.beacon.BeaconConsumer;
+import org.altbeacon.beacon.BeaconManager;
+import org.altbeacon.beacon.BeaconParser;
+import org.altbeacon.beacon.RangeNotifier;
+import org.altbeacon.beacon.Region;
+//import org.jetbrains.annotations.NotNull;
+import org.json.JSONArray;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+import okhttp3.MediaType;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.RequestBody;
+
+import static java.util.Comparator.comparing;
+
+
+public class BeaconService extends Service implements BeaconConsumer, RangeNotifier {
+
+    private static final String TAG = "BeaconService";
+    public static final String SERVER_ID_KEY = BeaconService.class.getName() + ".SERVER_ID_KEY";
+    public static final String DEPARTMENTS_ID_KEY = BeaconService.class.getName() + ".DEPARTMENTS_ID_KEY";
+    public static final String NURSE_ID_KEY = BeaconService.class.getName() + ".NURSE_ID_KEY";
+    public static final String NURSE_NAME_KEY = BeaconService.class.getName() + ".NURSE_NAME_KEY";
+
+//    private static final String UPDATE_BEACON_INFO_URL = "http://id.wdklian.com:10018/api/Beacon/UpdateBeaconPosition";
+    private static final String UPDATE_BEACON_INFO_URL = "http://55682a9da6da.ngrok.io/beacon";
+    private static final String BEACON_FORMAT = "m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24";
+
+    private static final ExecutorService BEACON_HANDLER = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), new BeaconThreadFactory());
+
+
+    private BeaconManager beaconManager;
+
+    private String serverId;//服务器id
+    private String departmentsId;//科室ID
+    private int nurseId;    //护士ID
+    private String nurseName;//护士名字
+
+    private final OkHttpClient okHttpClient = new OkHttpClient();
+
+    private List<BluetoothDataEntity> bluetoothDataEntityList = new ArrayList<>();
+
+    private String theCurrentDistance = "";//当前距离
+    private String theCurrentBeacon = "";//当前信标
+
+    @Override
+    public void onCreate() {
+        super.onCreate();
+
+        this.beaconManager = BeaconManager.getInstanceForApplication(this.getApplicationContext());
+
+        this.beaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout(BEACON_FORMAT));
+
+//        this.beaconManager.setBackgroundMode(true);
+
+        this.beaconManager.setForegroundScanPeriod(1000);
+        this.beaconManager.setForegroundBetweenScanPeriod(0);
+
+        this.beaconManager.bind(this);
+    }
+
+    @Nullable
+    @Override
+    public IBinder onBind(Intent intent) {
+        return new Binder();
+    }
+
+    @Override
+    public void onDestroy() {
+        super.onDestroy();
+
+        this.beaconManager.unbind(this);
+    }
+
+    @Override
+    public int onStartCommand(Intent intent, int flags, int startId) {
+
+        serverId = intent.getStringExtra(SERVER_ID_KEY);
+        departmentsId = intent.getStringExtra(DEPARTMENTS_ID_KEY);
+        String ID = intent.getStringExtra(NURSE_ID_KEY);
+        try {
+            nurseId = Integer.valueOf(ID);
+        } catch (Exception e) {
+            nurseId = -1;
+            e.printStackTrace();
+        }
+        nurseName = intent.getStringExtra(NURSE_NAME_KEY);
+
+        return super.onStartCommand(intent, flags, startId);
+    }
+
+    @Override
+    public void onBeaconServiceConnect() {
+        this.beaconManager.removeAllRangeNotifiers();
+        this.beaconManager.addRangeNotifier(this);
+
+        try {
+            this.beaconManager.startRangingBeaconsInRegion(new Region("", null, null, null));
+        } catch (RemoteException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    @RequiresApi(api = Build.VERSION_CODES.N)
+    @Override
+    public void didRangeBeaconsInRegion(Collection<Beacon> collection, Region region) {
+        BEACON_HANDLER.execute(() -> {
+            Log.d("wzl", "didRangeBeaconsInRegion size: " + collection.size());
+          if (collection.size() > 0) {
+
+                //调试查看
+              final JSONObject obj = new JSONObject();
+              try {
+                  obj.put("humanId", nurseId);
+                  obj.put("humanName", nurseName);
+                  obj.put("serverId", serverId);
+
+                  final JSONArray array = new JSONArray();
+                for (Beacon beacon : collection) {
+                    Log.e("xxx","名字"+beacon.getBluetoothName()+"信标"+beacon.getDistance());
+                    final JSONObject tmp = new JSONObject();
+                    tmp.put("name", beacon.getBluetoothName());
+                    tmp.put("address", beacon.getBluetoothAddress());
+                    tmp.put("uuid", beacon.getId1().toString());
+                    tmp.put("major", beacon.getId2().toInt());
+                    tmp.put("minor", beacon.getId3().toInt());
+                    tmp.put("txPower", beacon.getTxPower());
+                    tmp.put("rssi", beacon.getRssi());
+                    tmp.put("distance", beacon.getDistance());
+
+                    array.put(tmp);
+                }
+
+                  obj.put("beaconInfos", array);
+                  Log.e(TAG,"调试查看 obj "+obj.toString());
+////                    final Request request = new Request.Builder()
+////                            .url(UPDATE_BEACON_INFO_URL)
+////                            .post(RequestBody.create(obj.toString(), MediaType.parse("application/json")))
+////                            .build();
+////
+////                    okHttpClient.newCall(request).execute();
+              } catch (Exception ignore) {
+                  Log.e(TAG,ignore.getMessage());
+              }
+
+
+            for (Beacon beacon : collection) {
+                if(bluetoothDataEntityList !=null){
+                   if(bluetoothDataEntityList.size()==0){
+                       BluetoothDataEntity bluetoothDataEntity = new BluetoothDataEntity();
+                       bluetoothDataEntity.setAddress(beacon.getBluetoothAddress());
+                       bluetoothDataEntity.setRssi(beacon.getRssi());
+                       bluetoothDataEntity.setDistance(beacon.getDistance()+"");
+                       bluetoothDataEntityList.add(bluetoothDataEntity);
+                         //测试调试使用
+//                       Log.e(TAG,"getAddress() "+bluetoothDataEntity.getAddress());
+//                       Log.e(TAG,"bluetoothDataEntityList "+bluetoothDataEntityList.size());
+
+//                       theCurrentDistance = bluetoothDataEntityList.get(0).getDistance();
+                       theCurrentBeacon = bluetoothDataEntityList.get(0).getAddress();
+                       uploadingBluetoothBeacon(bluetoothDataEntityList.get(0));
+
+                   }else {
+                       BluetoothDataEntity bluetoothDataEntitys = new BluetoothDataEntity();
+                       bluetoothDataEntitys.setAddress(beacon.getBluetoothAddress());
+                       bluetoothDataEntitys.setRssi(beacon.getRssi());
+                       bluetoothDataEntitys.setDistance(beacon.getDistance()+"");
+                         //测试调试使用
+                       Log.e(TAG,"getAddress() "+bluetoothDataEntitys.getAddress());
+                       Log.e(TAG,"getRssi() "+bluetoothDataEntitys.getRssi());
+                       Log.e(TAG,"getDistance() "+bluetoothDataEntitys.getDistance());
+
+                       for(int i=0;i<bluetoothDataEntityList.size();i++){
+                           Log.e(TAG,"bluetoothDataEntitys222 "+i);
+                           BluetoothDataEntity bluetoothDataEntity = bluetoothDataEntityList.get(i);
+                           Log.e(TAG,"getAddress()2 "+bluetoothDataEntity.getAddress());
+                           Log.e(TAG,"getRssi()2 "+bluetoothDataEntity.getRssi());
+                           Log.e(TAG,"getDistance()2 "+bluetoothDataEntity.getDistance());
+                       }
+//                       Log.e(TAG,"包含 "+bluetoothDataEntityList.contains(bluetoothDataEntitys));
+
+//                       if(!bluetoothDataEntityList.contains(bluetoothDataEntitys)){
+                         if(bluetoothDataEntityList.size()>=3) {
+                             if((bluetoothDataEntityList.get(0).getAddress().equals(theCurrentBeacon)&&
+                                     bluetoothDataEntityList.get(1).getAddress().equals(theCurrentBeacon))||
+                                     (bluetoothDataEntityList.get(0).getAddress().equals(theCurrentBeacon)&&
+                                             bluetoothDataEntityList.get(2).getAddress().equals(theCurrentBeacon))){
+
+                                 bluetoothDataEntityList.remove(0);
+                             }else {
+                                 bluetoothDataEntityList.remove(2);
+                             }
+
+                         }
+                         bluetoothDataEntityList.add(bluetoothDataEntitys);
+                             //集合升序
+                             Collections.sort(bluetoothDataEntityList, new Comparator<BluetoothDataEntity>() {
+                                 public int compare(BluetoothDataEntity o1, BluetoothDataEntity o2) {
+                                     return o1.getDistance().compareTo(o2.getDistance());
+                                 }
+                             });
+//                             //集合倒序
+//                Collections.sort(bluetoothDataEntityList, new Comparator<BluetoothDataEntity>() {
+//                    public int compare(BluetoothDataEntity o1, BluetoothDataEntity o2) {
+//                    return o2.getAddress().compareTo(o1.getAddress());
+//                     }
+//                 });
+//               //也是排序的 当前api不支持
+//              bluetoothDataEntityList.sort(comparing(BluetoothDataEntity::getRssi));
+                 //测试调试使用
+             Log.e(TAG, "bluetoothDataEntityList222 " + bluetoothDataEntityList.size());
+             for(int i=0;i<bluetoothDataEntityList.size();i++){
+             Log.e(TAG,"bluetoothDataEntitys333 "+i);
+             BluetoothDataEntity bluetoothDataEntity = bluetoothDataEntityList.get(i);
+             Log.e(TAG,"getAddress() "+bluetoothDataEntity.getAddress());
+                }
+//                           if(!theCurrentDistance.equals(bluetoothDataEntityList.get(0).getDistance())){
+//                               theCurrentDistance = bluetoothDataEntityList.get(0).getDistance();
+
+                       Log.e(TAG,"theCurrentBeacon "+theCurrentBeacon);
+                       Log.e(TAG,"getAddress() "+bluetoothDataEntityList.get(0).getAddress());
+
+                       if(!theCurrentBeacon.equals(bluetoothDataEntityList.get(0).getAddress())){
+                               theCurrentBeacon = bluetoothDataEntityList.get(0).getAddress();
+                              uploadingBluetoothBeacon(bluetoothDataEntityList.get(0));
+                           }
+
+//                    }
+
+                   }
+                }
+            }
+          }
+        });
+    }
+
+    /**
+     * 上传蓝牙信标
+     * @param bluetoothDataEntity
+     */
+    private void uploadingBluetoothBeacon(BluetoothDataEntity bluetoothDataEntity) {
+
+            final JSONObject obj = new JSONObject();
+            try {
+                obj.put("humanId", nurseId);
+                obj.put("humanName", nurseName);
+                obj.put("serverId", serverId);
+                obj.put("partId", departmentsId);
+
+                final JSONArray array = new JSONArray();
+//                for (Beacon beacon : collection) {
+                    Log.e("xxx","名字"+bluetoothDataEntity.getAddress()+"信标"+bluetoothDataEntity.getDistance());
+                    final JSONObject tmp = new JSONObject();
+                    tmp.put("name", "");
+                    tmp.put("address", bluetoothDataEntity.getAddress());
+                    tmp.put("uuid", "");
+                    tmp.put("major", "");
+                    tmp.put("minor", "");
+                    tmp.put("txPower", "");
+                    tmp.put("rssi", bluetoothDataEntity.getRssi());
+                    tmp.put("distance", bluetoothDataEntity.getDistance());
+
+                    array.put(tmp);
+//                }
+
+                obj.put("beaconInfos", array);
+                Log.e(TAG,"上传信标信息 obj "+obj.toString());
+                    final Request request = new Request.Builder()
+                            .url(UPDATE_BEACON_INFO_URL)
+                            .post(RequestBody.create(obj.toString(), MediaType.parse("application/json")))
+                            .build();
+
+                    okHttpClient.newCall(request).execute();
+            } catch (Exception ignore) {
+                Log.e(TAG,ignore.getMessage());
+            }
+
+
+    }
+
+
+    private static final class BeaconThreadFactory implements ThreadFactory {
+        private static final String BEACON_THREAD_NAME = "BeaconThread";
+
+        private final ThreadGroup threadGroup;
+
+        BeaconThreadFactory() {
+            final SecurityManager securityManager = System.getSecurityManager();
+            this.threadGroup = securityManager != null ? securityManager.getThreadGroup() : Thread.currentThread().getThreadGroup();
+        }
+
+        @Override
+        public Thread newThread(Runnable runnable) {
+            final Thread thread = new Thread(this.threadGroup, runnable, BEACON_THREAD_NAME);
+            if (thread.isDaemon()) {
+                thread.setDaemon(false);
+            }
+            if (thread.getPriority() != Thread.NORM_PRIORITY) {
+                thread.setPriority(Thread.NORM_PRIORITY);
+            }
+            return thread;
+        }
+    }
+}

+ 85 - 0
app/src/main/java/com/wdkl/nursewatch/utils/LogUtil.java

@@ -0,0 +1,85 @@
+package com.wdkl.nursewatch.utils;
+
+import android.util.Log;
+
+/**
+ * 类名称:LogUtil <br>
+ * 类描述:打印日志工具类 <br>
+ * 创建人:Waderson Shll<br>
+ */
+public class LogUtil {
+    public static final int VERBOSE = 1;
+    public static final int DEBUG = 2;
+    public static final int INFO = 3;
+    public static final int WARN = 4;
+    public static final int ERROR = 5;
+    public static final int NOTHING = 6;
+    public static final int LEVEL = VERBOSE;
+
+    public static String getTag(Class<?> clazz) {
+        if (null != clazz) {
+            return clazz.getSimpleName();
+        }
+        return "WADERSON";
+    }
+
+    public static void v(String tag, String msg) {
+        if (LEVEL <= VERBOSE) {
+            Log.v(tag, msg);
+        }
+    }
+
+    public static void d(String tag, String msg) {
+        if (LEVEL <= DEBUG) {
+            Log.d(tag, msg);
+        }
+    }
+
+    public static void i(String tag, String msg) {
+        if (LEVEL <= INFO) {
+            Log.i(tag, msg);
+        }
+    }
+
+    public static void w(String tag, String msg) {
+        if (LEVEL <= WARN) {
+            Log.w(tag, msg);
+        }
+    }
+
+    public static void e(String tag, String msg) {
+        if (LEVEL <= ERROR) {
+            Log.e(tag, msg);
+        }
+    }
+
+    public static void v(Class<?> clazz, String msg) {
+        if (LEVEL <= VERBOSE) {
+            Log.v(getTag(clazz), msg);
+        }
+    }
+
+    public static void d(Class<?> clazz, String msg) {
+        if (LEVEL <= DEBUG) {
+            Log.d(getTag(clazz), msg);
+        }
+    }
+
+    public static void i(Class<?> clazz, String msg) {
+        if (LEVEL <= INFO) {
+            Log.i(getTag(clazz), msg);
+        }
+    }
+
+    public static void w(Class<?> clazz, String msg) {
+        if (LEVEL <= WARN) {
+            Log.w(getTag(clazz), msg);
+        }
+    }
+
+    public static void e(Class<?> clazz, String msg) {
+        if (LEVEL <= ERROR) {
+            Log.e(getTag(clazz), msg);
+        }
+    }
+}

+ 981 - 0
app/src/main/java/com/wdkl/nursewatch/utils/NetworkUtil.java

@@ -0,0 +1,981 @@
+package com.wdkl.nursewatch.utils;
+
+import android.content.Context;
+import android.database.Cursor;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.net.Uri;
+import android.net.wifi.WifiInfo;
+import android.net.wifi.WifiManager;
+import android.os.Build;
+import android.telephony.TelephonyManager;
+import android.text.TextUtils;
+
+import com.wdkl.nursewatch.MyApplication;
+
+public class NetworkUtil {
+
+    public static boolean checkNetworkAvailable() {
+        if (!checkNetworkAvailable(MyApplication.getAppContext())) {
+            ToastUtil.showToast(MyApplication.getAppContext(), "当前网络不可用");
+            return false;
+        }
+        return true;
+    }
+
+    // 检测网络 返回false表示网络不可以用
+    public static boolean checkNetworkAvailable(Context context) {
+        ConnectivityManager connectivity = (ConnectivityManager) context
+                .getSystemService(Context.CONNECTIVITY_SERVICE);
+        if (connectivity == null) {
+            return false;
+        } else {
+            NetworkInfo[] info = connectivity.getAllNetworkInfo();
+            if (info != null) {
+                for (int i = 0; i < info.length; i++) {
+                    if (info[i].getState() == NetworkInfo.State.CONNECTED) {
+                        NetworkInfo netWorkInfo = info[i];
+                        if (netWorkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
+                            return true;
+                        } else if (netWorkInfo.getType() == ConnectivityManager.TYPE_MOBILE) {
+                            return true;
+                        }
+                    }
+                }
+            }
+        }
+
+        return false;
+
+    }
+
+    public static final String TAG = "NetworkUtil";
+
+    public static final byte CURRENT_NETWORK_TYPE_NONE = 0;
+
+    /*
+     * 根据APN区分网络类型
+     */
+    public static final byte CURRENT_NETWORK_TYPE_WIFI = 1;// wifi
+
+    public static final byte CURRENT_NETWORK_TYPE_CTNET = 2;// ctnet
+
+    public static final byte CURRENT_NETWORK_TYPE_CTWAP = 3;// ctwap
+
+    public static final byte CURRENT_NETWORK_TYPE_CMWAP = 4;// cmwap
+
+    public static final byte CURRENT_NETWORK_TYPE_UNIWAP = 5;// uniwap,3gwap
+
+    public static final byte CURRENT_NETWORK_TYPE_CMNET = 6;// cmnet
+
+    public static final byte CURRENT_NETWORK_TYPE_UNIET = 7;// uninet,3gnet
+
+    /**
+     * 根据运营商区分网络类型
+     */
+    public static final byte CURRENT_NETWORK_TYPE_CTC = 10;// ctwap,ctnet
+
+    public static final byte CURRENT_NETWORK_TYPE_CUC = 11;// uniwap,3gwap,uninet,3gnet
+
+    public static final byte CURRENT_NETWORK_TYPE_CM = 12;// cmwap,cmnet
+
+    /**
+     * apn值
+     */
+    private static final String CONNECT_TYPE_WIFI = "wifi";
+
+    private static final String CONNECT_TYPE_CTNET = "ctnet";
+
+    private static final String CONNECT_TYPE_CTWAP = "ctwap";
+
+    private static final String CONNECT_TYPE_CMNET = "cmnet";
+
+    private static final String CONNECT_TYPE_CMWAP = "cmwap";
+
+    private static final String CONNECT_TYPE_UNIWAP = "uniwap";
+
+    private static final String CONNECT_TYPE_UNINET = "uninet";
+
+    private static final String CONNECT_TYPE_UNI3GWAP = "3gwap";
+
+    private static final String CONNECT_TYPE_UNI3GNET = "3gnet";
+
+    private static final Uri PREFERRED_APN_URI = Uri.parse("content://telephony/carriers/preferapn");
+
+    public static byte curNetworkType = CURRENT_NETWORK_TYPE_NONE;
+
+    /*
+     *
+     * 获取网络类型
+     *
+     */
+    public static int getNetType(Context context) {
+        NetworkInfo networkInfo = getActiveNetworkInfo(context);
+        if (networkInfo == null) {
+            return -1;
+        } else
+            return networkInfo.getType();
+    }
+
+    public static final int NETWORK_NONE = 0; // 没有网络连接
+    public static final int NETWORK_WIFI = 1; // wifi连接
+    public static final int NETWORK_2G = 2; // 2G
+    public static final int NETWORK_3G = 3; // 3G
+    public static final int NETWORK_4G = 4; // 4G
+    public static final int NETWORK_MOBILE = 5; // 手机流量
+
+    /**
+     * 获取当前网络连接的类型
+     *
+     * @param context context
+     * @return int
+     */
+    public static int getNetworkState(Context context) {
+        ConnectivityManager connManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); // 获取网络服务
+        if (null == connManager) { // 为空则认为无网络
+            return NETWORK_NONE;
+        }
+        // 获取网络类型,如果为空,返回无网络
+        NetworkInfo activeNetInfo = connManager.getActiveNetworkInfo();
+        if (activeNetInfo == null || !activeNetInfo.isAvailable()) {
+            return NETWORK_NONE;
+        }
+        // 判断是否为WIFI
+        NetworkInfo wifiInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
+        if (null != wifiInfo) {
+            NetworkInfo.State state = wifiInfo.getState();
+            if (null != state) {
+                if (state == NetworkInfo.State.CONNECTED || state == NetworkInfo.State.CONNECTING) {
+                    return NETWORK_WIFI;
+                }
+            }
+        }
+        // 若不是WIFI,则去判断是2G、3G、4G网
+        TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+        int networkType = telephonyManager.getNetworkType();
+        switch (networkType) {
+            // 2G网络
+            case TelephonyManager.NETWORK_TYPE_GPRS:
+            case TelephonyManager.NETWORK_TYPE_CDMA:
+            case TelephonyManager.NETWORK_TYPE_EDGE:
+            case TelephonyManager.NETWORK_TYPE_1xRTT:
+            case TelephonyManager.NETWORK_TYPE_IDEN:
+                return NETWORK_2G;
+            // 3G网络
+            case TelephonyManager.NETWORK_TYPE_EVDO_A:
+            case TelephonyManager.NETWORK_TYPE_UMTS:
+            case TelephonyManager.NETWORK_TYPE_EVDO_0:
+            case TelephonyManager.NETWORK_TYPE_HSDPA:
+            case TelephonyManager.NETWORK_TYPE_HSUPA:
+            case TelephonyManager.NETWORK_TYPE_HSPA:
+            case TelephonyManager.NETWORK_TYPE_EVDO_B:
+            case TelephonyManager.NETWORK_TYPE_EHRPD:
+            case TelephonyManager.NETWORK_TYPE_HSPAP:
+                return NETWORK_3G;
+            // 4G网络
+            case TelephonyManager.NETWORK_TYPE_LTE:
+                return NETWORK_4G;
+            default:
+                return NETWORK_MOBILE;
+        }
+    }
+
+
+    /**
+     * 判断当前网络类型。WIFI,NET,WAP
+     *
+     * @param context
+     * @return
+     */
+    public static byte getCurrentNetType(Context context) {
+        NetworkInfo networkInfo = getActiveNetworkInfo(context);
+        byte type = CURRENT_NETWORK_TYPE_NONE;
+        if (networkInfo != null) {
+            // String typeName = networkInfo.getTypeName();
+            // XT800
+            String typeName = networkInfo.getExtraInfo();
+            if (TextUtils.isEmpty(typeName)) {
+                typeName = networkInfo.getTypeName();
+            }
+            if (!TextUtils.isEmpty(typeName)) {
+                String temp = typeName.toLowerCase();
+                if (temp.indexOf(CONNECT_TYPE_WIFI) > -1) {// wifi
+                    type = CURRENT_NETWORK_TYPE_WIFI;
+                } else if (temp.indexOf(CONNECT_TYPE_CTNET) > -1) {// ctnet
+                    type = CURRENT_NETWORK_TYPE_CTNET;
+                } else if (temp.indexOf(CONNECT_TYPE_CTWAP) > -1) {// ctwap
+                    type = CURRENT_NETWORK_TYPE_CTWAP;
+                } else if (temp.indexOf(CONNECT_TYPE_CMNET) > -1) {// cmnet
+                    type = CURRENT_NETWORK_TYPE_CMNET;
+                } else if (temp.indexOf(CONNECT_TYPE_CMWAP) > -1) {// cmwap
+                    type = CURRENT_NETWORK_TYPE_CMWAP;
+                } else if (temp.indexOf(CONNECT_TYPE_UNIWAP) > -1) {// uniwap
+                    type = CURRENT_NETWORK_TYPE_UNIWAP;
+                } else if (temp.indexOf(CONNECT_TYPE_UNI3GWAP) > -1) {// 3gwap
+                    type = CURRENT_NETWORK_TYPE_UNIWAP;
+                } else if (temp.indexOf(CONNECT_TYPE_UNINET) > -1) {// uninet
+                    type = CURRENT_NETWORK_TYPE_UNIET;
+                } else if (temp.indexOf(CONNECT_TYPE_UNI3GNET) > -1) {// 3gnet
+                    type = CURRENT_NETWORK_TYPE_UNIET;
+                }
+            }
+        }
+
+        if (type == CURRENT_NETWORK_TYPE_NONE) {
+            String apnType = getApnType(context);
+            if (apnType != null && apnType.equals(CONNECT_TYPE_CTNET)) {// ctnet
+                type = CURRENT_NETWORK_TYPE_CTNET;
+            } else if (apnType != null && apnType.equals(CONNECT_TYPE_CTWAP)) {// ctwap
+                type = CURRENT_NETWORK_TYPE_CTWAP;
+            } else if (apnType != null && apnType.equals(CONNECT_TYPE_CMWAP)) {// cmwap
+                type = CURRENT_NETWORK_TYPE_CMWAP;
+            } else if (apnType != null && apnType.equals(CONNECT_TYPE_CMNET)) {// cmnet
+                type = CURRENT_NETWORK_TYPE_CMNET;
+            } else if (apnType != null && apnType.equals(CONNECT_TYPE_UNIWAP)) {// uniwap
+                type = CURRENT_NETWORK_TYPE_UNIWAP;
+            } else if (apnType != null && apnType.equals(CONNECT_TYPE_UNI3GWAP)) {// 3gwap
+                type = CURRENT_NETWORK_TYPE_UNIWAP;
+            } else if (apnType != null && apnType.equals(CONNECT_TYPE_UNINET)) {// uninet
+                type = CURRENT_NETWORK_TYPE_UNIET;
+            } else if (apnType != null && apnType.equals(CONNECT_TYPE_UNI3GNET)) {// 3gnet
+                type = CURRENT_NETWORK_TYPE_UNIET;
+            }
+        }
+        curNetworkType = type;
+
+        return type;
+    }
+
+    /**
+     * 判断APNTYPE
+     *
+     * @param context
+     * @return
+     */
+    /**
+     * @deprecated 4.0
+     * doc:
+     * Since the DB may contain corp passwords, we should secure it. Using the same permission as writing to the DB as the read is potentially as damaging as a write
+     */
+    public static String getApnType(Context context) {
+
+        String apntype = "nomatch";
+        Cursor c = context.getContentResolver().query(PREFERRED_APN_URI, null, null, null, null);
+        if (c != null) {
+            if (c.moveToFirst()) {
+                String user = c.getString(c.getColumnIndex("user"));
+                if (user != null && user.startsWith(CONNECT_TYPE_CTNET)) {
+                    apntype = CONNECT_TYPE_CTNET;
+                } else if (user != null && user.startsWith(CONNECT_TYPE_CTWAP)) {
+                    apntype = CONNECT_TYPE_CTWAP;
+                } else if (user != null && user.startsWith(CONNECT_TYPE_CMWAP)) {
+                    apntype = CONNECT_TYPE_CMWAP;
+                } else if (user != null && user.startsWith(CONNECT_TYPE_CMNET)) {
+                    apntype = CONNECT_TYPE_CMNET;
+                } else if (user != null && user.startsWith(CONNECT_TYPE_UNIWAP)) {
+                    apntype = CONNECT_TYPE_UNIWAP;
+                } else if (user != null && user.startsWith(CONNECT_TYPE_UNINET)) {
+                    apntype = CONNECT_TYPE_UNINET;
+                } else if (user != null && user.startsWith(CONNECT_TYPE_UNI3GWAP)) {
+                    apntype = CONNECT_TYPE_UNI3GWAP;
+                } else if (user != null && user.startsWith(CONNECT_TYPE_UNI3GNET)) {
+                    apntype = CONNECT_TYPE_UNI3GNET;
+                }
+            }
+            c.close();
+            c = null;
+        }
+
+        return apntype;
+    }
+
+    /**
+     * 判断是否有网络可用
+     *
+     * @param context
+     * @return
+     */
+    public static boolean isNetAvailable(Context context) {
+        NetworkInfo networkInfo = getActiveNetworkInfo(context);
+        if (networkInfo != null) {
+            return networkInfo.isAvailable();
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * 此判断不可靠
+     *
+     * @param context
+     * @return
+     */
+    public static boolean isNetworkConnected(Context context) {
+        NetworkInfo networkInfo = getActiveNetworkInfo(context);
+        if (networkInfo != null) {
+            boolean a = networkInfo.isConnected();
+            return a;
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * 获取可用的网络信息(省电模式不能使用该方法)
+     *
+     * @param context
+     * @return
+     */
+    private static NetworkInfo getActiveNetworkInfo(Context context) {
+        try {
+            ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+            return cm.getActiveNetworkInfo();
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+
+
+    public static boolean isNetworkAvailable(Context context) {
+        ConnectivityManager connManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+        if (connManager != null) {
+/**
+ * 获取网络信息实体
+ * 由于从系统服务中获取数据属于进程间通信,基本类型外的数据必须实现Parcelable接口,
+ * NetworkInfo实现了Parcelable,获取到的activeNetInfo相当于服务中网络信息实体对象的一个副本(拷贝),
+ * 所以,不管系统网络服务中的实体对象是否置为了null,此处获得的activeNetInfo均不会发生变化
+ */
+            NetworkInfo activeNetInfo = connManager.getActiveNetworkInfo();
+            if (activeNetInfo != null) {
+                return activeNetInfo.isAvailable();
+            }
+        }
+        return false;
+    }
+
+    public static boolean isWifiOr3G(Context context) {
+        if (isWifi(context)) {
+            return true;
+        } else {
+            return is3G(context);
+        }
+    }
+
+    public static boolean is2G(Context context) {
+        return !isWifiOr3G(context);
+    }
+
+    public static boolean is3G(Context context) {
+        int type = getNetworkClass(context);
+        if (type == NETWORK_CLASS_3_G || type == NETWORK_CLASS_4_G) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * 当前网络是否是wifi网络
+     *
+     * @param context
+     * @return
+     */
+    public static boolean isWifi(Context context) {
+        try {
+            ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+            NetworkInfo ni = cm.getActiveNetworkInfo();
+            if (ni != null) {
+                if (ni.getType() == ConnectivityManager.TYPE_WIFI) {
+                    return true;
+                } else {
+                    return false;
+                }
+            } else {
+                return false;
+            }
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
+    public static boolean getNetworkConnectionStatus(Context context) {
+        ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+        if (manager == null) {
+            return false;
+        }
+
+        NetworkInfo info = manager.getActiveNetworkInfo();
+        if (info == null) {
+            return false;
+        }
+
+        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+        if (tm == null) {
+            return false;
+        }
+
+        if ((tm.getDataState() == TelephonyManager.DATA_CONNECTED || tm.getDataState() == TelephonyManager.DATA_ACTIVITY_NONE)
+                && info.isAvailable()) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public static String getNetworkProxyInfo(Context context) {
+        String proxyHost = android.net.Proxy.getDefaultHost();
+        int proxyPort = android.net.Proxy.getDefaultPort();
+        String szport = String.valueOf(proxyPort);
+        String proxyInfo = null;
+
+        ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+        if (manager == null) {
+            return null;
+        } else {
+            NetworkInfo info = manager.getActiveNetworkInfo();
+            if (info != null) {
+                String typeName = info.getTypeName().toLowerCase();
+                if (typeName != null && typeName.equals("wifi")) {
+                    return null;
+                }
+            } else {
+                return null;
+            }
+        }
+
+        if (proxyHost != null && (0 < proxyPort && proxyPort < 65535)) {
+            proxyInfo = proxyHost + ":" + szport;
+            return proxyInfo;
+        } else {
+            return null;
+        }
+    }
+
+    public static String getNetworkProxyUrl(Context context) {
+        if (isWifi(context)) {
+            return null;
+        }
+
+        String proxyHost = android.net.Proxy.getDefaultHost();
+        LogUtil.e(TAG, "proxyHost:" + proxyHost);
+        return proxyHost;
+    }
+
+    public static String getNetworkProxyUrl() {
+        /**
+         * 当网络为wifi时,直接返回空代理: 当ctwap,cmwap,uniwap,3gwap开启时同时开启wifi网络
+         * ,通过下面的getDefaultHost接口将得到对应wap网络代理ip ,这是错误的,所以在此判断当前网络是否为wifi
+         */
+        if (curNetworkType == CURRENT_NETWORK_TYPE_WIFI) {
+            return null;
+        }
+
+        String proxyHost = android.net.Proxy.getDefaultHost();
+        LogUtil.e(TAG, "proxyHost:" + proxyHost);
+        return proxyHost;
+    }
+
+    public static int getNetworkProxyPort() {
+        int proxyPort = android.net.Proxy.getDefaultPort();
+        return proxyPort;
+    }
+
+    public static boolean isCtwap(Context context) {
+        if (getApnType(context).equals(CONNECT_TYPE_CTWAP)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public static boolean isUniwap(Context context) {
+        if (getApnType(context).equals(CONNECT_TYPE_UNIWAP)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public static boolean isCmwap(Context context) {
+        if (getApnType(context).equals(CONNECT_TYPE_CMWAP)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * 判断是否是电信网络(ctwap,ctnet)
+     *
+     * @return
+     */
+    public static boolean isCtcNetwork(Context context) {
+        byte type = getCurrentNetType(context);
+
+        return isCtcNetwork(type);
+    }
+
+    public static boolean isCtcNetwork(String apnName) {
+        if (apnName == null) {
+            return false;
+        }
+
+        if (apnName.equals(CONNECT_TYPE_CTWAP) || apnName.equals(CONNECT_TYPE_CTNET)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public static boolean isCtcNetwork(byte type) {
+        if (type == CURRENT_NETWORK_TYPE_CTWAP || type == CURRENT_NETWORK_TYPE_CTNET) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * 判断是否是联通网络(uniwap,uninet,3gwap,3gnet)
+     *
+     * @return
+     */
+    public static boolean isCucNetwork(Context context) {
+        byte type = getCurrentNetType(context);
+
+        return isCucNetwork(type);
+    }
+
+    public static boolean isCucNetwork(String apnName) {
+        if (apnName == null) {
+            return false;
+        }
+
+        if (apnName.equals(CONNECT_TYPE_UNIWAP) || apnName.equals(CONNECT_TYPE_UNINET)
+                || apnName.equals(CONNECT_TYPE_UNI3GWAP) || apnName.equals(CONNECT_TYPE_UNI3GNET)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public static boolean isCucNetwork(byte type) {
+        if (type == CURRENT_NETWORK_TYPE_UNIWAP || type == CURRENT_NETWORK_TYPE_UNIET) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * 判断是否是移动网络(cmwap,cmnet)
+     *
+     * @return
+     */
+    public static boolean isCmbNetwork(Context context) {
+        byte type = getCurrentNetType(context);
+
+        return isCmbNetwork(type);
+    }
+
+    public static boolean isCmbNetwork(String apnName) {
+        if (apnName == null) {
+            return false;
+        }
+
+        if (apnName.equals(CONNECT_TYPE_CMWAP) || apnName.equals(CONNECT_TYPE_CMNET)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public static boolean isCmbNetwork(byte type) {
+        if (type == CURRENT_NETWORK_TYPE_CMWAP || type == CURRENT_NETWORK_TYPE_CMNET) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * 获取网络运营商类型(中国移动,中国联通,中国电信,wifi)
+     *
+     * @param context
+     * @return
+     */
+    public static byte getNetworkOperators(Context context) {
+        if (isWifi(context)) {
+            return CURRENT_NETWORK_TYPE_WIFI;
+        } else if (isCtcNetwork(context)) {
+            return CURRENT_NETWORK_TYPE_CTC;
+        } else if (isCmbNetwork(context)) {
+            return CURRENT_NETWORK_TYPE_CM;
+        } else if (isCucNetwork(context)) {
+            return CURRENT_NETWORK_TYPE_CUC;
+        } else {
+            return CURRENT_NETWORK_TYPE_NONE;
+        }
+    }
+
+    public static byte getNetworkOperators(byte type) {
+        if (type == CURRENT_NETWORK_TYPE_NONE) {
+            return CURRENT_NETWORK_TYPE_NONE;
+        } else if (type == CURRENT_NETWORK_TYPE_WIFI) {
+            return CURRENT_NETWORK_TYPE_WIFI;
+        } else if (type == CURRENT_NETWORK_TYPE_CTNET || type == CURRENT_NETWORK_TYPE_CTWAP) {
+            return CURRENT_NETWORK_TYPE_CTC;
+        } else if (type == CURRENT_NETWORK_TYPE_CMWAP || type == CURRENT_NETWORK_TYPE_CMNET) {
+            return CURRENT_NETWORK_TYPE_CM;
+        } else if (type == CURRENT_NETWORK_TYPE_UNIWAP || type == CURRENT_NETWORK_TYPE_UNIET) {
+            return CURRENT_NETWORK_TYPE_CUC;
+        } else {
+            return CURRENT_NETWORK_TYPE_NONE;
+        }
+    }
+
+    /**
+     * 是否需要设置代理(网络请求,一般用于wap网络,但有些机型设置代理会导致系统异常)
+     *
+     * @return
+     */
+    public static boolean isNeedSetProxyForNetRequest() { // #00044 +
+        if (Build.MODEL.equals("SCH-N719") || Build.MODEL.equals("SCH-I939D")) {
+            return false;
+        } else {
+            return true;
+        }
+    }
+
+    /**
+     * get mac address of wifi if wifi is active
+     */
+
+    public static String getActiveMacAddress(Context context) {
+        WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+
+        WifiInfo info = wifi.getConnectionInfo();
+
+        if (info != null) {
+            return info.getMacAddress();
+        }
+
+        return "";
+    }
+
+    public static String getNetworkInfo(Context context) {
+        String info = "";
+        ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+        if (connectivity != null) {
+            NetworkInfo activeNetInfo = connectivity.getActiveNetworkInfo();
+            if (activeNetInfo != null) {
+                if (activeNetInfo.getType() == ConnectivityManager.TYPE_WIFI) {
+                    info = activeNetInfo.getTypeName();
+                } else {
+                    StringBuilder sb = new StringBuilder();
+                    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+                    sb.append(activeNetInfo.getTypeName());
+                    sb.append(" [");
+                    if (tm != null) {
+                        // Result may be unreliable on CDMA networks
+                        sb.append(tm.getNetworkOperatorName());
+                        sb.append("#");
+                    }
+                    sb.append(activeNetInfo.getSubtypeName());
+                    sb.append("]");
+                    info = sb.toString();
+                }
+            }
+        }
+        return info;
+    }
+
+    public enum NetworkSpeedMode {
+        LOW, NORMAL, HIGH, UNKNOWN
+    }
+
+    /**
+     * 网络类型
+     */
+    public static final int NETWORK_CLASS_UNKNOWN = 0;
+
+    public static final int NETWORK_CLASS_2_G = 1;
+
+    public static final int NETWORK_CLASS_3_G = 2;
+
+    public static final int NETWORK_CLASS_4_G = 3;
+
+    public static final int NETWORK_CLASS_WIFI = 10;
+
+    /**
+     * 仅判断Mobile网络的慢速.蓝牙等其他网络不做判断.
+     *
+     * @param context
+     * @return
+     */
+    public static NetworkSpeedMode getNetworkSpeedModeInMobile(Context context) {
+        ConnectivityManager connectivityManager = (ConnectivityManager) context
+                .getSystemService(Context.CONNECTIVITY_SERVICE);
+        if (connectivityManager != null) {
+            NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
+            if (networkInfo != null) {
+                if (networkInfo.getType() == ConnectivityManager.TYPE_MOBILE) {
+                    switch (networkInfo.getSubtype()) {
+                        case TelephonyManager.NETWORK_TYPE_IDEN: // ~25 kbps
+                            return NetworkSpeedMode.LOW;
+                        case TelephonyManager.NETWORK_TYPE_CDMA: // ~ 14-64 kbps
+                            return NetworkSpeedMode.LOW;
+                        case TelephonyManager.NETWORK_TYPE_1xRTT: // ~ 50-100 kbps
+                            return NetworkSpeedMode.LOW;
+                        case TelephonyManager.NETWORK_TYPE_EDGE: // ~ 50-100 kbps
+                            return NetworkSpeedMode.LOW;
+                        case TelephonyManager.NETWORK_TYPE_GPRS: // ~ 100 kbps
+                            return NetworkSpeedMode.LOW;
+
+                        case TelephonyManager.NETWORK_TYPE_EVDO_0: // ~ 400-1000
+                            // kbps
+                            return NetworkSpeedMode.NORMAL;
+                        case TelephonyManager.NETWORK_TYPE_EVDO_A: // ~ 600-1400
+                            // kbps
+                            return NetworkSpeedMode.NORMAL;
+                        case TelephonyManager.NETWORK_TYPE_HSPA: // ~ 700-1700 kbps
+                            return NetworkSpeedMode.NORMAL;
+                        case TelephonyManager.NETWORK_TYPE_UMTS: // ~ 400-7000 kbps
+                            return NetworkSpeedMode.NORMAL;
+                        case 14: // TelephonyManager.NETWORK_TYPE_EHRPD: // ~ 1-2
+                            // Mbps
+                            return NetworkSpeedMode.NORMAL;
+                        case 12: // TelephonyManager.NETWORK_TYPE_EVDO_B: // ~ 5
+                            // Mbps
+                            return NetworkSpeedMode.NORMAL;
+
+                        case TelephonyManager.NETWORK_TYPE_HSDPA: // ~ 2-14 Mbps
+                            return NetworkSpeedMode.HIGH;
+                        case TelephonyManager.NETWORK_TYPE_HSUPA: // ~ 1-23 Mbps
+                            return NetworkSpeedMode.HIGH;
+                        case 15: // TelephonyManager.NETWORK_TYPE_HSPAP: // ~ 10-20
+                            // Mbps
+                            return NetworkSpeedMode.HIGH;
+                        case 13: // TelephonyManager.NETWORK_TYPE_LTE: // ~ 10+ Mbps
+                            return NetworkSpeedMode.HIGH;
+
+                        case TelephonyManager.NETWORK_TYPE_UNKNOWN:
+                            return NetworkSpeedMode.NORMAL;
+                        default:
+                            break;
+                    }
+                }
+            }
+        }
+        return NetworkSpeedMode.UNKNOWN;
+    }
+
+    /**
+     * 获取在Mobile网络下的网络类型. 2G,3G,4G
+     *
+     * @param context
+     * @return
+     */
+    public static int getNetworkClass(Context context) {
+        ConnectivityManager connectivityManager = (ConnectivityManager) context
+                .getSystemService(Context.CONNECTIVITY_SERVICE);
+        if (connectivityManager != null) {
+            NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
+            if (networkInfo != null) {
+                if (networkInfo.getType() == ConnectivityManager.TYPE_MOBILE) {
+                    switch (networkInfo.getSubtype()) {
+                        case TelephonyManager.NETWORK_TYPE_GPRS:
+                        case TelephonyManager.NETWORK_TYPE_EDGE:
+                        case TelephonyManager.NETWORK_TYPE_CDMA:
+                        case TelephonyManager.NETWORK_TYPE_1xRTT:
+                        case TelephonyManager.NETWORK_TYPE_IDEN:
+                            return NETWORK_CLASS_2_G;
+                        case TelephonyManager.NETWORK_TYPE_UMTS:
+                        case TelephonyManager.NETWORK_TYPE_EVDO_0:
+                        case TelephonyManager.NETWORK_TYPE_EVDO_A:
+                        case TelephonyManager.NETWORK_TYPE_HSDPA:
+                        case TelephonyManager.NETWORK_TYPE_HSUPA:
+                        case TelephonyManager.NETWORK_TYPE_HSPA:
+                        case 12: // TelephonyManager.NETWORK_TYPE_EVDO_B:
+                        case 14: // TelephonyManager.NETWORK_TYPE_EHRPD:
+                        case 15: // TelephonyManager.NETWORK_TYPE_HSPAP:
+                            return NETWORK_CLASS_3_G;
+                        case 13: // TelephonyManager.NETWORK_TYPE_LTE:
+                            return NETWORK_CLASS_4_G;
+                        default:
+                            return NETWORK_CLASS_UNKNOWN;
+                    }
+                } else if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
+                    return NETWORK_CLASS_WIFI;
+                }
+            }
+        }
+        return NETWORK_CLASS_UNKNOWN;
+    }
+
+    public static String getNetworkTypeName(Context context) {
+        String networkName = "UNKNOWN";
+        ConnectivityManager connectivityManager = (ConnectivityManager) context
+                .getSystemService(Context.CONNECTIVITY_SERVICE);
+        if (connectivityManager != null) {
+            NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
+            if (networkInfo != null) {
+                networkName = getNetworkTypeName(networkInfo.getType());
+                if (networkInfo.getType() == ConnectivityManager.TYPE_MOBILE) {
+                    networkName += "#" + getNetworkTypeNameInMobile(networkInfo.getSubtype());
+                }
+            }
+        }
+        return networkName;
+    }
+
+    private static String getNetworkTypeNameInMobile(int type) {
+        switch (type) {
+            case TelephonyManager.NETWORK_TYPE_GPRS:
+                return "GPRS";
+            case TelephonyManager.NETWORK_TYPE_EDGE:
+                return "EDGE";
+            case TelephonyManager.NETWORK_TYPE_UMTS:
+                return "UMTS";
+            case TelephonyManager.NETWORK_TYPE_HSDPA:
+                return "HSDPA";
+            case TelephonyManager.NETWORK_TYPE_HSUPA:
+                return "HSUPA";
+            case TelephonyManager.NETWORK_TYPE_HSPA:
+                return "HSPA";
+            case TelephonyManager.NETWORK_TYPE_CDMA:
+                return "CDMA";
+            case TelephonyManager.NETWORK_TYPE_EVDO_0:
+                return "CDMA - EvDo rev. 0";
+            case TelephonyManager.NETWORK_TYPE_EVDO_A:
+                return "CDMA - EvDo rev. A";
+            case TelephonyManager.NETWORK_TYPE_EVDO_B:
+                return "CDMA - EvDo rev. B";
+            case TelephonyManager.NETWORK_TYPE_1xRTT:
+                return "CDMA - 1xRTT";
+            case TelephonyManager.NETWORK_TYPE_LTE:
+                return "LTE";
+            case TelephonyManager.NETWORK_TYPE_EHRPD:
+                return "CDMA - eHRPD";
+            case TelephonyManager.NETWORK_TYPE_IDEN:
+                return "iDEN";
+            case TelephonyManager.NETWORK_TYPE_HSPAP:
+                return "HSPA+";
+            default:
+                return "UNKNOWN";
+        }
+    }
+
+    private static String getNetworkTypeName(int type) {
+        switch (type) {
+            case ConnectivityManager.TYPE_MOBILE:
+                return "MOBILE";
+            case ConnectivityManager.TYPE_WIFI:
+                return "WIFI";
+            case ConnectivityManager.TYPE_MOBILE_MMS:
+                return "MOBILE_MMS";
+            case ConnectivityManager.TYPE_MOBILE_SUPL:
+                return "MOBILE_SUPL";
+            case ConnectivityManager.TYPE_MOBILE_DUN:
+                return "MOBILE_DUN";
+            case ConnectivityManager.TYPE_MOBILE_HIPRI:
+                return "MOBILE_HIPRI";
+            case ConnectivityManager.TYPE_WIMAX:
+                return "WIMAX";
+            case ConnectivityManager.TYPE_BLUETOOTH:
+                return "BLUETOOTH";
+            case ConnectivityManager.TYPE_DUMMY:
+                return "DUMMY";
+            case ConnectivityManager.TYPE_ETHERNET:
+                return "ETHERNET";
+            case 10: // ConnectivityManager.TYPE_MOBILE_FOTA:
+                return "MOBILE_FOTA";
+            case 11: // ConnectivityManager.TYPE_MOBILE_IMS:
+                return "MOBILE_IMS";
+            case 12: // ConnectivityManager.TYPE_MOBILE_CBS:
+                return "MOBILE_CBS";
+            case 13: // ConnectivityManager.TYPE_WIFI_P2P:
+                return "WIFI_P2P";
+            default:
+                return Integer.toString(type);
+        }
+    }
+
+    //中国电信
+    public static final int ISP_CTCC = 0;
+    //中国联通
+    public static final int ISP_CUCC = 1;
+    //中国移动
+    public static final int ISP_CMCC = 2;
+    //中国铁通
+    public static final int ISP_CTT = 3;
+    //其他
+    public static final int ISP_OTHERS = -1;
+
+    public static String getSimOperator(Context context) {
+        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+        if (tm != null) {
+            return tm.getSimOperator();
+        }
+        return null;
+    }
+
+    public static String getNetworkOperator(Context context) {
+        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+        if (tm != null) {
+            return tm.getNetworkOperator();
+        }
+        return null;
+    }
+
+
+    public interface LinkNetWorkType {
+        public static final int UNKNOWN = 0;
+        public static final int WIFI = 1;
+        public static final int WWAN = 2;
+        public static final int _2G = 3;
+        public static final int _3G = 4;
+        public static final int _4G = 5;
+    }
+
+    public static int getNetworkTypeForLink(Context context) {
+        try {
+            ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+            NetworkInfo ni = cm.getActiveNetworkInfo();
+            if (ni != null) {
+                if (ni.getType() == ConnectivityManager.TYPE_WIFI) {
+                    return LinkNetWorkType.WIFI;
+                } else {
+                    if (ni.getType() == ConnectivityManager.TYPE_MOBILE) {
+                        switch (ni.getSubtype()) {
+                            case TelephonyManager.NETWORK_TYPE_GPRS:
+                            case TelephonyManager.NETWORK_TYPE_EDGE:
+                            case TelephonyManager.NETWORK_TYPE_CDMA:
+                            case TelephonyManager.NETWORK_TYPE_1xRTT:
+                            case TelephonyManager.NETWORK_TYPE_IDEN:
+                                return LinkNetWorkType._2G;
+                            case TelephonyManager.NETWORK_TYPE_UMTS:
+                            case TelephonyManager.NETWORK_TYPE_EVDO_0:
+                            case TelephonyManager.NETWORK_TYPE_EVDO_A:
+                            case TelephonyManager.NETWORK_TYPE_HSDPA:
+                            case TelephonyManager.NETWORK_TYPE_HSUPA:
+                            case TelephonyManager.NETWORK_TYPE_HSPA:
+                            case 12: // TelephonyManager.NETWORK_TYPE_EVDO_B:
+                            case 14: // TelephonyManager.NETWORK_TYPE_EHRPD:
+                            case 15: // TelephonyManager.NETWORK_TYPE_HSPAP:
+                                return LinkNetWorkType._3G;
+                            case 13: // TelephonyManager.NETWORK_TYPE_LTE:
+                                return LinkNetWorkType._4G;
+                            default:
+                                return LinkNetWorkType._2G;
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+            return LinkNetWorkType.UNKNOWN;
+        }
+        return LinkNetWorkType.UNKNOWN;
+    }
+}

+ 493 - 0
app/src/main/java/com/wdkl/nursewatch/utils/PalyPhonetics.java

@@ -0,0 +1,493 @@
+package com.wdkl.nursewatch.utils;
+
+import android.content.Context;
+import android.media.AudioManager;
+import android.media.MediaPlayer;
+import android.util.DisplayMetrics;
+
+import com.wdkl.nursewatch.MyApplication;
+import com.wdkl.nursewatch.R;
+import com.wdkl.nursewatch.common.Constants;
+import com.wdkl.nursewatch.entity.MessageEntity;
+
+import java.util.ArrayList;
+
+/**
+ * 类名称:PalyPhonetics <br>
+ * 类描述:语音播报工具类 <br>
+ * 创建人:Waderson Shll (TEL:15675117662)<br>
+ * 创建时间:2017-11-01 <br>
+ * 注意:以判断结束回调的方式播放连续性并不好;所以本人考虑采用阻塞式;由于阻塞的必要性;本人建议将此类的执行放于子线程 <br>
+ * 特别提醒:如有需要该类可任意创建与调用;在未通知本人的情况下该类禁止任何修改!<br>
+ *
+ * @version V1.0
+ */
+public class PalyPhonetics {
+
+    public MediaPlayer mediaPlayer;
+    public Context context;
+    /**
+     * 左声道
+     */
+    public float leftVolume = MyApplication.PalyPhoneticsVolume;
+    /**
+     * 右声道
+     */
+    public float rightVolume = MyApplication.PalyPhoneticsVolume;
+    /**
+     * 循环次数
+     */
+    public int looping = 3;
+
+    private static PalyPhonetics palyphonetics;
+
+    public static PalyPhonetics getInstance(Context context) {
+        if (palyphonetics == null) {
+            synchronized (PalyPhonetics.class) {
+                if (palyphonetics == null) {
+                    palyphonetics = new PalyPhonetics(context);
+                }
+            }
+        }
+        return palyphonetics;
+    }
+
+    private PalyPhonetics(Context context) {
+        this.context = context;
+    }
+
+    public void speak(final ArrayList<Integer> resIdlist) throws InterruptedException {
+        if (MyApplication.PALYDISMISS) return;
+        if (!MyApplication.IS_HAVE_SPEAK) return;
+        if (null != mediaPlayer) mediaPlayer.release();
+        mediaPlayer = MediaPlayer.create(context, R.raw.notice);
+        mediaPlayer.setLooping(false);
+        mediaPlayer.setVolume(leftVolume, rightVolume);
+        mediaPlayer.start();
+        Thread.sleep(getMillis(R.raw.notice));
+        for (int x = 0; x < looping; x++) {
+            if (MyApplication.PALYDISMISS) return;
+            for (int i = 0; i < resIdlist.size(); i++) {
+                if (MyApplication.PALYDISMISS) return;
+                if (null != mediaPlayer) mediaPlayer.release();
+                mediaPlayer = MediaPlayer.create(context, resIdlist.get(i));
+                mediaPlayer.setVolume(leftVolume, rightVolume);
+                mediaPlayer.start();
+                long milli = getMillis(resIdlist.get(i));
+                if (i == resIdlist.size() - 1) {
+                    milli += 200;
+                }
+                Thread.sleep(milli);
+            }
+        }
+    }
+
+    public long getMillis(int id) {
+        if (isWatch(context)) {
+            return getMillisM(id);
+        } else {
+            return getMillisL(id);
+        }
+    }
+
+    public long getMillisM(int id) {
+        if (id == R.raw.zero || id == R.raw.one || id == R.raw.two || id == R.raw.three || id == R.raw.four ||
+                id == R.raw.five || id == R.raw.six || id == R.raw.seven || id == R.raw.eight || id == R.raw.nine) {
+            return 360;
+        } else if (id == R.raw.chuang || id == R.raw.hao) {
+            return 380;
+        } else if (id == R.raw.fang) {
+            return 430;
+        } else if (id == R.raw.hujiao || id == R.raw.jinji || id == R.raw.zhuji) {
+            return 680;
+        } else if (id == R.raw.menkoji || id == R.raw.weishejian) {
+            return 820;
+        } else if (id == R.raw.zhinenshouwan || id == R.raw.zhujihujiao || id == R.raw.jinjihujiao || id == R.raw.qingqiuzhenyuan) {
+            return 1000;
+        } else if (id == R.raw.notice) {
+            return 2800;
+        }
+        return 700;
+    }
+
+    public long getMillisL(int id) {
+        if (id == R.raw.zero || id == R.raw.one || id == R.raw.two || id == R.raw.three || id == R.raw.four ||
+                id == R.raw.five || id == R.raw.six || id == R.raw.seven || id == R.raw.eight || id == R.raw.nine || id == R.raw.ten) {
+            return 460;
+        } else if (id == R.raw.chuang || id == R.raw.hao) {
+            return 500;
+        } else if (id == R.raw.fang) {
+            return 530;
+        } else if (id == R.raw.hujiao || id == R.raw.jinji || id == R.raw.zhuji) {
+            return 720;
+        } else if (id == R.raw.menkoji || id == R.raw.weishejian) {
+            return 890;
+        } else if (id == R.raw.zhinenshouwan || id == R.raw.zhujihujiao || id == R.raw.jinjihujiao || id == R.raw.qingqiuzhenyuan) {
+            return 1150;
+        } else if (id == R.raw.notice) {
+            return 2900;
+        }
+        return 700;
+    }
+
+    public int getResIdInt(String num) {
+        switch (num) {
+            case "0":
+                return R.raw.zero;
+            case "1":
+                return R.raw.one;
+            case "2":
+                return R.raw.two;
+            case "3":
+                return R.raw.three;
+            case "4":
+                return R.raw.four;
+            case "5":
+                return R.raw.five;
+            case "6":
+                return R.raw.six;
+            case "7":
+                return R.raw.seven;
+            case "8":
+                return R.raw.eight;
+            case "9":
+                return R.raw.nine;
+            case "十":
+                return R.raw.ten;
+        }
+        return R.raw.zero;
+    }
+
+    /**
+     * 改变床号的播报格式<br></>
+     *
+     * deleteFront0 :是否要将前面的“0”去掉?
+     *
+     */
+    public String changeNumType(String num, boolean deleteFront0) {
+        if (!StringUtils.notEmpty(num)) return "0";
+        String n = "";
+        if (deleteFront0) {
+            n = changeNum(num);
+        } else {
+            n = num;
+        }
+
+        if (n.length() <= 1 || n.length() >= 3) return n;
+
+        if ("1".equals(StringUtils.substringByLengh(n, 0, 1))) {
+            if ("0".equals(StringUtils.substringByLengh(n, 1, 2))) {
+                return "十";
+            } else {
+                return "十" + StringUtils.deleteCharAt(n, 0);
+            }
+        } else if ("0".equals(StringUtils.substringByLengh(n, 0, 1))) {
+            return n;
+        } else {
+            if ("0".equals(StringUtils.substringByLengh(n, 1, 2))) {
+                return StringUtils.substringByLengh(n, 0, 1) + "十";
+            } else {
+                return StringUtils.substringByLengh(n, 0, 1) + "十" + StringUtils.substringByLengh(n, 1, 2);
+            }
+        }
+    }
+
+    /**
+     * 前面去0操作
+     */
+    public String changeNum(String num) {
+        String n = num;
+        if (!StringUtils.notEmpty(n))
+            return "0";
+        if (n.length() <= 1)
+            return n;
+
+        if ("0".equals(StringUtils.substringByLengh(n, 0, 1))) {
+            n = StringUtils.deleteCharAt(n, 0);
+        } else {
+            return n;
+        }
+        return changeNum(n);
+    }
+
+    /**
+     * 是否需要轮播
+     */
+    public static void setPalyDismiss(boolean palyDismiss) {
+        MyApplication.PALYDISMISS = palyDismiss;
+    }
+
+    /**
+     * 设置音量;左右音道一样<br></>
+     * 该方法我在内部调用,外部调用反应速度太慢,作过时标记。
+     */
+    @Deprecated
+    public void setVolume(float volume) {
+        this.leftVolume = this.rightVolume = MyApplication.PalyPhoneticsVolume = volume;
+    }
+
+    /**
+     * 设置音量;
+     */
+    public void setVolumes(float volume) {
+        AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
+        if (volume <= 0.0f) {
+            audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 0, 0);
+        } else if (volume >= 1.0f) {
+            audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 100, 0);
+        } else {
+            audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 60, 0);
+        }
+    }
+
+    /**
+     * 设置音量;
+     */
+    public void setVolumes(Context context, float volume) {
+        AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
+        if (volume <= 0.0f) {
+            audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 0, 0);
+        } else if (volume >= 1.0f) {
+            audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 100, 0);
+        } else {
+            audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 60, 0);
+        }
+    }
+
+    public float getLeftVolume() {
+        return leftVolume;
+    }
+
+    public void setLeftVolume(float leftVolume) {
+        this.leftVolume = leftVolume;
+    }
+
+    public float getRightVolume() {
+        return rightVolume;
+    }
+
+    public void setRightVolume(float rightVolume) {
+        this.rightVolume = rightVolume;
+    }
+
+    public int getLooping() {
+        return looping;
+    }
+
+    public void setLooping(int looping) {
+        this.looping = looping;
+    }
+
+    public boolean isWatch(Context context) {
+        DisplayMetrics dm = context.getResources().getDisplayMetrics();
+        if (null != dm) {
+            int screenWidth = dm.widthPixels; // 屏幕宽(像素,如:480px)
+            int screenHeight = dm.heightPixels;
+            LogUtil.d("getScreenInfo", "screenWidth==" + screenWidth + "----screenHeight==" + screenHeight);
+            int densityDpi = dm.densityDpi;
+            float density = dm.density;
+            LogUtil.d("getScreenInfo", "densityDpi==" + densityDpi + "----density==" + density);
+            float scaledDensity = dm.scaledDensity;
+            float xDpi = dm.xdpi;
+            float yDpi = dm.ydpi;
+            LogUtil.d("getScreenInfo", "scaledDensity==" + scaledDensity + "----xDpi==" + xDpi + "----yDpi==" + yDpi);
+            if (screenWidth == screenHeight) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    /**
+     * 语音轮播线程
+     */
+    Thread palyPhoneticsThread;
+    /**
+     * 语音播报循环次数
+     */
+    public static int speakLooping = 3;
+    /**
+     * 是否需要轮流播报
+     */
+    public boolean have_Speak = true;
+    /**
+     * 语音轮播的当前实体
+     */
+    public static MessageEntity loopingUdpentity;
+
+    public static boolean thisEntityIsSpeaking(MessageEntity m) {
+        if (null == m) return false;
+        return MessageEntity.equalsThisEntity(m, loopingUdpentity);
+    }
+
+    public void startPalyPhonetics() {
+        if (null == palyPhoneticsThread) {
+            palyPhoneticsThread = new Thread(new palyPhoneticsRunnable());
+            palyPhoneticsThread.start();
+        } else if (null != palyPhoneticsThread && !palyPhoneticsThread.isAlive()) {
+            palyPhoneticsThread.start();
+        }
+    }
+
+    public class palyPhoneticsRunnable implements Runnable {
+        public void run() {
+            while (have_Speak) {
+                palyPhonetics();
+            }
+        }
+    }
+
+    /**
+     * 播放语音(waderson 20171031)
+     */
+    public void palyPhonetics() {
+        LogUtil.d("palyPhonetics", "size==" + MyApplication.speakEntityList.size());
+        if (!MyApplication.IS_HAVE_SPEAK) return;
+        if (null != MyApplication.speakEntityList && MyApplication.speakEntityList.size() > 0) {
+            String voiceBroadcastType;
+            boolean haveRoomNum=SharedPreferencesUtil.getBooleanSp(SharedPreferencesUtil.SETTING_BROADCASTING_ROOM_NUMBER);
+            if(haveRoomNum){
+                voiceBroadcastType = "1";
+            }else{
+                voiceBroadcastType = "0";
+            }
+
+            setVolumes(1.0f);
+
+            setPalyDismiss(false);
+            setLooping(speakLooping);
+            loopingUdpentity = MyApplication.speakEntityList.get(0);
+            ArrayList<Integer> resIdlist = new ArrayList<>();
+            resIdlist.clear();
+
+            String type = loopingUdpentity.getDataEight();
+            String rnb = loopingUdpentity.getDataFive();
+            String bnb = loopingUdpentity.getDataSix();
+            String roomnumber = changeNumType(rnb,false);
+            String bednumber = changeNumType(bnb,false);
+            switch (type) {
+                case Constants.DOOR_CALL: //门口机
+                    ArrayList<String> list_str1 = StringUtils.substringBySing(roomnumber);
+                    if (null != list_str1) {
+                        for (String s : list_str1) {
+                            resIdlist.add(getResIdInt(s));
+                        }
+                        resIdlist.add(R.raw.fang);
+                        resIdlist.add(R.raw.menkoji);
+                        resIdlist.add(R.raw.hujiao);
+                    }
+                    break;
+                case Constants.MAIN_CALL://主机
+                    ArrayList<String> list_str2 = StringUtils.substringBySing(roomnumber);
+                    if (null != list_str2) {
+                        for (String s : list_str2) {
+                            resIdlist.add(getResIdInt(s));
+                        }
+                        resIdlist.add(R.raw.hao);
+                        resIdlist.add(R.raw.zhujihujiao);
+                    }
+                    break;
+                case Constants.SON_CALL://床位
+                    ArrayList<String> list_str3 = StringUtils.substringBySing(roomnumber);
+                    ArrayList<String> list_str33 = StringUtils.substringBySing(bednumber);
+                    if (null != list_str3 && "1".equals(voiceBroadcastType)) {//是否要播报“房” 0不要  1要
+                        for (String s : list_str3) {
+                            resIdlist.add(getResIdInt(s));
+                        }
+                        resIdlist.add(R.raw.fang);
+                    }
+
+                    if (null != list_str33) {
+                        for (String s : list_str33) {
+                            resIdlist.add(getResIdInt(s));
+                        }
+                        resIdlist.add(R.raw.chuang);
+                        resIdlist.add(R.raw.hujiao);
+                    }
+                    break;
+                case Constants.TRADITION_CALL://床位
+                    ArrayList<String> list_str6 = StringUtils.substringBySing(roomnumber);
+                    ArrayList<String> list_str66 = StringUtils.substringBySing(bednumber);
+                    if (null != list_str6 && "1".equals(voiceBroadcastType)) {//是否要播报“房” 0不要  1要
+                        for (String s : list_str6) {
+                            resIdlist.add(getResIdInt(s));
+                        }
+                        resIdlist.add(R.raw.fang);
+                    }
+                    if (null != list_str66) {
+
+                        for (String s : list_str66) {
+                            resIdlist.add(getResIdInt(s));
+                        }
+                        resIdlist.add(R.raw.chuang);
+                        resIdlist.add(R.raw.hujiao);
+                    }
+                    break;
+                case Constants.ROOMHELP_CALL://请求增援
+                    ArrayList<String> list_str4 = StringUtils.substringBySing(roomnumber);
+                    ArrayList<String> list_str44 = StringUtils.substringBySing(bednumber);
+                    if (null != list_str4 && "1".equals(voiceBroadcastType)) {//是否要播报“房” 0不要  1要
+                        for (String s : list_str4) {
+                            resIdlist.add(getResIdInt(s));
+                        }
+                        resIdlist.add(R.raw.fang);
+                    }
+                    if (null != list_str44) {
+                        for (String s : list_str44) {
+                            resIdlist.add(getResIdInt(s));
+                        }
+                        resIdlist.add(R.raw.chuang);
+                    }
+                    resIdlist.add(R.raw.qingqiuzhenyuan);
+                    break;
+                case Constants.WSHROOM_CALL://卫生间
+                    ArrayList<String> list_str5 = StringUtils.substringBySing(roomnumber);
+                    if (null != list_str5) {
+                        for (String s : list_str5) {
+                            resIdlist.add(getResIdInt(s));
+                        }
+                        resIdlist.add(R.raw.fang);
+                        resIdlist.add(R.raw.weishejian);
+                        resIdlist.add(R.raw.jinjihujiao);
+                    }
+                    break;
+            }
+            try {
+                speak(resIdlist);
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+            if (MyApplication.speakEntityList.contains(loopingUdpentity)) {
+                MyApplication.speakEntityList.remove(loopingUdpentity);
+            }
+            //if (null != speakEntityList && speakEntityList.size() > 0) {
+            //    speakEntityList.remove(0);
+            //}
+        }
+    }
+
+    public void addPhonetics(MessageEntity udpEntity) {
+        startPalyPhonetics();
+        MyApplication.speakEntityList.add(udpEntity);
+    }
+
+    public static boolean deleteCallEntity(MessageEntity messageEntity) {
+        if (null == messageEntity) return false;
+        try {
+            if (StringUtils.listNotEmpty(MyApplication.speakEntityList)) {
+                for (int i = 0; i < MyApplication.speakEntityList.size(); i++) {
+                    if (MessageEntity.equalsThisEntity(MyApplication.speakEntityList.get(i), messageEntity)) {
+                        MyApplication.speakEntityList.remove(i);
+                    }
+                }
+            } else {
+                return false;
+            }
+        } catch (Exception e) {
+            return false;
+        }
+        return true;
+    }
+
+}

+ 407 - 0
app/src/main/java/com/wdkl/nursewatch/utils/PhoneUtils.java

@@ -0,0 +1,407 @@
+package com.wdkl.nursewatch.utils;
+
+import android.Manifest;
+import android.app.Activity;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.content.res.Configuration;
+import android.net.wifi.WifiInfo;
+import android.net.wifi.WifiManager;
+import android.os.Build;
+import android.os.Vibrator;
+import android.provider.Settings;
+import android.support.v4.app.ActivityCompat;
+import android.telephony.TelephonyManager;
+import android.util.DisplayMetrics;
+
+import com.wdkl.nursewatch.MyApplication;
+import com.wdkl.nursewatch.presentation.ui.activities.MainActivity;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.util.UUID;
+
+public class PhoneUtils {
+
+    public static String getUUIDstr(Context context) {
+        if (StringUtils.notEmpty(getUUID(context))) {
+            return getUUID(context);
+        } else {
+            return getUUID();
+        }
+    }
+
+    public static String getUUID(Context context) {
+        String uniqueId = null;
+        final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+        String tmDevice, tmSerial, androidId;
+        if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
+            ToastUtil.showToast(context, "没有权限");
+            return "";
+        }
+        tmDevice = "" + tm.getDeviceId();
+        tmSerial = "" + tm.getSimSerialNumber();
+        androidId = "" + android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
+        UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
+        uniqueId = deviceUuid.toString();
+        LogUtil.d("getUUID", "UUID--1==" + uniqueId);
+        return uniqueId;
+    }
+
+    public static String getUUID() {
+        UUID uuid = UUID.randomUUID();
+        String uniqueId = uuid.toString();
+        LogUtil.d("getUUID", "UUID--2==" + uuid);
+        return uniqueId;
+    }
+
+    /**
+     * IMEI(International Mobile Equipment Identity)是国际移动设备身份码的缩写,国际移动装备辨识码,
+     * 是由15位数字组成的”电子串号”,它与每台移动电话机一一对应,而且该码是全世界唯一的。
+     * 每一只移动电话机在组装完成后都将被赋予一个全球唯一的一组号码,这个号码从生产到交付使用都将被制造生产的厂商所记录。
+     * PS:通俗来讲就是标识你当前设备(手机)全世界唯一,类似于个人身份证,这个肯定唯一啦~
+     */
+    public static String getIMEI(Context context) {
+        try {
+            //实例化TelephonyManager对象
+            TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+            //获取IMEI号
+            if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
+                ToastUtil.showToast(context, "没有权限");
+                return "";
+            }
+            String imei = telephonyManager.getDeviceId();
+            //在次做个验证,也不是什么时候都能获取到的啊
+            if (imei == null) {
+                imei = "";
+            }
+            return imei;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return "";
+        }
+    }
+
+    /**
+     * MEID是CDMA手机的识别码
+     */
+    public static String getMEID(Context context) {
+        TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+        if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
+            ToastUtil.showToast(context, "没有权限");
+            return "";
+        }
+        String meid = "";
+        try {
+            Method method = manager.getClass().getMethod("getDeviceId", int.class);
+            meid = (String) method.invoke(manager, 2);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return meid;
+    }
+
+    /**
+     * 国际移动用户识别码(IMSI:International Mobile Subscriber Identification
+     * Number)是区别移动用户的标志,储存在SIM卡中,可用于区别移动用户的有效信息。其总长度不超过15位,同样使用0~9的数字。
+     * 其中MCC是移动用户所属国家代号,占3位数字,中国的MCC规定为460;MNC是移动网号码,由两位或者三位数字组成,中国移动的移动网络编码(MNC)为00;
+     * 用于识别移动用户所归属的移动通信网;MSIN是移动用户识别码,用以识别某一移动通信网中的移动用户
+     * PS:通俗来讲就是标识你当前SIM卡(手机卡)唯一,同样类似于个人身份证,肯定唯一啦~
+     */
+    public static String getIMSI(Context context) {
+        try {
+            TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+            if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
+                ToastUtil.showToast(context, "没有权限");
+                return "";
+            }
+            String imsi = telephonyManager.getSubscriberId();
+            if (null == imsi) {
+                imsi = "";
+            }
+            return imsi;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return "";
+        }
+    }
+
+    public static String getIccId(Context context) {
+        String iccid = iccId(context);
+        if (StringUtils.notEmpty(iccid)) {
+            return iccid;
+        } else {
+            iccid = iccId_2(context);
+        }
+        return iccid;
+    }
+
+    /**
+     * IccId
+     */
+    public static String iccId(Context context) {
+        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+        if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
+            ToastUtil.showToast(context, "没有权限");
+            return "";
+        }
+        return tm.getSimSerialNumber();
+    }
+
+    /**
+     * IccId
+     */
+    public static String iccId_2(Context context) {
+        String iccid = "";
+        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+        try {
+            Method method = tm.getClass().getDeclaredMethod("getSubscriberInfo");
+            try {
+                method.setAccessible(true);
+                Object obj = method.invoke(tm);
+                Method method2 = obj.getClass().getDeclaredMethod("getPhone", int.class);
+                method2.setAccessible(true);
+                Object obj2 = method2.invoke(obj, 0);
+                Method method3 = obj2.getClass().getMethod("getFullIccSerialNumber");
+                iccid = (String) method3.invoke(obj2);
+            } catch (IllegalAccessException e) {
+                e.printStackTrace();
+            } catch (InvocationTargetException e) {
+                e.printStackTrace();
+            }
+        } catch (NoSuchMethodException e) {
+            e.printStackTrace();
+        }
+        return iccid;
+    }
+
+    /**
+     * 根据Wifi信息获取本地Mac(该方法只能在6.0以下才能用,这个方法在安卓6.0之后便只能获取到02:00:00:00:00)
+     */
+    public static String getLocalMacAddressFromWifi(Context context) {
+        WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+        if (!wifi.isWifiEnabled()) wifi.setWifiEnabled(true);
+        WifiInfo info = (null == wifi ? null : wifi.getConnectionInfo());
+        if (null != info) {
+            return info.getMacAddress();
+        } else {
+            return "";
+        }
+    }
+
+    /**
+     * 根据Wifi信息获取本地Mac
+     */
+    public static String getLocalMacAddress(Context context, boolean transformMac) {
+        //WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+        //if (!wifi.isWifiEnabled()) wifi.setWifiEnabled(true);
+        String macAddress = "";
+        StringBuffer buf = new StringBuffer();
+        NetworkInterface networkInterface = null;
+        try {
+            networkInterface = NetworkInterface.getByName("eth1");
+            if (networkInterface == null) {
+                networkInterface = NetworkInterface.getByName("wlan0");
+            }
+            if (networkInterface == null) return "02:00:00:00:00:00";
+            byte[] addr = networkInterface.getHardwareAddress();
+            for (byte b : addr) {
+                buf.append(String.format("%02X:", b));
+            }
+            if (buf.length() > 0) {
+                buf.deleteCharAt(buf.length() - 1);
+            }
+            macAddress = buf.toString();
+        } catch (SocketException e) {
+            e.printStackTrace();
+            return "02:00:00:00:00:00";
+        }
+        if (transformMac) {
+            return transformMacAddress(macAddress);
+        } else {
+            return macAddress;
+        }
+    }
+
+    /**
+     * 把Mac地址的“:”去掉,把大写转成小写
+     */
+    public static String transformMacAddress(String str) {
+        return StringUtils.smallerCapitalTo(StringUtils.replaceStr(str, ":"));
+    }
+
+    /**
+     * 获取电话号码
+     */
+    public static String getNativePhoneNumber(Context context) {
+        TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+        if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_SMS) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_NUMBERS) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
+            ToastUtil.showToast(context, "没有权限");
+            return "";
+        }
+        String num = telephonyManager.getLine1Number();
+        if (!StringUtils.notEmpty(num) || num.length() < 8) {
+            return "----";
+        }
+        return num;
+    }
+
+
+    public static final String endString = "wdkl";
+
+    /**
+     * 获取手机唯一码
+     *
+     * @param context
+     * @return
+     */
+    public static String getOnlyCodeForPhone(Context context) {
+        return getAndroidID(context) + getIMEI2(context) + endString;
+    }
+
+    /**
+     * 获取手机IMEI
+     *
+     * @param context
+     * @return
+     */
+    public static String getIMEI2(Context context) {
+        try {
+            //实例化TelephonyManager对象
+            TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+            if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
+                LogUtil.d("getIMEI2", "没有权限");
+                return "";
+            }
+            String imei = telephonyManager.getDeviceId();
+            if (imei == null) {
+                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+                    imei = telephonyManager.getDeviceId(0);
+                }
+            }
+            if (imei == null) {
+                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+                    imei = telephonyManager.getDeviceId(1);
+                }
+            }
+            //String simOperatorName = telephonyManager.getSimOperatorName();
+            if (imei == null) {
+                imei = "";
+            }
+            return imei;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return "";
+        }
+
+    }
+
+    /**
+     * 获取手机IMEI
+     *
+     * @param context
+     * @return
+     */
+    public static String getAndroidID(Context context) {
+        return Settings.Secure.getString(context.getApplicationContext().getContentResolver(), Settings.Secure.ANDROID_ID);
+    }
+
+    /**
+     * 检测是否有电话卡
+     */
+    public static boolean checkHaveCards(Activity activity) {
+        if (ActivityCompat.checkSelfPermission(activity, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
+            String[] permission = {Manifest.permission.READ_PHONE_STATE};
+            ActivityCompat.requestPermissions(activity, permission, 2019);
+            return false;
+        } else {
+//            TelephonyManager tm = (TelephonyManager) activity.getSystemService(Context.TELEPHONY_SERVICE);
+//            String simSer = tm.getSimSerialNumber();
+//            if (!StringUtils.notEmpty(simSer)) {
+//                return false;
+//            }
+
+            TelephonyManager manager = (TelephonyManager) activity.getSystemService(Context.TELEPHONY_SERVICE);
+            String imsi = manager.getSubscriberId();
+            if (!StringUtils.notEmpty(imsi)) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    public static boolean killCall(Context context) {
+        try {
+            // Get the boring old TelephonyManager
+            TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+            // Get the getITelephony() method
+            Class classTelephony = Class.forName(telephonyManager.getClass().getName());
+            Method methodGetITelephony = classTelephony.getDeclaredMethod("getITelephony");
+            // Ignore that the method is supposed to be private
+            methodGetITelephony.setAccessible(true);
+            // Invoke getITelephony() to get the ITelephony interface
+            Object telephonyInterface = methodGetITelephony.invoke(telephonyManager);
+            // Get the endCall method from ITelephony
+            Class telephonyInterfaceClass = Class.forName(telephonyInterface.getClass().getName());
+            Method methodEndCall = telephonyInterfaceClass.getDeclaredMethod("endCall");
+            // Invoke endCall()
+            methodEndCall.invoke(telephonyInterface);
+        } catch (Exception ex) { // Many things can go wrong with reflection calls
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * 判断当前设备是手机还是平板
+     *
+     * @param context
+     * @return 平板返回 True,手机返回 False
+     */
+    public static boolean isPad(Context context) {
+        return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK)
+                >= Configuration.SCREENLAYOUT_SIZE_LARGE;
+    }
+
+    /**
+     * 判断当前设备是不是腕表
+     *
+     * @param context
+     * @return 腕表返回 True,否则返回 False
+     */
+    public static boolean isWatch(Context context) {
+        DisplayMetrics dm = context.getResources().getDisplayMetrics();
+        if (null != dm) {
+            int screenWidth = dm.widthPixels; // 屏幕宽(像素,如:480px)
+            int screenHeight = dm.heightPixels;
+            LogUtil.d("getScreenInfo", "screenWidth==" + screenWidth + "----screenHeight==" + screenHeight);
+
+            if ((screenWidth / screenHeight) == 9 / 16 || (screenWidth / screenHeight) == 10 / 16) {
+                return false;
+            }
+            if ((screenWidth / screenHeight) == 1 || (screenWidth / screenHeight) >= 14 / 16 || (screenHeight / screenWidth) >= 14 / 16) {
+                return true;
+            }
+
+        }
+        return false;
+    }
+
+    /**
+     * 震动
+     *
+     * @param milliseconds
+     */
+    public static void isVibrator(long milliseconds) {
+        Boolean isVibrator = SharedPreferencesUtil.getBooleanSp(SharedPreferencesUtil.SETTING_SHAKE);
+        if (isVibrator) {
+            Vibrator vibrator = (Vibrator) MyApplication.getAppContext().getSystemService(Context.VIBRATOR_SERVICE);
+            vibrator.vibrate(milliseconds);//震动
+        }
+    }
+
+}
+

+ 69 - 0
app/src/main/java/com/wdkl/nursewatch/utils/ReceiverUtil.java

@@ -0,0 +1,69 @@
+package com.wdkl.nursewatch.utils;
+
+import android.app.Activity;
+import android.content.BroadcastReceiver;
+import android.content.Intent;
+import android.content.IntentFilter;
+
+import com.wdkl.nursewatch.MyApplication;
+
+public class ReceiverUtil {
+
+    public static final String BATTERY_STATA= "com.wdkl.nurse_watch.BATTERY_STATA";
+
+    /**
+     * 发送广播
+     */
+    public static void sendBroadcast(String action) {
+        Intent intent = new Intent();
+        intent.setAction(action);
+        MyApplication.getAppContext().sendBroadcast(intent);
+
+    }
+
+    public static void sendBroadcast(String action, Intent intent) {
+        intent.setAction(action);
+        MyApplication.getAppContext().sendBroadcast(intent);
+
+    }
+
+    public static void sendBroadcast(Activity activity, String action) {
+        Intent intent = new Intent();
+        intent.setAction(action);
+        activity.sendBroadcast(intent);
+
+    }
+
+    public static void sendBroadcast(Activity activity, String action, Intent intent) {
+        intent.setAction(action);
+        activity.sendBroadcast(intent);
+
+    }
+
+    /**
+     * 动态注册一个广播
+     */
+    public static void registReceiver(Activity activity, BroadcastReceiver receiver, String action, int pro) {
+        IntentFilter intentFilter = new IntentFilter();
+        intentFilter.addAction(action);
+        intentFilter.setPriority(pro);
+        activity.registerReceiver(receiver, intentFilter);
+    }
+    public static void registReceiver(Activity activity, BroadcastReceiver receiver, String action) {
+        IntentFilter intentFilter = new IntentFilter();
+        intentFilter.addAction(action);
+        activity.registerReceiver(receiver, intentFilter);
+    }
+    public static void registReceiver(BroadcastReceiver receiver, String action, int pro) {
+        IntentFilter intentFilter = new IntentFilter();
+        intentFilter.addAction(action);
+        intentFilter.setPriority(pro);
+        MyApplication.getAppContext().registerReceiver(receiver, intentFilter);
+    }
+    public static void registReceiver(BroadcastReceiver receiver, String action) {
+        IntentFilter intentFilter = new IntentFilter();
+        intentFilter.addAction(action);
+        MyApplication.getAppContext().registerReceiver(receiver, intentFilter);
+    }
+
+}

+ 162 - 0
app/src/main/java/com/wdkl/nursewatch/utils/SaveCallListUtil.java

@@ -0,0 +1,162 @@
+package com.wdkl.nursewatch.utils;
+
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+import com.wdkl.nursewatch.MyApplication;
+import com.wdkl.nursewatch.entity.MessageEntity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class SaveCallListUtil {
+    /**
+     * 获取所有的呼叫记录
+     * @return
+     */
+    public static List<MessageEntity> getCallList() {
+        String callListStr = SharedPreferencesUtil.getStringSp(SharedPreferencesUtil.CALLING_LIST);
+        if (!StringUtils.notEmpty(callListStr)) return null;
+        return new Gson().fromJson(callListStr, new TypeToken<List<MessageEntity>>() {
+        }.getType());
+    }
+
+    /**
+     * 添加一个呼叫记录
+     * @param messageEntity
+     * @return
+     */
+    public static boolean saveCallEntity(MessageEntity messageEntity) {
+        if (null == messageEntity) return false;
+        try {
+            List<MessageEntity> oldList = getCallList();
+            if (StringUtils.listNotEmpty(oldList)) {
+                oldList.add(messageEntity);
+            } else {
+                oldList = new ArrayList<>();
+                oldList.add(messageEntity);
+            }
+
+            String jsonStr = new Gson().toJson(oldList);
+            SharedPreferencesUtil.putStringSp(SharedPreferencesUtil.CALLING_LIST, jsonStr);
+        } catch (Exception e) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * 删除呼叫机记录中的一条
+     * @param messageEntity
+     * @return
+     */
+    public static boolean deleteCallEntity(MessageEntity messageEntity) {
+        if (null == messageEntity) return false;
+        try {
+            List<MessageEntity> oldList = getCallList();
+            if (StringUtils.listNotEmpty(oldList)) {
+                for (int i = 0; i < oldList.size(); i++) {
+                    if (MessageEntity.equalsThisEntity(oldList.get(i), messageEntity)) {
+                        oldList.remove(i);
+                    }
+                }
+            } else {
+                return false;
+            }
+            String jsonStr = new Gson().toJson(oldList);
+            SharedPreferencesUtil.putStringSp(SharedPreferencesUtil.CALLING_LIST, jsonStr);
+        } catch (Exception e) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * 删除所有的呼叫记录
+     */
+    public static void deleteAllEntity() {
+        try {
+            List<MessageEntity> list = new ArrayList<>();
+            String jsonStr = new Gson().toJson(list);
+            SharedPreferencesUtil.putStringSp( SharedPreferencesUtil.CALLING_LIST, jsonStr);
+        } catch (Exception e) {
+
+        }
+    }
+
+
+    /**
+     * 获取当前呼叫总数
+     * */
+    public static List<MessageEntity> getCallListNow() {
+        String callListStr = SharedPreferencesUtil.getStringSp(SharedPreferencesUtil.CALLING_LIST_NOW);
+        if (!StringUtils.notEmpty(callListStr)) return null;
+        return new Gson().fromJson(callListStr, new TypeToken<List<MessageEntity>>() {
+        }.getType());
+    }
+
+    /**
+     * 添加一个当前呼叫
+     * @param messageEntity
+     * @return
+     */
+    public static boolean saveCallEntityNow(MessageEntity messageEntity) {
+        if (null == messageEntity) return false;
+        try {
+            List<MessageEntity> oldList = getCallListNow();
+            if (StringUtils.listNotEmpty(oldList)) {
+                oldList.add(messageEntity);
+            } else {
+                oldList = new ArrayList<>();
+                oldList.add(messageEntity);
+            }
+
+            String jsonStr = new Gson().toJson(oldList);
+            SharedPreferencesUtil.putStringSp(SharedPreferencesUtil.CALLING_LIST_NOW, jsonStr);
+        } catch (Exception e) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * 删除当前呼叫中的一个
+     * @param messageEntity
+     * @return
+     */
+    public static boolean deleteCallEntityNow(MessageEntity messageEntity) {
+        if (null == messageEntity) return false;
+        try {
+            List<MessageEntity> oldList = getCallListNow();
+            LogUtil.d("deleteCallEntityNow", oldList.size() + "====1");
+            if (StringUtils.listNotEmpty(oldList)) {
+                for (int i = 0; i < oldList.size(); i++) {
+                    if (MessageEntity.equalsThisEntity(oldList.get(i), messageEntity)) {
+                        oldList.remove(i);
+                    }
+                }
+            } else {
+                return false;
+            }
+            LogUtil.d("deleteCallEntityNow", oldList.size() + "====2");
+            String jsonStr = new Gson().toJson(oldList);
+            SharedPreferencesUtil.putStringSp(SharedPreferencesUtil.CALLING_LIST_NOW, jsonStr);
+        } catch (Exception e) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * 删除当前所有的呼叫
+     */
+    public static void deleteAllEntityNow() {
+        try {
+            List<MessageEntity> list = new ArrayList<>();
+            String jsonStr = new Gson().toJson(list);
+            SharedPreferencesUtil.putStringSp( SharedPreferencesUtil.CALLING_LIST_NOW, jsonStr);
+        } catch (Exception e) {
+
+        }
+    }
+
+}

+ 120 - 0
app/src/main/java/com/wdkl/nursewatch/utils/SharedPreferencesUtil.java

@@ -0,0 +1,120 @@
+package com.wdkl.nursewatch.utils;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.SharedPreferences;
+
+import com.wdkl.nursewatch.MyApplication;
+
+/**
+ * 类名称:SharedPreferencesUtil <br>
+ * 类描述:SharedPreferences存储工具类<br>
+ * 创建人:Waderson Shll <br>
+ * 创建时间:2017-12-11 <br>
+ *
+ * @version V1.0
+ */
+public class SharedPreferencesUtil {
+
+    public static final String LOGIN_TAG = "LOGIN_TAG";         //是否绑定成功
+    public static final String LOGIN_SERVERID="LOGIN_SERVERID"; //服务器ID
+    public static final String LOGIN_DEPARTMENTSID="LOGIN_DEPARTMENTSID";//科室ID
+    public static final String LOGIN_NURSE_ID="LOGIN_NURSE_ID";          //护士ID
+    public static final String LOGIN_NURSE_NAME="LOGIN_NURSE_NAME";      //护士名字
+
+    public static final String SETTING_SHAKE="SETTING_SHAKE";//设置震动
+    public static final String SETTING_VOICE_BROADCAST="SETTING_VOICE_BROADCAST";  //设置语音播报
+    public static final String SETTING_BROADCASTING_ROOM_NUMBER="SETTING_BROADCASTING_ROOM_NUMBER";//设置播报房号
+    public static final String CALLING_LIST="CALLING_LIST";//呼叫记录
+
+    public static final String CALLING_LIST_NOW="CALLING_LIST_NOW";//当前呼叫列表
+    private static final String PREFERENCES_VAR = "NurseWatch";
+
+    private static SharedPreferences mySharedPreferences;
+    private static SharedPreferences.Editor editor;
+
+    public static void initSharedPreferences(int mode) {
+        if (mySharedPreferences == null) {
+            synchronized (SharedPreferences.class) {
+                if (mySharedPreferences == null) {
+                    mySharedPreferences = MyApplication.getAppContext().getSharedPreferences(PREFERENCES_VAR, mode);
+                }
+            }
+        }
+    }
+
+    public static SharedPreferences getInstance() {
+        initSharedPreferences(Activity.MODE_PRIVATE);
+        return mySharedPreferences;
+    }
+
+    public static SharedPreferences.Editor getSharededit() {
+        if (editor == null) {
+            synchronized (SharedPreferences.Editor.class) {
+                if (editor == null) {
+                    editor = mySharedPreferences.edit();
+                }
+            }
+        }
+        return editor;
+    }
+
+    /**
+     * SharedPreferences字符串的存入
+     *
+     * @param key
+     * @param vData
+     */
+    public static void putStringSp(String key, String vData) {
+        getInstance().edit().putString(key, vData).commit();
+    }
+
+    public static void putBooleanSp(String key, boolean vData) {
+        getInstance().edit().putBoolean(key, vData).commit();
+    }
+
+    public static void putIntSp(String key, int vData) {
+        getInstance().edit().putInt(key, vData).commit();
+    }
+
+    public static void putFloatSp(String key, float vData) {
+        getInstance().edit().putFloat(key, vData).commit();
+    }
+
+    public static void putLongSp(String key, long vData) {
+        getInstance().edit().putLong(key, vData).commit();
+    }
+
+    /**
+     * SharedPreferences字符串的取出
+     *
+     */
+    public static String getStringSp(String key) {
+        return getInstance().getString(key, "");
+    }
+
+    public static int getIntSp(String key) {
+        return getInstance().getInt(key, 0);
+    }
+
+    public static boolean getBooleanSp(String key) {
+        return getInstance().getBoolean(key, true);
+    }
+
+    public static long getLongSp(String key) {
+        return getInstance().getLong(key, 0l);
+    }
+
+    public static float getFloatSp(String key) {
+        return getInstance().getFloat(key, 0.0f);
+    }
+
+    /**
+     * SharedPreferences数据的清除
+     *
+     */
+    public static void deleSp() {
+        getInstance().edit().clear().commit();
+    }
+
+}

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1101 - 0
app/src/main/java/com/wdkl/nursewatch/utils/StringUtils.java


+ 189 - 0
app/src/main/java/com/wdkl/nursewatch/utils/TimeUtil.java

@@ -0,0 +1,189 @@
+package com.wdkl.nursewatch.utils;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+public class TimeUtil {
+    private Calendar cal;
+    private static TimeUtil mTimeUtil;
+    //返回当前时间 年月日 时间 星期
+    private StringBuffer str = new StringBuffer();
+
+    private int year;
+    private int month;
+    private int day;
+    private int hour;
+    private int minute;
+    private int second;
+    private int length;
+    private Integer a;
+    private int b;
+    private String s;
+    private SimpleDateFormat sdfInput, timeInput;
+    private Date date1, date2;
+    private int dayOfWeek;
+    private int i;
+
+
+    //返回当前秒钟
+    public String getSecond() {
+        cal = Calendar.getInstance();//使用日历类
+        second = cal.get(Calendar.SECOND);//得到秒
+        return second + "";
+    }
+
+
+    public static TimeUtil getInstance() {
+        if (mTimeUtil == null)
+            mTimeUtil = new TimeUtil();
+
+        return mTimeUtil;
+    }
+
+    public TimeUtil() {
+        sdfInput = new SimpleDateFormat("yyyy年MM月dd日  E");
+        timeInput = new SimpleDateFormat("HH:mm:ss");
+        date1 = new Date();
+    }
+
+    /**
+     * 获取年月日 周几
+     * @return
+     */
+    public String getDataTime() {
+        date1 = new Date();
+        return sdfInput.format(date1).toString();
+    }
+
+    /**
+     * 获取时分秒
+     * @return
+     */
+    public String getTime() {
+        date2 = new Date();
+        return timeInput.format(date2).toString();
+    }
+
+
+    //返回当前时间 年月日 时间 星期
+//    public String getClockTime() {
+//        String str = "";
+//        int year = cal.get(Calendar.YEAR);//得到年
+//        int month = cal.get(Calendar.MONTH) + 1;//得到月,因为从0开始的,所以要加1
+//        int day = cal.get(Calendar.DAY_OF_MONTH);//得到天
+//        int hour = cal.get(Calendar.HOUR_OF_DAY);//得到小时
+//        int minute = cal.get(Calendar.MINUTE);//得到分钟
+//        int second = cal.get(Calendar.SECOND);//得到秒
+//        String date = year + "/" + month + "/" + day;
+//        str += date;
+//
+//        Integer aInteger = minute;
+//        int length = aInteger.toString().length();
+//        Integer a = second;
+//        int b = a.toString().length();
+//        if (length == 1 && b == 1) {
+//            str += " " + hour + ":" + "0" + minute + ":" + "0" + second;
+//        } else if (length != 1 && b != 1) {
+//            str += " " + hour + ":" + minute + ":" + second;
+//        } else if (length == 1 && b != 1) {
+//            str += " " + hour + ":" + "0" + minute + ":" + second;
+//        } else {
+//            str += " " + hour + ":" + minute + ":" + "0" + second;
+//        }
+//
+//        String s = year + "/" + month + "/" + day;
+//        SimpleDateFormat sdfInput = new SimpleDateFormat("yyyy/MM/dd");
+//        Date date1 = new Date();
+//        try {
+//            date1 = sdfInput.parse(s);
+//        } catch (ParseException e) {
+//            e.printStackTrace();
+//        }
+//        calendar.setTime(date1);
+//        return str;
+//    }
+
+    /*获取星期几*/
+
+    public String getWeek() {
+        i = cal.get(Calendar.DAY_OF_WEEK);
+        switch (i) {
+            case 1:
+                return "星期日";
+            case 2:
+                return "星期一";
+            case 3:
+                return "星期二";
+            case 4:
+                return "星期三";
+            case 5:
+                return "星期四";
+            case 6:
+                return "星期五";
+            case 7:
+                return "星期六";
+            default:
+                return "";
+        }
+    }
+
+    /**
+     * 设置系统时间
+     *
+     * @param date
+     */
+    public static void setSysDate(String date) {
+        try {
+            Process process = Runtime.getRuntime().exec("su");
+            if (null != process) {
+                String datetime = date; //测试的设置的时间【时间格式 yyyyMMdd.HHmmss】"20131023.112800"
+                DataOutputStream os = new DataOutputStream(process.getOutputStream());
+                os.writeBytes("setprop persist.sys.timezone GMT\n");
+                os.writeBytes("/system/bin/date -s " + datetime + "\n");
+                os.writeBytes("clock -w\n");
+                os.writeBytes("exit\n");
+                os.flush();
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 时间做密码
+     * @return
+     */
+    public static String getPassWord() {
+        String PassWord = "";
+        Calendar cal = Calendar.getInstance();
+        int year = cal.get(Calendar.YEAR);
+        int hour = cal.get(Calendar.HOUR_OF_DAY);
+        PassWord = String.valueOf(year) + String.valueOf(hour);
+        return PassWord;
+    }
+
+    /**
+     * 获取系统权限
+     * @return
+     */
+    public static boolean isRoot() {
+        try {
+            Process process = Runtime.getRuntime().exec("su");
+            process.getOutputStream().write("exit\n".getBytes());
+            process.getOutputStream().flush();
+            int i = process.waitFor();
+            if (0 == i) {
+                return true;
+            }
+
+        } catch (Exception e) {
+            return false;
+        }
+        return false;
+
+    }
+
+}

+ 126 - 0
app/src/main/java/com/wdkl/nursewatch/utils/ToastUtil.java

@@ -0,0 +1,126 @@
+package com.wdkl.nursewatch.utils;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+import android.widget.Toast;
+
+public class ToastUtil {
+
+    public static Toast toast = null;
+    public static boolean is_Debug = true;
+
+    /**
+     * 弹出调试Toast
+     *
+     * @param context
+     * @param text
+     */
+    public static void showToast_Debug(Context context, String text) {
+        if (is_Debug) {
+            if (toast == null) {
+                toast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
+            }
+            toast.setText(text);
+            toast.show();
+        }
+    }
+
+    /**
+     * 弹出Toast
+     *
+     * @param context
+     * @param text
+     */
+    public static void showToast(Context context, String text) {
+        if (toast == null) {
+            toast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
+        }
+        toast.setText(text);
+        toast.show();
+    }
+
+    /**
+     * 弹出指定Toast的时间
+     *
+     * @param context
+     * @param text
+     */
+    public static void showtimeToast(Context context, String text, int time) {
+        if (toast == null) {
+            toast = Toast.makeText(context, text, time);
+        }
+        toast.setText(text);
+        toast.show();
+    }
+
+    /**
+     * 弹出自定义Toast
+     *
+     * @param context         (上下文)
+     * @param text            (Toast内容)
+     * @param time            (Toast的显示时间)
+     * @param gravity         (Toast显示的位置)
+     * @param backgroundcolor (背景颜色)
+     * @param textColor       (Toast字体的颜色)
+     * @param imageresource   (Toast添加图片的资源ID)
+     */
+    public static void myselfToast(Context context, String text, int time,
+                                   int gravity, int backgroundcolor, int textColor, int imageresource) {
+        Toast toast = null;
+        if (toast == null) {
+            toast = Toast.makeText(context, text, time);
+        }
+        // toast.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM, 0, 0);
+        // toast.setGravity(0|0 , 0, 200); // 设置显示位置
+        toast.setGravity(gravity, 0, 0); // 设置显示位置
+        LinearLayout layout = (LinearLayout) toast.getView();
+        layout.setBackgroundColor(backgroundcolor);
+        if (imageresource != -1) {
+            ImageView image = new ImageView(context);
+            image.setImageResource(imageresource);
+            layout.addView(image, 0);
+        }
+        TextView v = (TextView) toast.getView().findViewById(
+                android.R.id.message);
+        v.setTextColor(textColor); // 设置字体颜色
+        toast.show();
+    }
+
+    /**
+     * 弹出自定义Toast
+     *
+     * @param context       (上下文)
+     * @param inflater      (LayoutInflater对象)
+     * @param text          (Toast内容)
+     * @param time          (Toast的显示时间)
+     * @param layout        (Toast的自定义布局)
+     * @param gravity       (Toast显示的位置)
+     * @param imgResId      (Toast添加图片的RESID)
+     * @param textResId     (Toast添加文字的RESID)
+     * @param imageresource (Toast添加图片的资源ID)
+     */
+    public static void myselfToast(Context context, LayoutInflater inflater,
+                                   String text, int time, int layout, int gravity, int imgResId,
+                                   int textResId, int imageresource) {
+        View view = inflater.inflate(layout, null);
+        if (imageresource != -1) {
+            ImageView img_logo = (ImageView) view.findViewById(imgResId);
+            img_logo.setImageResource(imageresource);
+        }
+        TextView tv_msg = (TextView) view.findViewById(textResId);
+        tv_msg.setText(text);
+        Toast toast = null;
+        if (toast == null) {
+            toast = new Toast(context);
+        }
+        toast.setGravity(gravity, 0, 0);
+        toast.setDuration(time);
+        toast.setView(view);
+        toast.show();
+    }
+}
+

+ 326 - 0
app/src/main/java/com/wdkl/nursewatch/utils/WebsocketUtil.java

@@ -0,0 +1,326 @@
+package com.wdkl.nursewatch.utils;
+
+import android.support.annotation.Nullable;
+import android.util.Log;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.wdkl.nursewatch.MyApplication;
+import com.wdkl.nursewatch.common.Constants;
+import com.wdkl.nursewatch.entity.MessageEntity;
+import com.wdkl.nursewatch.entity.MessageEvent;
+import com.wdkl.nursewatch.entity.WebsocketEntity;
+import com.wdkl.nursewatch.entity.WebsocketEntityReal;
+
+import org.greenrobot.eventbus.EventBus;
+
+import java.util.concurrent.TimeUnit;
+
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
+import okhttp3.WebSocket;
+import okhttp3.WebSocketListener;
+import okio.ByteString;
+
+public class WebsocketUtil {
+
+
+    private String TAG = WebsocketUtil.class.getSimpleName();
+      //原有的
+//    public static String serverUrl = "ws://id.wdklian.com:10011/call";
+    //public static String serverUrl = "ws://192.168.3.88:10011/call";//吴总做测试 20190417
+
+    //后面修改的
+    public static String serverUrl = "ws://39.108.248.223:10011/ch/2/";
+
+    public static int WEBSOCKET_SUCCESS = 0;      //连接成功
+    public static int WEBSOCKET_ONOPEN = 1;      //通道开放
+    public static int WEBSOCKET_ONCLOSING = 2;   //正在关闭
+    public static int WEBSOCKET_ONCLOSED = 3;   //通道关闭
+    public static int WEBSOCKET_ONFAILURE = 4; //连接失败
+    public static int WEBSOCKET_STATE = -1;    //连接状态
+
+    public OkHttpClient client;
+    public WebSocket webSocket;
+    public Gson gson;
+    public GsonBuilder builder;
+    public WebsocketEntity websocketEntity;
+
+    private static final int NORMAL_CLOSURE_STATUS = 1000;
+
+    private static WebsocketUtil mWebsocketUtil;
+
+    public static WebsocketUtil getInstance() {
+        if (mWebsocketUtil == null) {
+            synchronized (WebsocketUtil.class) {
+                if (mWebsocketUtil == null) {
+                    mWebsocketUtil = new WebsocketUtil();
+                }
+            }
+        }
+        return mWebsocketUtil;
+    }
+
+    public WebsocketUtil() {
+        builder = new GsonBuilder();
+        gson = builder.create();
+    }
+
+    public WebSocket getWebSocket() {
+        return webSocket;
+    }
+
+    public OkHttpClient getHttpClient() {
+        return client;
+    }
+
+    public void connect(String serverID,String machineID, String nurseID) {
+        LogUtil.d(TAG, "connect machineID==" + machineID + "==nurseID==" + nurseID);
+        if (!StringUtils.notEmpty(machineID)) return;
+        WebsocketEntity websocketEntity = new WebsocketEntity();
+        websocketEntity.setServerID(serverID);
+        websocketEntity.setDepartmentsID(machineID);
+        websocketEntity.setNurseID(nurseID);
+        websocketEntity.setUDPData("");
+        websocketEntity.setDeviceType("2");
+        Log.e(TAG," 网址:"+serverUrl+websocketEntity.getServerID()+
+                "_"+"1"+"_"+websocketEntity.getNurseID());
+        start(websocketEntity);
+    }
+
+    public void start(WebsocketEntity websocketEntity) {
+        if (websocketEntity == null || !StringUtils.notEmpty(websocketEntity.getDepartmentsID()))
+            return;
+
+        this.websocketEntity = websocketEntity;
+
+        Request request = new Request.Builder().url(serverUrl+websocketEntity.getServerID()+
+                "_"+"1"+"_"+websocketEntity.getNurseID()).build();
+
+        EchoWebSocketListener listener = new EchoWebSocketListener(websocketEntity);
+        client = new OkHttpClient.Builder().readTimeout(3, TimeUnit.SECONDS).build();
+        webSocket = client.newWebSocket(request, listener);
+
+        //client.dispatcher().executorService().shutdown();
+        //try {
+        //    if (!client.dispatcher().executorService().awaitTermination(3000, TimeUnit.MILLISECONDS)) {
+        //        // 超时的时候向线程池中所有的线程发出中断命令(interrupted)。
+        //    }
+        //} catch (InterruptedException e) {}
+
+    }
+
+    /**
+     * 这几个方法很好理解,是用来异步回调的,这里简单说一下:
+     * onOpen当WebSocket和远程建立连接时回调;两个onMessage就是接收到消息时回调,只是消息内容的类型不同;
+     * onClosing是当远程端暗示没有数据交互时回调(即此时准备关闭,但连接还没有关闭);
+     * onClosed就是当连接已经释放的时候被回调;
+     * onFailure当然是失败时被回调(包括连接失败,发送失败等)。
+     */
+    protected final class EchoWebSocketListener extends WebSocketListener {
+
+        private WebsocketEntity websocketEntity;
+
+        public EchoWebSocketListener(WebsocketEntity websocketEntity) {
+            this.websocketEntity = websocketEntity;
+        }
+
+        @Override
+        public void onOpen(WebSocket webSocket, Response response) {
+            LogUtil.d(TAG, "onOpen==0");
+            WEBSOCKET_STATE = WEBSOCKET_ONOPEN;
+            EventBus.getDefault().post(new MessageEvent("onOpen", Constants.EVENT_LOGIN_STATUS_MESSAGE));
+//            sendMessageForWS();
+        }
+
+        @Override
+        public void onMessage(WebSocket webSocket, String text) {//收到文本信息
+            LogUtil.d(TAG, "onMessage==1" + "text==" + text);
+            WEBSOCKET_STATE = WEBSOCKET_SUCCESS;
+            // 0:索引 1:主机id 2:门口机id 3:子机id 4:sip地址 5:房间号 6:床号 7:护理等级 8:消息类型 9:名称
+            if ("Hello!".equals(text)) {
+                EventBus.getDefault().post(new MessageEvent("success", Constants.EVENT_LOGIN_STATUS_MESSAGE));
+            } else if (text.equals("{\"type\":\"ping\"}")) {
+                LogUtil.d(TAG, "onMessage 服务端收到心跳信号,返回来了");
+            } else {
+                Log.e(TAG,"onMessage..."+text);
+
+//                if (Constants.IS_LOGOUT) return;
+//                WebsocketEntityReal websocketEntityReal = gson.fromJson(text, WebsocketEntityReal.class);
+//                text = websocketEntityReal.getUDPData();
+//                if (!text.equals("") && "$".equals(text.substring(0, 1))) { //判断是否为美元符号开头,如果是则是android 端的命令
+//                    text = delHeadAndEnd(text, "$", "#");
+//                    String[] data = text.split("\\|");
+//
+//                    onMessageCall(text, data);
+//                }
+
+                if (!text.equals("") && "$".equals(text.substring(0, 1))) { //判断是否为美元符号开头,如果是则是android 端的命令
+                    text = delHeadAndEnd(text, "$", "#");
+                    String[] data = text.split(Character.toString((char) 3));
+                    onMessageCall(text, data);
+                }
+
+            }
+
+        }
+
+        @Override
+        public void onMessage(WebSocket webSocket, ByteString bytes) {//收到二进制信息
+            LogUtil.d(TAG, "onMessage==2");
+            WEBSOCKET_STATE = WEBSOCKET_SUCCESS;
+            if (Constants.IS_LOGOUT) return;
+        }
+
+        @Override
+        public void onClosing(WebSocket webSocket, int code, String reason) {
+            LogUtil.d(TAG, "onClosing==3");
+            WEBSOCKET_STATE = WEBSOCKET_ONCLOSING;
+            webSocket.close(NORMAL_CLOSURE_STATUS, reason);
+            connectWS();
+            EventBus.getDefault().post(new MessageEvent("onClosing", Constants.EVENT_LOGIN_STATUS_MESSAGE));
+        }
+
+        @Override
+        public void onClosed(WebSocket webSocket, int code, String reason) {
+            LogUtil.d(TAG, "onClosed==303");
+            WEBSOCKET_STATE = WEBSOCKET_ONCLOSED;
+            connectWS();
+            EventBus.getDefault().post(new MessageEvent("onClosed", Constants.EVENT_LOGIN_STATUS_MESSAGE));
+        }
+
+        @Override
+        public void onFailure(WebSocket webSocket, Throwable t, @Nullable Response response) {
+            LogUtil.d(TAG, "onFailure==4");
+            WEBSOCKET_STATE = WEBSOCKET_ONFAILURE;
+            connectWS();
+            EventBus.getDefault().post(new MessageEvent("onFailure", Constants.EVENT_LOGIN_STATUS_MESSAGE));
+        }
+    }
+
+    /**
+     * 发送命令给服务器;websocket已经连接成功  waderson 20190329
+     */
+    public void sendMessageForWS() {
+        try {
+            //String sendMessage = "{\"UDPData\":\"\",\"MachineID\":" + "\"" + websocketEntity.getMachineID() + "\"" + ",\"DeviceType\":\"2\"}";
+            String sendMessage = new Gson().toJson(websocketEntity);
+            LogUtil.d(TAG, "sendMessage==" + sendMessage);
+            WebsocketUtil.getInstance().getWebSocket().send(sendMessage);
+            LogUtil.d(TAG, "2_send_ok");
+        } catch (Exception e) {
+        }
+    }
+
+    public static void connectWS() {
+        if (!NetworkUtil.checkNetworkAvailable(MyApplication.getAppContext())) return;//网络不可用
+
+        String serverId = SharedPreferencesUtil.getStringSp(SharedPreferencesUtil.LOGIN_SERVERID);
+        String loginMachineId = SharedPreferencesUtil.getStringSp(SharedPreferencesUtil.LOGIN_DEPARTMENTSID);
+        String nurseId = SharedPreferencesUtil.getStringSp(SharedPreferencesUtil.LOGIN_NURSE_ID);
+//        if (StringUtils.notEmpty(loginMachineId) && StringUtils.notEmpty(nurseId) && !Constants.IS_LOGOUT && WEBSOCKET_STATE != WEBSOCKET_SUCCESS && WEBSOCKET_STATE != WEBSOCKET_ONOPEN) {
+        WebsocketUtil.getInstance().connect(serverId,loginMachineId, nurseId);
+//        }
+    }
+
+    public synchronized void onMessageCall(String text, String[] data) {
+        LogUtil.d(TAG, data.toString());
+        if (!Constants.UDP_WS_DATA.equals(text)) {
+            LogUtil.d(TAG, "onMessageCall222");
+            Constants.UDP_WS_DATA = text;
+            MessageEntity messageEntity = new MessageEntity();
+            if (data[8].equals(Constants.SON_CALL)) {//床头机呼叫
+                messageEntity.setPatientName(data[6] + "床呼叫");//护士i
+            } else if (data[8].equals(Constants.WSHROOM_CALL)) {//卫生间紧急呼叫
+                messageEntity.setPatientName(data[5] + "房卫生间紧急呼叫");
+            } else if (data[8].equals(Constants.ROOMHELP_CALL)) {//床头机请求
+                messageEntity.setPatientName(data[6] + "床请求增援");
+            } else if (data[8].equals(Constants.DOOR_CALL)) {//门口机呼叫
+                messageEntity.setPatientName(data[5] + "房门口机呼叫");
+            } else if (data[8].equals(Constants.TRADITION_CALL)) {//传统子机呼叫
+                messageEntity.setPatientName(data[6] + "床呼叫");
+            }
+
+            messageEntity.setPatientID(data[5]);//房间号
+            messageEntity.setIndexes(data[0]);
+            messageEntity.setDataOne(data[1]);
+            messageEntity.setDataTwo(data[2]);
+            messageEntity.setDataThree(data[3]);
+            messageEntity.setDataFour(data[4]);
+            messageEntity.setDataFive(data[5]);
+            messageEntity.setDataSix(data[6]);
+            messageEntity.setDataSeven(data[7]);
+            messageEntity.setDataEight(data[8]);
+            messageEntity.setDataNine(data[9]);
+            if (data.length > 10) messageEntity.setDataTen(data[10]);
+
+            switch (data[0]) {
+                case "call_1"://床头机呼叫
+                case "call_2"://卫生间紧急呼叫
+                case "call_4"://床头机请求增援
+                case "call_6"://门口机呼叫
+                    LogUtil.d("onMessageCall", "onMessageCall333");
+                    PalyPhonetics.getInstance(MyApplication.getAppContext()).addPhonetics(messageEntity);
+                    PhoneUtils.isVibrator(1000);//震动
+
+                    SaveCallListUtil.saveCallEntity(messageEntity);
+                    SaveCallListUtil.saveCallEntityNow(messageEntity);
+                    break;
+                case "call_8_upremove"://主机上滑取消了
+                case "call_1_ringoff":
+                    LogUtil.d("onMessageCall", "onMessageCall444 ---- call_8_upremove");
+                    SaveCallListUtil.deleteCallEntity(messageEntity);
+                    SaveCallListUtil.deleteCallEntityNow(messageEntity);
+                    if (PalyPhonetics.thisEntityIsSpeaking(messageEntity)) {
+                        PalyPhonetics.setPalyDismiss(true);
+                    }
+                    PalyPhonetics.deleteCallEntity(messageEntity);
+                    break;
+            }
+
+            EventBus.getDefault().post(new MessageEvent(messageEntity, Constants.EVENT_NEW_UDPDATA));
+
+            new Thread(new Runnable() {//这里做个去重;有时候服务端连续发来好多条
+                @Override
+                public void run() {
+                    try {
+                        Thread.sleep(300);
+                    } catch (InterruptedException e) {
+                        e.printStackTrace();
+                    }
+                    LogUtil.d("onMessageCall", "onMessageCall555");
+                    Constants.UDP_WS_DATA = "";
+                }
+            }).start();
+        }
+
+    }
+
+
+    public static String delHeadAndEnd(String source, String beginTrim, String endTrim) {
+        try {
+            if (source == null) {
+                return "";
+            }
+            source = source.trim(); // 循环去掉字符串首的beTrim字符
+            if (source.isEmpty()) {
+                return "";
+            }
+            String beginChar = source.substring(0, 1);
+            if (beginChar.equalsIgnoreCase(beginTrim)) {
+                source = source.substring(1, source.length());
+            }
+            // 循环去掉字符串尾的beTrim字符
+            String endChar = source.substring(source.length() - 1, source.length());
+            if (endChar.equalsIgnoreCase(endTrim)) {
+                source = source.substring(0, source.length() - 1);
+            }
+        } catch (Exception e) {
+            LogUtil.d("delHeadAndEnd", "delHeadAndEnd Exception");
+        }
+
+        return source;
+    }
+
+}

+ 44 - 0
app/src/main/java/com/wdkl/nursewatch/utils/testudp.java

@@ -0,0 +1,44 @@
+package com.wdkl.nursewatch.utils;
+
+public class testudp {
+
+    //package com.wdkl.nursewatch.utils;
+    //
+    //import java.io.IOException;
+    //import java.net.DatagramPacket;
+    //import java.net.DatagramSocket;
+    //import java.net.InetAddress;
+    //
+    //public class testudp {
+    //
+    //
+    //
+    //
+    //
+    //    public static void broadcast(
+    //            String broadcastMessage) throws IOException {
+    //        DatagramSocket socket = new DatagramSocket();
+    //        socket.setBroadcast(true);
+    //
+    //        byte[] buffer = broadcastMessage.getBytes();
+    //
+    //        InetAddress address = InetAddress.getByName("10.0.122.255");
+    //
+    //        DatagramPacket packet
+    //                = new DatagramPacket(buffer, buffer.length, address, 10010);
+    //        socket.send(packet);
+    //        socket.close();
+    //    }
+    //
+    //    public static void main(String[] args) {
+    //        System.out.println("123");
+    //        try {
+    //            broadcast("sdfgsdfg");
+    //        }catch (IOException ex){
+    //
+    //        }
+    //        System.out.println("123");
+    //    }
+    //}
+
+}

BIN
app/src/main/res/drawable-hdpi/app_logo.png


BIN
app/src/main/res/drawable-hdpi/jpush_ic_richpush_actionbar_back.png


BIN
app/src/main/res/drawable-hdpi/jpush_ic_richpush_actionbar_divider.png


BIN
app/src/main/res/drawable-hdpi/jpush_notification_icon.png


+ 21 - 0
app/src/main/res/drawable-hdpi/jpush_richpush_btn_selector.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?> 
+<selector xmlns:android="http://schemas.android.com/apk/res/android" > 
+    <!-- 获得焦点但未按下时的背景图片 --> 
+    <item 
+        android:state_focused="true" 
+        android:state_enabled="true" 
+        android:state_pressed="false" 
+        android:drawable="@drawable/jpush_ic_richpush_actionbar_back" />
+     <!-- 按下时的背景图片 --> 
+    <item 
+        android:state_enabled="true" 
+        android:state_pressed="true" 
+        android:drawable="@android:color/darker_gray" /> 
+    <!-- 按下时的背景图片 --> 
+    <item 
+        android:state_enabled="true" 
+        android:state_checked="true" 
+        android:drawable="@android:color/darker_gray" /> 
+    <!-- 默认时的背景图片 --> 
+    <item android:drawable="@drawable/jpush_ic_richpush_actionbar_back" />
+</selector> 

+ 20 - 0
app/src/main/res/drawable-hdpi/jpush_richpush_progressbar.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <!-- 背景  gradient是渐变,corners定义的是圆角 -->
+    <item android:id="@android:id/background">
+        <shape>
+            <solid android:color="#ffffff" />
+        </shape>
+    </item>
+    
+    <!-- 进度条 -->
+    <item android:id="@android:id/progress">
+        <clip>
+            <shape>
+                <solid android:color="#4393ea" />
+            </shape>
+        </clip>
+    </item>
+
+</layer-list>

BIN
app/src/main/res/drawable-mdpi/app_logo.png


BIN
app/src/main/res/drawable-mdpi/history_records.png


BIN
app/src/main/res/drawable-mdpi/ic_call_bed.png


BIN
app/src/main/res/drawable-mdpi/ic_calling_sickbed_room_standby_top.png


BIN
app/src/main/res/drawable-mdpi/ic_support.png


BIN
app/src/main/res/drawable-mdpi/ic_wc.png


BIN
app/src/main/res/drawable-mdpi/nor_calling.png


BIN
app/src/main/res/drawable-mdpi/setting.png


BIN
app/src/main/res/drawable-mdpi/setting_nor_click.png


BIN
app/src/main/res/drawable-mdpi/setting_sel_click.png


BIN
app/src/main/res/drawable-mdpi/unbind_nurse_station.png


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 34 - 0
app/src/main/res/drawable-v24/ic_launcher_foreground.xml


BIN
app/src/main/res/drawable-xhdpi/app_logo.png


BIN
app/src/main/res/drawable-xxhdpi/app_logo.png


BIN
app/src/main/res/drawable-xxhdpi/img_back_white.png


BIN
app/src/main/res/drawable-xxhdpi/img_white_more.png


BIN
app/src/main/res/drawable-xxxhdpi/all_power_4g.png


BIN
app/src/main/res/drawable-xxxhdpi/all_power_4g_four.png


BIN
app/src/main/res/drawable-xxxhdpi/all_power_4g_nor.png


BIN
app/src/main/res/drawable-xxxhdpi/all_power_4g_one.png


BIN
app/src/main/res/drawable-xxxhdpi/all_power_4g_three.png


BIN
app/src/main/res/drawable-xxxhdpi/all_power_4g_two.png


BIN
app/src/main/res/drawable-xxxhdpi/app_logo.png


BIN
app/src/main/res/drawable-xxxhdpi/call_nor_per.png


+ 170 - 0
app/src/main/res/drawable/ic_launcher_background.xml

@@ -0,0 +1,170 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="108dp"
+    android:height="108dp"
+    android:viewportHeight="108"
+    android:viewportWidth="108">
+    <path
+        android:fillColor="#26A69A"
+        android:pathData="M0,0h108v108h-108z" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M9,0L9,108"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M19,0L19,108"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M29,0L29,108"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M39,0L39,108"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M49,0L49,108"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M59,0L59,108"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M69,0L69,108"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M79,0L79,108"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M89,0L89,108"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M99,0L99,108"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,9L108,9"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,19L108,19"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,29L108,29"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,39L108,39"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,49L108,49"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,59L108,59"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,69L108,69"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,79L108,79"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,89L108,89"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,99L108,99"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M19,29L89,29"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M19,39L89,39"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M19,49L89,49"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M19,59L89,59"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M19,69L89,69"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M19,79L89,79"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M29,19L29,89"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M39,19L39,89"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M49,19L49,89"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M59,19L59,89"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M69,19L69,89"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M79,19L79,89"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+</vector>

+ 5 - 0
app/src/main/res/drawable/selector_choose_botton.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:drawable="@drawable/selector_choose_button_item_true" android:state_pressed="true"/>
+    <item android:drawable="@drawable/selector_choose_button_item_false"/>
+</selector>

+ 5 - 0
app/src/main/res/drawable/selector_choose_button_item_false.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android" >
+    <solid android:color="#FF6335" />
+    <corners android:radius="8dp"></corners>
+</shape>

+ 5 - 0
app/src/main/res/drawable/selector_choose_button_item_true.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android" >
+    <solid android:color="#65FECD" />
+    <corners android:radius="8dp"></corners>
+</shape>

+ 8 - 0
app/src/main/res/drawable/selector_setting_click.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item android:drawable="@drawable/setting_nor_click" android:state_checked="false" />
+    <item android:drawable="@drawable/setting_sel_click" android:state_checked="true" />
+    <item android:drawable="@drawable/setting_nor_click" android:state_enabled="false" />
+
+</selector>

+ 7 - 0
app/src/main/res/drawable/shape_confirm_unbind_station.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="oval">
+
+    <solid android:color="@color/color_red_f04c62" />
+
+</shape>

+ 7 - 0
app/src/main/res/drawable/shape_intoset_unbind_station.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="oval">
+
+    <solid android:color="@color/color_sbgreen" />
+
+</shape>

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

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="oval">
+    <solid android:color="@color/white" />
+
+</shape>

+ 26 - 0
app/src/main/res/layout/activity_call_history_list.xml

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@mipmap/main_list_background"
+    android:gravity="center"
+    android:orientation="vertical">
+    <!--腕表历史记录-->
+    <TextView
+        android:id="@+id/tv_call_history_records"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:gravity="center"
+        android:onClick="clearCalledHistory"
+        android:text="呼叫历史记录"
+        android:textColor="#2F5A71"
+        android:textSize="23sp" />
+
+    <com.jude.easyrecyclerview.EasyRecyclerView
+        android:id="@+id/ecl_history_records"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+
+    </com.jude.easyrecyclerview.EasyRecyclerView>
+
+</LinearLayout>

+ 23 - 0
app/src/main/res/layout/activity_calling.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:gravity="center"
+    android:orientation="vertical">
+    <!--腕表初版挂断-->
+    <ImageView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:src="@drawable/ic_launcher_background" />
+
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="002房002床正在呼叫" />
+
+    <ImageView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:src="@drawable/ic_launcher_background" />
+
+</LinearLayout>

+ 135 - 0
app/src/main/res/layout/activity_home.xml

@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@mipmap/main_background"
+    android:orientation="vertical">
+
+    <TextView
+        android:id="@+id/tv_home_network_power"
+        android:layout_width="wrap_content"
+        android:layout_height="25dp"
+        android:layout_gravity="top"
+        android:layout_marginLeft="10dp"
+        android:layout_marginTop="0dp"
+        android:drawablePadding="2dp"
+        android:gravity="center"
+        android:text=""
+        android:textColor="@color/white" />
+
+    <com.wdkl.nursewatch.presentation.ui.views.BatteryView
+        android:id="@+id/battery_view"
+        android:layout_width="40dp"
+        android:layout_height="20dp"
+        android:layout_alignParentRight="true"
+        android:layout_marginTop="5dp"
+        android:layout_marginRight="10dp" />
+
+    <TextView
+        android:id="@+id/tv_nurse_name"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_below="@+id/battery_view"
+        android:layout_centerHorizontal="true"
+        android:layout_marginTop="5dp"
+        android:ellipsize="end"
+        android:lines="1"
+        android:text="--"
+        android:textColor="@color/white"
+        android:textSize="35sp" />
+
+    <LinearLayout
+        android:id="@+id/ll_home_all"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_below="@+id/tv_home_network_power"
+        android:gravity="center"
+        android:orientation="vertical">
+
+        <TextView
+            android:id="@+id/tv_home_times"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center"
+            android:layout_marginTop="18dp"
+            android:text="14:09:26"
+            android:textColor="@color/white"
+            android:textSize="50sp" />
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="10dp"
+            android:layout_marginBottom="30dp"
+            android:gravity="center"
+            android:orientation="horizontal">
+
+            <TextView
+                android:id="@+id/tv_home_date_times"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center"
+                android:text="2018/12/12 星期二"
+                android:textColor="@color/white"
+                android:textSize="20sp" />
+
+        </LinearLayout>
+
+
+        <FrameLayout
+            android:id="@+id/fl_home_nor_call_img_icon"
+            android:layout_width="80dp"
+            android:layout_height="80dp"
+            android:layout_centerHorizontal="true"
+            android:layout_gravity="center"
+            android:visibility="gone">
+
+            <ImageView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center"
+                android:paddingTop="10dp"
+                android:src="@drawable/nor_calling" />
+
+            <TextView
+                android:id="@+id/list_item_img_icon_num"
+                android:layout_width="32dp"
+                android:layout_height="32dp"
+                android:layout_gravity="right"
+                android:layout_marginTop="0dp"
+                android:layout_marginRight="2dp"
+                android:background="@drawable/shape_nor_call_num"
+                android:gravity="center"
+                android:text="1"
+                android:textColor="@color/color_red_f04c62"
+                android:textSize="11sp"
+                android:textStyle="bold" />
+        </FrameLayout>
+
+    </LinearLayout>
+
+    <TextView
+        android:id="@+id/tv_home_call_num"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentBottom="true"
+        android:layout_marginLeft="3dp"
+        android:layout_marginBottom="3dp"
+        android:gravity="center"
+        android:text="当前呼叫: 0"
+        android:textColor="@color/white" />
+
+    <TextView
+        android:id="@+id/tv_home_version"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentRight="true"
+        android:layout_alignParentBottom="true"
+        android:layout_marginRight="3dp"
+        android:layout_marginBottom="3dp"
+        android:paddingLeft="28dp"
+        android:paddingTop="28dp"
+        android:text="V1.00"
+        android:textColor="@color/white" />
+
+</RelativeLayout>

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

@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@mipmap/main_list_background"
+    android:padding="15sp">
+
+    <TextView
+        android:id="@+id/tv_bind_nurse_station"
+        android:layout_width="match_parent"
+        android:layout_height="70dp"
+        android:background="@mipmap/list_item_history_records_back_nor"
+        android:gravity="center"
+        android:text="绑定护士站"
+        android:textColor="@color/white"
+        android:textSize="30sp" />
+
+    <TextView
+        android:id="@+id/activity_main_layout_tv_welcome"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_below="@+id/tv_bind_nurse_station"
+        android:layout_centerHorizontal="true"
+        android:layout_marginTop="20dp"
+        android:text="请扫描设备二维码"
+        android:textColor="@color/white"
+        android:textSize="20sp"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <Button
+        android:id="@+id/start"
+        android:layout_width="130dp"
+        android:layout_height="130dp"
+        android:layout_centerHorizontal="true"
+        android:layout_marginTop="150dp"
+        android:background="@drawable/shape_confirm_unbind_station"
+        android:text="扫描"
+        android:textColor="@color/white"
+        android:textSize="30sp" />
+
+    <ScrollView
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_below="@id/start"
+        android:layout_centerInParent="true">
+
+        <TextView
+            android:id="@+id/output"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_centerHorizontal="true"
+            android:layout_marginTop="20dp"
+            android:textSize="16sp" />
+    </ScrollView>
+
+</RelativeLayout>

+ 0 - 0
app/src/main/res/layout/activity_login_phone.xml


Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác