]> git.ktnx.net Git - mobile-ledger.git/commitdiff
avoid multiple acc/trn list updating when switching profiles
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Tue, 16 Apr 2019 18:29:26 +0000 (21:29 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Tue, 16 Apr 2019 18:29:26 +0000 (21:29 +0300)
app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java

index a2cf30ea42264a33c1c71f8da96c37e62f1283a0..1eb8f45832269edd5f34f31a45aff13f44163a21 100644 (file)
@@ -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();