|
@@ -98,7 +98,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
|
98
|
98
|
override fun initData() {
|
99
|
99
|
val json = spUtils.getFromJson(Const.USERINFO, UserBean().javaClass)
|
100
|
100
|
if (json == null) {
|
101
|
|
- loginOut()
|
|
101
|
+ loginOut(false)
|
102
|
102
|
return
|
103
|
103
|
} else {
|
104
|
104
|
userBean = json as UserBean
|
|
@@ -328,6 +328,13 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
|
328
|
328
|
}
|
329
|
329
|
}
|
330
|
330
|
}
|
|
331
|
+ viewModel.logEventData.observe(this){
|
|
332
|
+ when(it.logEventType){
|
|
333
|
+ EventLog.ACCOUNTQUITEVENT->{
|
|
334
|
+ loginOutSucess()
|
|
335
|
+ }
|
|
336
|
+ }
|
|
337
|
+ }
|
331
|
338
|
startWorkManager()
|
332
|
339
|
updateAllStrategy()
|
333
|
340
|
}
|
|
@@ -1057,14 +1064,23 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
|
1057
|
1064
|
.setAlign(CustomDialog.ALIGN.CENTER).show()
|
1058
|
1065
|
}
|
1059
|
1066
|
|
1060
|
|
- private fun loginOut() {
|
1061
|
|
- val data = LogdOperateBean()
|
1062
|
|
- ManageApplication.getDeviceInfo()?.let {
|
1063
|
|
- data.sn = it
|
|
1067
|
+ private fun loginOut(hasUser:Boolean=true) {
|
|
1068
|
+ //没有用户信息时,判断为初次调用,直接跳转登录页面
|
|
1069
|
+ if (hasUser){
|
|
1070
|
+ //调用接口传递退出事件,成功则退出登录
|
|
1071
|
+ val data = LogdOperateBean()
|
|
1072
|
+ ManageApplication.getDeviceInfo()?.let {
|
|
1073
|
+ data.sn = it
|
|
1074
|
+ }
|
|
1075
|
+ data.comm = "退出登录"
|
|
1076
|
+ data.doEvent = EventLog.ACCOUNTQUITEVENT
|
|
1077
|
+ viewModel.eventLog(data)
|
|
1078
|
+ }else{
|
|
1079
|
+ loginOutSucess()
|
1064
|
1080
|
}
|
1065
|
|
- data.comm = "退出登录"
|
1066
|
|
- data.doEvent = EventLog.ACCOUNTQUITEVENT
|
1067
|
|
- viewModel.eventLog(data)
|
|
1081
|
+ }
|
|
1082
|
+
|
|
1083
|
+ private fun loginOutSucess(){
|
1068
|
1084
|
WorkManager.getInstance(this).cancelAllWork()
|
1069
|
1085
|
deleteSharedPreferences(SharedPreferencesUtils.SP_FILE_NAME)
|
1070
|
1086
|
Const.USERID = null
|