From a19411c94708088532f0e5de23683aa6e38bebed Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Sun, 13 Dec 2020 16:32:04 +0100 Subject: [PATCH] cleanup accountManager.activeAccount usages in MainActivity (#2021) --- .../main/java/com/keylesspalace/tusky/MainActivity.kt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/MainActivity.kt b/app/src/main/java/com/keylesspalace/tusky/MainActivity.kt index 58cd3a02d..31a4e80c9 100644 --- a/app/src/main/java/com/keylesspalace/tusky/MainActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/MainActivity.kt @@ -139,11 +139,8 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje } } val accountRequested = accountId != -1L - if (accountRequested) { - val account = accountManager.activeAccount - if (account == null || accountId != account.id) { - accountManager.setActiveAccount(accountId) - } + if (accountRequested && accountId != activeAccount.id) { + accountManager.setActiveAccount(accountId) } if (canHandleMimeType(intent.type)) { // Sharing to Tusky from an external app @@ -155,8 +152,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje showAccountChooserDialog(getString(R.string.action_share_as), true, object : AccountSelectionListener { override fun onAccountSelected(account: AccountEntity) { val requestedId = account.id - val activeAccount = accountManager.activeAccount - if (activeAccount != null && requestedId == activeAccount.id) { + if (requestedId == activeAccount.id) { // The correct account is already active forwardShare(intent) } else {