From 303f98ff040343213d7d7989a7791f13f86c0e78 Mon Sep 17 00:00:00 2001 From: pan <1029559041@qq.com> Date: Tue, 25 May 2021 14:27:33 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gyf/csams/account/model/AccountViewModel.kt | 3 --- .../main/java/com/gyf/csams/account/ui/AccountActivity.kt | 8 ++++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/foreground/src/main/java/com/gyf/csams/account/model/AccountViewModel.kt b/foreground/src/main/java/com/gyf/csams/account/model/AccountViewModel.kt index d1685e5..24a1dbb 100644 --- a/foreground/src/main/java/com/gyf/csams/account/model/AccountViewModel.kt +++ b/foreground/src/main/java/com/gyf/csams/account/model/AccountViewModel.kt @@ -1,7 +1,6 @@ package com.gyf.csams.account.model import android.app.Application -import android.content.Intent import android.os.Build import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.LiveData @@ -12,7 +11,6 @@ import com.gyf.csams.AccountApi import com.gyf.csams.Api import com.gyf.csams.R import com.gyf.csams.account.ui.AccountRoute -import com.gyf.csams.main.ui.MainActivity import com.gyf.csams.util.AppDatabase import com.gyf.csams.util.SimpleCallback import com.gyf.csams.util.Token @@ -269,7 +267,6 @@ class AccountViewModel(application: Application) : AndroidViewModel(application) TokenManager.token = it db?.tokenDao()?.save(token = it) }.invokeOnCompletion { - context.startActivity(Intent(context, MainActivity::class.java)) _finishLogin.postValue(true) } } diff --git a/foreground/src/main/java/com/gyf/csams/account/ui/AccountActivity.kt b/foreground/src/main/java/com/gyf/csams/account/ui/AccountActivity.kt index 4fd380f..1aa5c80 100644 --- a/foreground/src/main/java/com/gyf/csams/account/ui/AccountActivity.kt +++ b/foreground/src/main/java/com/gyf/csams/account/ui/AccountActivity.kt @@ -27,6 +27,7 @@ import com.gyf.csams.BuildConfig import com.gyf.csams.R import com.gyf.csams.account.model.AccountViewModel import com.gyf.csams.account.model.DialogMessage +import com.gyf.csams.main.ui.MainActivity import com.gyf.lib.uikit.* @@ -47,6 +48,7 @@ class AccountActivity : ComponentActivity() { route = AccountRoute.Login ) { isValidForm: Boolean, accountViewModel: AccountViewModel, scaffoldModel: ScaffoldModel -> + Spacer(modifier = Modifier.height(10.dp)) OutlinedButton( onClick = { @@ -65,6 +67,12 @@ class AccountActivity : ComponentActivity() { val finishLogin: Boolean? by accountViewModel.finishLogin.observeAsState() if (finishLogin == true) { + startActivity( + Intent( + LocalContext.current, + MainActivity::class.java + ) + ) finish() }