|
@@ -470,42 +470,47 @@ class WdKeepAliveService : AbsWorkService() {
|
|
}
|
|
}
|
|
|
|
|
|
Constants.EVENT_DATA_REFRESH -> { //更新通讯录,更新通话白名单列表
|
|
Constants.EVENT_DATA_REFRESH -> { //更新通讯录,更新通话白名单列表
|
|
- Thread(Runnable {
|
|
|
|
- var jsonStr = ""
|
|
|
|
- val contactVos = ApiManager.API_WatchManageDevice.getWatchContactList(Constants.deviceId).map {
|
|
|
|
- jsonStr = it.getJsonString()
|
|
|
|
- val gson = GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create()
|
|
|
|
- val contactList: List<WatchContactVO> = gson.fromJson(jsonStr, object : TypeToken<List<WatchContactVO>>() {}.type)
|
|
|
|
- return@map contactList
|
|
|
|
- }.blockingSingle()
|
|
|
|
-
|
|
|
|
- if (contactVos != null && contactVos.size > 0) {
|
|
|
|
- Log.e(TAG, "222 start update contacts...")
|
|
|
|
- /*for (contactVO in contactVos) {
|
|
|
|
- if (!Strings.isNullOrEmpty(contactVO.name) && !Strings.isNullOrEmpty(contactVO.phoneNumber)) {
|
|
|
|
- ContactHelper.setContact(BaseApplication.appContext, contactVO.name, contactVO.phoneNumber)
|
|
|
|
- }
|
|
|
|
- }*/
|
|
|
|
|
|
+ Thread {
|
|
|
|
+ try {
|
|
|
|
+ var jsonStr = ""
|
|
|
|
+ val contactVos = ApiManager.API_WatchManageDevice.getWatchContactList(Constants.deviceId)
|
|
|
|
+ .map {
|
|
|
|
+ jsonStr = it.getJsonString()
|
|
|
|
+ val gson = GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create()
|
|
|
|
+ val contactList: List<WatchContactVO> = gson.fromJson(jsonStr, object : TypeToken<List<WatchContactVO>>() {}.type)
|
|
|
|
+ return@map contactList
|
|
|
|
+ }.blockingSingle()
|
|
|
|
+
|
|
|
|
+ if (contactVos != null && contactVos.size > 0) {
|
|
|
|
+ Log.e(TAG, "222 start update contacts...")
|
|
|
|
+ /*for (contactVO in contactVos) {
|
|
|
|
+ if (!Strings.isNullOrEmpty(contactVO.name) && !Strings.isNullOrEmpty(contactVO.phoneNumber)) {
|
|
|
|
+ ContactHelper.setContact(BaseApplication.appContext, contactVO.name, contactVO.phoneNumber)
|
|
|
|
+ }
|
|
|
|
+ }*/
|
|
|
|
|
|
- ContactHelper.setContact2(BaseApplication.appContext, contactVos)
|
|
|
|
- Log.e(TAG, "222 update contacts end...")
|
|
|
|
- }
|
|
|
|
|
|
+ ContactHelper.setContact2(BaseApplication.appContext, contactVos)
|
|
|
|
+ Log.e(TAG, "222 update contacts end...")
|
|
|
|
+ }
|
|
|
|
|
|
- //更新白名单列表
|
|
|
|
- val whiteList = ApiManager.API_WatchManageDevice.getPhoneWhiteList(Constants.deviceId).map {
|
|
|
|
- jsonStr = it.getJsonString()
|
|
|
|
- val gson = GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create()
|
|
|
|
- val whiteList: List<String> = gson.fromJson(jsonStr, object : TypeToken<List<String>>() {}.type)
|
|
|
|
- return@map whiteList
|
|
|
|
- }.blockingSingle()
|
|
|
|
|
|
+ //更新白名单列表
|
|
|
|
+ val whiteList = ApiManager.API_WatchManageDevice.getPhoneWhiteList(Constants.deviceId).map {
|
|
|
|
+ jsonStr = it.getJsonString()
|
|
|
|
+ val gson = GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create()
|
|
|
|
+ val whiteList: List<String> = gson.fromJson(jsonStr, object : TypeToken<List<String>>() {}.type)
|
|
|
|
+ return@map whiteList
|
|
|
|
+ }.blockingSingle()
|
|
|
|
|
|
|
|
|
|
- if (whiteList != null && whiteList.size > 0) {
|
|
|
|
- Constants.phoneWhiteList.clear()
|
|
|
|
- Constants.phoneWhiteList.addAll(whiteList)
|
|
|
|
|
|
+ if (whiteList != null && whiteList.size > 0) {
|
|
|
|
+ Constants.phoneWhiteList.clear()
|
|
|
|
+ Constants.phoneWhiteList.addAll(whiteList)
|
|
|
|
+ }
|
|
|
|
+ } catch (ex: Exception) {
|
|
|
|
+ ex.printStackTrace()
|
|
}
|
|
}
|
|
|
|
|
|
- }).start()
|
|
|
|
|
|
+ }.start()
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|