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) {
|
AccountUtil.newAccount(account.uid, account) {
|
||||||
isLoadingAccount = false
|
isLoadingAccount = false
|
||||||
if (it) {
|
if (it) {
|
||||||
AccountUtil.switchUser(this@LoginActivity, account.id)
|
AccountUtil.switchAccount(this@LoginActivity, account.id)
|
||||||
snackBar.setText("登录成功,即将跳转")
|
snackBar.setText("登录成功,即将跳转")
|
||||||
handler.postDelayed({
|
handler.postDelayed({
|
||||||
snackBar.dismiss()
|
snackBar.dismiss()
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ class PreferencesFragment : PreferencesFragment() {
|
||||||
val accountsPreference = findPreference<ListPreference>("switch_account")
|
val accountsPreference = findPreference<ListPreference>("switch_account")
|
||||||
accountsPreference!!.onPreferenceChangeListener =
|
accountsPreference!!.onPreferenceChangeListener =
|
||||||
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any? ->
|
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any? ->
|
||||||
if (AccountUtil.switchUser(
|
if (AccountUtil.switchAccount(
|
||||||
attachContext,
|
attachContext,
|
||||||
Integer.valueOf((newValue as String?)!!)
|
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,
|
enabled = true,
|
||||||
defaultValue = account.id.toString(),
|
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 {
|
} else {
|
||||||
TextPref(
|
TextPref(
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ fun AccountNavIcon(
|
||||||
menuContent = {
|
menuContent = {
|
||||||
val allAccounts = AccountUtil.allAccounts
|
val allAccounts = AccountUtil.allAccounts
|
||||||
allAccounts.forEach {
|
allAccounts.forEach {
|
||||||
DropdownMenuItem(onClick = { AccountUtil.switchUser(context, it.id) }) {
|
DropdownMenuItem(onClick = { AccountUtil.switchAccount(context, it.id) }) {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.clip(CircleShape)
|
.clip(CircleShape)
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ object AccountUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun switchUser(context: Context, id: Int): Boolean {
|
fun switchAccount(context: Context, id: Int): Boolean {
|
||||||
context.sendBroadcast(Intent().setAction(ACTION_SWITCH_ACCOUNT))
|
context.sendBroadcast(Intent().setAction(ACTION_SWITCH_ACCOUNT))
|
||||||
val account = runCatching { getAccountInfo(id) }.getOrNull() ?: return false
|
val account = runCatching { getAccountInfo(id) }.getOrNull() ?: return false
|
||||||
mutableCurrentAccountState.value = account
|
mutableCurrentAccountState.value = account
|
||||||
|
|
@ -188,7 +188,7 @@ object AccountUtil {
|
||||||
if (accounts.size > 1) {
|
if (accounts.size > 1) {
|
||||||
accounts = allAccounts
|
accounts = allAccounts
|
||||||
account = accounts[0]
|
account = accounts[0]
|
||||||
switchUser(context, account.id)
|
switchAccount(context, account.id)
|
||||||
Toast.makeText(context, "退出登录成功,已切换至账号 " + account.nameShow, Toast.LENGTH_SHORT).show()
|
Toast.makeText(context, "退出登录成功,已切换至账号 " + account.nameShow, Toast.LENGTH_SHORT).show()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue