X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2Factivity%2FMainActivity.java;h=d5d0b71005b4cc48818fb55e0ddc8a521fc1969d;hb=bc7510c72087c68d82c93dafac9269753c01875c;hp=5ca25061b277045987d0699a70ed9b51a99dd37c;hpb=b7a79ded94e99d06567b6617c7caa926799dc90c;p=mobile-ledger.git 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 5ca25061..d5d0b710 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 @@ -392,30 +392,30 @@ public class MainActivity extends ProfileThemedActivity implements FabManager.Fa createShortcuts(newList); - Profile currentProfile = Data.getProfile(); - boolean currentProfilePresent = false; + final Profile currentProfile = Data.getProfile(); + Profile replacementProfile = null; if (currentProfile != null) { for (Profile p : newList) { if (p.getId() == currentProfile.getId()) { - currentProfilePresent = true; + replacementProfile = p; break; } } } - if (!currentProfilePresent) { + + if (replacementProfile == null) { Logger.debug(TAG, "Switching profile because the current is no longer available"); Data.setCurrentProfile(newList.get(0)); } + else { + Data.setCurrentProfile(replacementProfile); + } } /** * called when the current profile has changed */ private void onProfileChanged(@Nullable Profile newProfile) { - if (this.profile == null) { - if (newProfile == null) - return; - } - else { + if (this.profile != null) { if (this.profile.equals(newProfile)) return; } @@ -427,7 +427,7 @@ public class MainActivity extends ProfileThemedActivity implements FabManager.Fa else setTitle(R.string.app_name); - int newProfileTheme = haveProfile ? newProfile.getTheme() : -1; + int newProfileTheme = haveProfile ? newProfile.getTheme() : Colors.DEFAULT_HUE_DEG; if (newProfileTheme != Colors.profileThemeId) { Logger.debug("profiles", String.format(Locale.ENGLISH, "profile theme %d → %d", Colors.profileThemeId, @@ -482,7 +482,7 @@ public class MainActivity extends ProfileThemedActivity implements FabManager.Fa Logger.debug(TAG, "account filter changed, reloading transactions"); // mainModel.scheduleTransactionListReload(); LiveData> transactions = - new MutableLiveData<>(new ArrayList()); + new MutableLiveData<>(new ArrayList<>()); if (profile != null) { if (accFilter == null || accFilter.isEmpty()) { transactions = DB.get()