diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-06-15 12:18:00 +0300 |
---|---|---|
committer | Niedermann IT-Dienstleistungen <stefan-niedermann@users.noreply.github.com> | 2020-06-15 21:32:47 +0300 |
commit | 841afe3993b8730c7daa094457a811168fba4b6a (patch) | |
tree | eebd72afe9c85bcf33f059ac5718436227101fa3 /app/src/main/java/it/niedermann/nextcloud/deck/ui/accountswitcher | |
parent | fe8923853c8ce667febb1e4c0f19c12bd6fd74b5 (diff) |
Fix list menu
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/ui/accountswitcher')
2 files changed, 7 insertions, 12 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/accountswitcher/AccountSwitcherAdapter.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/accountswitcher/AccountSwitcherAdapter.java index 5e9bb0695..1bfc34e3b 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/accountswitcher/AccountSwitcherAdapter.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/accountswitcher/AccountSwitcherAdapter.java @@ -46,7 +46,7 @@ public class AccountSwitcherAdapter extends RecyclerView.Adapter<AccountSwitcher return localAccounts.size(); } - public void setLocalAccounts(@NonNull List<Account> localAccounts) { + public void setAccounts(@NonNull List<Account> localAccounts) { this.localAccounts.clear(); this.localAccounts.addAll(localAccounts); notifyDataSetChanged(); diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/accountswitcher/AccountSwitcherDialog.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/accountswitcher/AccountSwitcherDialog.java index d53cb130e..09592b7b7 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/accountswitcher/AccountSwitcherDialog.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/accountswitcher/AccountSwitcherDialog.java @@ -20,13 +20,13 @@ import com.nextcloud.android.sso.exceptions.NextcloudFilesAppNotInstalledExcepti import it.niedermann.nextcloud.deck.R; import it.niedermann.nextcloud.deck.databinding.DialogAccountSwitcherBinding; -import it.niedermann.nextcloud.deck.model.Account; import it.niedermann.nextcloud.deck.persistence.sync.SyncManager; import it.niedermann.nextcloud.deck.ui.MainViewModel; import it.niedermann.nextcloud.deck.ui.branding.BrandedDialogFragment; import it.niedermann.nextcloud.deck.ui.manageaccounts.ManageAccountsActivity; import it.niedermann.nextcloud.deck.util.ExceptionUtil; +import static it.niedermann.nextcloud.deck.persistence.sync.adapters.db.util.LiveDataHelper.observeOnce; import static it.niedermann.nextcloud.deck.ui.MainActivity.ACTIVITY_MANAGE_ACCOUNTS; import static it.niedermann.nextcloud.deck.ui.branding.BrandedActivity.applyBrandToLayerDrawable; @@ -68,6 +68,11 @@ public class AccountSwitcherDialog extends BrandedDialogFragment { .apply(RequestOptions.circleCropTransform()) .into(binding.currentAccountItemAvatar); + observeOnce(syncManager.readAccounts(), requireActivity(), (accounts) -> { + accounts.remove(viewModel.getCurrentAccount()); + adapter.setAccounts(accounts); + }); + binding.accountLayout.setOnClickListener((v) -> dismiss()); adapter = new AccountSwitcherAdapter((localAccount -> { @@ -75,16 +80,6 @@ public class AccountSwitcherDialog extends BrandedDialogFragment { dismiss(); })); - syncManager.readAccounts().observe(requireActivity(), (localAccounts) -> { - for (Account localAccount : localAccounts) { - if (localAccount.getId() == viewModel.getCurrentAccount().getId()) { - localAccounts.remove(localAccount); - break; - } - } - adapter.setLocalAccounts(localAccounts); - }); - binding.accountsList.setAdapter(adapter); binding.addAccount.setOnClickListener((v) -> { |