diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-06-15 20:25:09 +0300 |
---|---|---|
committer | Niedermann IT-Dienstleistungen <stefan-niedermann@users.noreply.github.com> | 2020-06-15 21:32:47 +0300 |
commit | b22fe28c168998cd2a5bfd8d937888ca8536165b (patch) | |
tree | e1ee37d326dce5e58a39f452497fa44ab152d244 /app/src/main/java/it/niedermann/nextcloud/deck/ui/accountswitcher | |
parent | 0593392c82850a5546ae8d3a60607beeb880bee0 (diff) |
Unsubscribe stacks as soon as the board is changed
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/ui/accountswitcher')
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/ui/accountswitcher/AccountSwitcherDialog.java | 32 |
1 files changed, 7 insertions, 25 deletions
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 67b4dcbc3..a3994172c 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 @@ -30,27 +30,15 @@ import static it.niedermann.nextcloud.deck.ui.MainActivity.ACTIVITY_MANAGE_ACCOU public class AccountSwitcherDialog extends BrandedDialogFragment { - private static final String KEY_CURRENT_ACCOUNT_ID = "current_account_id"; - private AccountSwitcherAdapter adapter; private SyncManager syncManager; private DialogAccountSwitcherBinding binding; private MainViewModel viewModel; - private long currentAccountId; @Override public void onAttach(@NonNull Context context) { super.onAttach(context); - viewModel = new ViewModelProvider(requireActivity()).get(MainViewModel.class); - final Bundle args = getArguments(); - - if (args == null || !args.containsKey(KEY_CURRENT_ACCOUNT_ID)) { - throw new IllegalArgumentException("Please provide at least " + KEY_CURRENT_ACCOUNT_ID); - } else { - this.currentAccountId = args.getLong(KEY_CURRENT_ACCOUNT_ID); - } - syncManager = new SyncManager(requireActivity()); } @@ -67,11 +55,6 @@ 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 -> { @@ -79,6 +62,11 @@ public class AccountSwitcherDialog extends BrandedDialogFragment { dismiss(); })); + observeOnce(syncManager.readAccounts(), requireActivity(), (accounts) -> { + accounts.remove(viewModel.getCurrentAccount()); + adapter.setAccounts(accounts); + }); + binding.accountsList.setAdapter(adapter); binding.addAccount.setOnClickListener((v) -> { @@ -102,14 +90,8 @@ public class AccountSwitcherDialog extends BrandedDialogFragment { .create(); } - public static DialogFragment newInstance(long currentAccountId) { - DialogFragment dialog = new AccountSwitcherDialog(); - - Bundle args = new Bundle(); - args.putLong(KEY_CURRENT_ACCOUNT_ID, currentAccountId); - dialog.setArguments(args); - - return dialog; + public static DialogFragment newInstance() { + return new AccountSwitcherDialog(); } @Override |