style(AccountUtil.kt): 修改方法名
This commit is contained in:
parent
92ceb99bda
commit
c104ae920e
|
|
@ -101,7 +101,7 @@ class LoginActivity : BaseActivity(), WebViewListener {
|
|||
AccountUtil.newAccount(account.uid, account) {
|
||||
isLoadingAccount = false
|
||||
if (it) {
|
||||
AccountUtil.switchUser(this@LoginActivity, account.id)
|
||||
AccountUtil.switchAccount(this@LoginActivity, account.id)
|
||||
snackBar.setText("登录成功,即将跳转")
|
||||
handler.postDelayed({
|
||||
snackBar.dismiss()
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ class PreferencesFragment : PreferencesFragment() {
|
|||
val accountsPreference = findPreference<ListPreference>("switch_account")
|
||||
accountsPreference!!.onPreferenceChangeListener =
|
||||
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any? ->
|
||||
if (AccountUtil.switchUser(
|
||||
if (AccountUtil.switchAccount(
|
||||
attachContext,
|
||||
Integer.valueOf((newValue as String?)!!)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -94,10 +94,12 @@ fun AccountManagePage(
|
|||
)
|
||||
}
|
||||
},
|
||||
onValueChange = { AccountUtil.switchUser(context, it.toInt()) },
|
||||
onValueChange = { AccountUtil.switchAccount(context, it.toInt()) },
|
||||
enabled = true,
|
||||
defaultValue = account.id.toString(),
|
||||
entries = AllAccounts.current.associate { it.id.toString() to (it.nameShow ?: it.name) }
|
||||
entries = AllAccounts.current.associate {
|
||||
it.id.toString() to (it.nameShow ?: it.name)
|
||||
}
|
||||
)
|
||||
} else {
|
||||
TextPref(
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ fun AccountNavIcon(
|
|||
menuContent = {
|
||||
val allAccounts = AccountUtil.allAccounts
|
||||
allAccounts.forEach {
|
||||
DropdownMenuItem(onClick = { AccountUtil.switchUser(context, it.id) }) {
|
||||
DropdownMenuItem(onClick = { AccountUtil.switchAccount(context, it.id) }) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.clip(CircleShape)
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ object AccountUtil {
|
|||
}
|
||||
|
||||
@JvmStatic
|
||||
fun switchUser(context: Context, id: Int): Boolean {
|
||||
fun switchAccount(context: Context, id: Int): Boolean {
|
||||
context.sendBroadcast(Intent().setAction(ACTION_SWITCH_ACCOUNT))
|
||||
val account = runCatching { getAccountInfo(id) }.getOrNull() ?: return false
|
||||
mutableCurrentAccountState.value = account
|
||||
|
|
@ -188,7 +188,7 @@ object AccountUtil {
|
|||
if (accounts.size > 1) {
|
||||
accounts = allAccounts
|
||||
account = accounts[0]
|
||||
switchUser(context, account.id)
|
||||
switchAccount(context, account.id)
|
||||
Toast.makeText(context, "退出登录成功,已切换至账号 " + account.nameShow, Toast.LENGTH_SHORT).show()
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue