master
pan 4 years ago
parent 306d953e76
commit 303f98ff04
  1. 3
      foreground/src/main/java/com/gyf/csams/account/model/AccountViewModel.kt
  2. 8
      foreground/src/main/java/com/gyf/csams/account/ui/AccountActivity.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)
}
}

@ -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()
}

Loading…
Cancel
Save