]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java
more flow debugging
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / activity / MainActivity.java
index 86463aac20c22bc34d7f50ec4cec5fc00ee74541..3e774a04ce4883920cea6f2c5ce015c4f049dadf 100644 (file)
@@ -100,6 +100,7 @@ public class MainActivity extends ProfileThemedActivity {
     protected void onStart() {
         super.onStart();
 
+        Log.d("flow", "MainActivity.onStart()");
         setupProfile();
 
         updateLastUpdateTextFromDB();
@@ -129,7 +130,7 @@ public class MainActivity extends ProfileThemedActivity {
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-
+        Log.d("flow", "MainActivity.onCreate()");
         setContentView(R.layout.activity_main);
 
         fab = findViewById(R.id.btn_add_transaction);
@@ -169,6 +170,22 @@ public class MainActivity extends ProfileThemedActivity {
                     fab.hide();
                 }
 
+                int old_index = -1;
+                int new_index = -1;
+                if (arg != null) {
+                    MobileLedgerProfile old = (MobileLedgerProfile) arg;
+                    old_index = Data.getProfileIndex(old);
+                    new_index = Data.getProfileIndex(profile);
+                }
+
+                if ((old_index != -1) && (new_index != -1)) {
+                    mProfileListAdapter.notifyItemChanged(old_index);
+                    mProfileListAdapter.notifyItemChanged(new_index);
+                }
+                else mProfileListAdapter.notifyDataSetChanged();
+
+                collapseProfileList();
+
                 int newProfileTheme = profile.getThemeId();
                 if (newProfileTheme != Colors.profileThemeId) {
                     Log.d("profiles", String.format("profile theme %d → %d", Colors.profileThemeId,
@@ -176,6 +193,8 @@ public class MainActivity extends ProfileThemedActivity {
                     profileThemeChanged();
                     Colors.profileThemeId = newProfileTheme;
                 }
+                else
+                    drawer.closeDrawers();
             });
         });
         Data.profiles.addObserver((o, arg) -> {
@@ -440,7 +459,8 @@ public class MainActivity extends ProfileThemedActivity {
                 mBackMeansToAccountList = false;
             }
             else {
-                Log.d("fragments", String.format("manager stack: %d", fragmentManager.getBackStackEntryCount()));
+                Log.d("fragments", String.format("manager stack: %d",
+                        fragmentManager.getBackStackEntryCount()));
 
                 super.onBackPressed();
             }