File tree Expand file tree Collapse file tree 2 files changed +12
-7
lines changed
app/src/main/java/com/zj/play/main/login Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import com.zj.play.article.ArticleBroadCast
1414import dagger.hilt.android.lifecycle.HiltViewModel
1515import kotlinx.coroutines.Dispatchers
1616import kotlinx.coroutines.launch
17+ import kotlinx.coroutines.withContext
1718import javax.inject.Inject
1819
1920/* *
@@ -52,14 +53,18 @@ class LoginViewModel @Inject constructor(
5253 _state .postValue(LoginSuccess (login))
5354 Play .setLogin(true )
5455 Play .setUserInfo(login.nickname, login.username)
55- getApplication<Application >().showToast(
56- if (account.isLogin) getApplication<Application >().getString(R .string.login_success) else getApplication<Application >().getString(
57- R .string.register_success
56+ withContext(Dispatchers .Main ) {
57+ getApplication<Application >().showToast(
58+ if (account.isLogin) getApplication<Application >().getString(R .string.login_success) else getApplication<Application >().getString(
59+ R .string.register_success
60+ )
5861 )
59- )
62+ }
6063 ArticleBroadCast .sendArticleChangesReceiver(context = getApplication())
6164 } else {
62- getApplication<Application >().showToast(loginModel.errorMsg)
65+ withContext(Dispatchers .Main ) {
66+ getApplication<Application >().showToast(loginModel.errorMsg)
67+ }
6368 _state .postValue(LoginError )
6469 }
6570 }
Original file line number Diff line number Diff line change 33 compileSdkVersion : 32 ,
44 minSdkVersion : 24 ,
55 targetSdkVersion : 32 ,
6- versionCode : 31 ,
7- versionName : " 4.5.3 " ,
6+ versionCode : 35 ,
7+ versionName : " 5.0.0 " ,
88 testInstrumentationRunner : " androidx.test.runner.AndroidJUnitRunner" ,
99 consumerProguardFiles : ' consumer-rules.pro' ,
1010 ]
You can’t perform that action at this time.
0 commit comments