@@ -2,7 +2,6 @@ package com.fmt.github.user.activity
2
2
3
3
import android.content.Intent
4
4
import android.view.View
5
- import androidx.lifecycle.Observer
6
5
import com.fmt.github.R
7
6
import com.fmt.github.base.activity.BaseDataBindVMActivity
8
7
import com.fmt.github.base.viewmodel.BaseViewModel
@@ -13,7 +12,6 @@ import com.fmt.github.ext.otherwise
13
12
import com.fmt.github.ext.startActivity
14
13
import com.fmt.github.ext.yes
15
14
import com.fmt.github.home.activity.HomeActivity
16
- import com.fmt.github.user.model.AuthorizationRespModel
17
15
import com.fmt.github.user.model.UserLoginModel
18
16
import com.fmt.github.user.model.UserModel
19
17
import com.fmt.github.user.model.db.User
@@ -90,29 +88,29 @@ class LoginActivity : BaseDataBindVMActivity<ActivityLoginBinding>() {
90
88
}
91
89
92
90
private fun createOrGetAuthorization () {
93
- mViewModel.createOrGetAuthorization().observe( this , Observer < AuthorizationRespModel > {
91
+ mViewModel.createOrGetAuthorization().observeKt {
94
92
// 保存授权后的Token和ID
95
93
Settings .Account .token = it.token
96
94
// 获取用户信息
97
95
getUserInfo()
98
- })
96
+ }
99
97
}
100
98
101
99
private fun getToken (code : String? , state : String? ) {
102
100
if (code != null && state != null ) {
103
101
mDataBind.mOAuthProgress.visibility = View .VISIBLE
104
102
mDataBind.mOAuthLoginIv.visibility = View .GONE
105
- mViewModel.getAccessToken(code, state).observe( this , Observer {
103
+ mViewModel.getAccessToken(code, state).observeKt {
106
104
Settings .Account .token = it.access_token
107
105
getUserInfo()
108
- })
106
+ }
109
107
}
110
108
}
111
109
112
110
private fun getUserInfo () {
113
- mViewModel.getUser().observe( this , Observer < UserModel > {
111
+ mViewModel.getUser().observeKt {
114
112
saveUserInfo(it)
115
- })
113
+ }
116
114
}
117
115
118
116
private fun saveUserInfo (userModel : UserModel ) {
0 commit comments