Browse Source

1.系统时间设置添加请求判断,只有请求了才设置时间,防止重复设置导致的socket断联。

20241218TB223FC(测试jar包)
wangwanlei 1 month ago
parent
commit
02d2f6b945

+ 7
- 4
app/src/main/java/com/xhly/manageapp/ui/login/activity/LoginActivity.kt View File

78
             }
78
             }
79
         }
79
         }
80
         viewModel.timeResultData.observe(this){
80
         viewModel.timeResultData.observe(this){
81
-            ManageApplication.setSysTime(it)
82
-            if (syncTimeClickFlag){
83
-                Toast(getString(R.string.syncsucess))
81
+            if (SystemUtil.updateTimeFlag){
82
+                SystemUtil.updateTimeFlag=false
83
+                ManageApplication.setSysTime(it)
84
+                if (syncTimeClickFlag){
85
+                    Toast(getString(R.string.syncsucess))
86
+                }
87
+                syncTimeClickFlag=false
84
             }
88
             }
85
-            syncTimeClickFlag=false
86
         }
89
         }
87
         viewModel.controlResultData.observe(this){
90
         viewModel.controlResultData.observe(this){
88
             //为真则可以进入管理页面
91
             //为真则可以进入管理页面

+ 9
- 4
app/src/main/java/com/xhly/manageapp/ui/main/activity/MainActivity.kt View File

90
 import com.xhly.manageapp.utils.InstallUtils
90
 import com.xhly.manageapp.utils.InstallUtils
91
 import com.xhly.manageapp.utils.PadInfoUtils
91
 import com.xhly.manageapp.utils.PadInfoUtils
92
 import com.xhly.manageapp.utils.StrategyUtils
92
 import com.xhly.manageapp.utils.StrategyUtils
93
+import com.xhly.manageapp.utils.SystemClock
93
 import com.xhly.manageapp.workmanager.TimingWorker
94
 import com.xhly.manageapp.workmanager.TimingWorker
94
 import kotlinx.coroutines.Dispatchers
95
 import kotlinx.coroutines.Dispatchers
95
 import kotlinx.coroutines.delay
96
 import kotlinx.coroutines.delay
598
             }
599
             }
599
         }
600
         }
600
         viewModel.timeResultData.observe(this) {
601
         viewModel.timeResultData.observe(this) {
601
-            ManageApplication.setSysTime(it)
602
-            try {
603
-                tipsDialog?.dismiss()
604
-            }catch (e:Exception){
602
+            if (SystemUtil.updateTimeFlag){
603
+                SystemUtil.updateTimeFlag=false
604
+                ManageApplication.setSysTime(it)
605
+                LogShow("当前设置的时间是"+it+"|||"+SystemClock.getDateString(it))
606
+                try {
607
+                    tipsDialog?.dismiss()
608
+                }catch (e:Exception){
605
 
609
 
610
+                }
606
             }
611
             }
607
         }
612
         }
608
 
613
 

+ 2
- 0
app/src/main/java/com/xhly/manageapp/viewmodel/BaseViewModel.kt View File

6
 import com.xhly.corelib.network.RetrofitService
6
 import com.xhly.corelib.network.RetrofitService
7
 import com.xhly.corelib.utils.LogShow
7
 import com.xhly.corelib.utils.LogShow
8
 import com.xhly.corelib.utils.MD5Utils
8
 import com.xhly.corelib.utils.MD5Utils
9
+import com.xhly.corelib.utils.SystemUtil
9
 import com.xhly.manageapp.bean.log.LogEventBean
10
 import com.xhly.manageapp.bean.log.LogEventBean
10
 import com.xhly.manageapp.bean.log.LogPushBean
11
 import com.xhly.manageapp.bean.log.LogPushBean
11
 import com.xhly.manageapp.bean.log.LogPushResultBean
12
 import com.xhly.manageapp.bean.log.LogPushResultBean
120
             val startTime = System.currentTimeMillis()
121
             val startTime = System.currentTimeMillis()
121
             val postSyncTime = loginService.postSyncTime()
122
             val postSyncTime = loginService.postSyncTime()
122
             if (postSyncTime.code == 0) {
123
             if (postSyncTime.code == 0) {
124
+                SystemUtil.updateTimeFlag=true
123
                 val endTime = System.currentTimeMillis()
125
                 val endTime = System.currentTimeMillis()
124
                 val obj = postSyncTime.obj
126
                 val obj = postSyncTime.obj
125
                 timeResult.value = obj + (endTime - startTime) / 2
127
                 timeResult.value = obj + (endTime - startTime) / 2

+ 2
- 1
corelib/src/main/java/com/xhly/corelib/utils/SystemUtil.java View File

37
  * 邮箱:zhan_0313@163.com
37
  * 邮箱:zhan_0313@163.com
38
  */
38
  */
39
 public class SystemUtil {
39
 public class SystemUtil {
40
-
40
+    //标记是否请求了时间,请求了才更新
41
+    public static boolean updateTimeFlag=false;
41
 
42
 
42
     /**
43
     /**
43
      * 获取当前手机系统语言。
44
      * 获取当前手机系统语言。

Loading…
Cancel
Save