style(AccountUtil.kt): 修改方法名

This commit is contained in:
HuanCheng65 2023-03-11 01:15:25 +08:00
parent 92ceb99bda
commit c104ae920e
No known key found for this signature in database
GPG Key ID: E9031EF91A805148
5 changed files with 9 additions and 7 deletions

View File

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

View File

@ -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?)!!)
)

View File

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

View File

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

View File

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