From 0b77cf6b4e9d7657a25900afb107dc76443fc7ca Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Tue, 16 Apr 2019 21:29:26 +0300 Subject: [PATCH] avoid multiple acc/trn list updating when switching profiles --- .../mobileledger/ui/activity/MainActivity.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java index a2cf30ea..1eb8f458 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java @@ -309,8 +309,9 @@ public class MainActivity extends ProfileThemedActivity { findViewById(R.id.nav_profile_list_head_layout) .setOnClickListener(this::navProfilesHeadClicked); findViewById(R.id.nav_profiles_label).setOnClickListener(this::navProfilesHeadClicked); + boolean initialStart = Data.profile.get() == null; setupProfile(); - onProfileChanged(null); + if (!initialStart) onProfileChanged(null); updateLastUpdateTextFromDB(); } @@ -367,13 +368,6 @@ public class MainActivity extends ProfileThemedActivity { findViewById(R.id.pager_layout) .setVisibility(haveProfile ? View.VISIBLE : View.VISIBLE); - Data.transactions.clear(); - debug("transactions", "requesting list reload"); - TransactionListViewModel.scheduleTransactionListReload(); - - Data.accounts.clear(); - AccountSummaryViewModel.scheduleAccountListReload(); - if (profile == null) MainActivity.this.setTitle(R.string.app_name); else MainActivity.this.setTitle(profile.getName()); MainActivity.this.updateLastUpdateTextFromDB(); @@ -405,6 +399,13 @@ public class MainActivity extends ProfileThemedActivity { } drawer.closeDrawers(); + Data.transactions.clear(); + debug("transactions", "requesting list reload"); + TransactionListViewModel.scheduleTransactionListReload(); + + Data.accounts.clear(); + AccountSummaryViewModel.scheduleAccountListReload(); + if (profile == null) { mToolbar.setSubtitle(null); fab.hide(); -- 2.39.5