From: Damyan Ivanov Date: Tue, 16 Apr 2019 18:29:26 +0000 (+0300) Subject: avoid multiple acc/trn list updating when switching profiles X-Git-Tag: v0.10.0~95 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=0b77cf6b4e9d7657a25900afb107dc76443fc7ca;p=mobile-ledger.git avoid multiple acc/trn list updating when switching profiles --- 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();