diff --git a/app/src/main/java/de/sebse/fuplanner/MainActivity.java b/app/src/main/java/de/sebse/fuplanner/MainActivity.java index a17b61d..a4929d3 100644 --- a/app/src/main/java/de/sebse/fuplanner/MainActivity.java +++ b/app/src/main/java/de/sebse/fuplanner/MainActivity.java @@ -70,6 +70,7 @@ public class MainActivity extends AppCompatActivity private int fragmentPage = FRAGMENT_NONE; private int currentPage = FRAGMENT_NONE; private String fragmentData = ""; + private String currentData = ""; private CanteenBrowser mCanteenBrowser; private boolean mOfflineMode = false; private HashMap permissionListeners = new HashMap<>(); @@ -358,27 +359,27 @@ public class MainActivity extends AppCompatActivity } else { findViewById(R.id.app_bar_layout).setVisibility(View.VISIBLE); } - // switch to logout - if ( - (newFragment == FRAGMENT_STARTUP || newFragment == FRAGMENT_LOGIN) && - (currentPage != FRAGMENT_STARTUP && currentPage != FRAGMENT_LOGIN) - ) { - refreshNavigation(); - } // switch to login - else if ( - (currentPage == FRAGMENT_STARTUP || currentPage == FRAGMENT_LOGIN || currentPage == FRAGMENT_NONE) && - (newFragment != FRAGMENT_STARTUP && newFragment != FRAGMENT_LOGIN && (getKVV().isLoggedIn() || mOfflineMode)) - ) { - refreshNavigation(); - } - setNavigationSelection(newFragment, newData); + + boolean isChangeLoginState = + ( + (newFragment == FRAGMENT_STARTUP || newFragment == FRAGMENT_LOGIN) && + (currentPage != FRAGMENT_STARTUP && currentPage != FRAGMENT_LOGIN) + ) || ( + (currentPage == FRAGMENT_STARTUP || currentPage == FRAGMENT_LOGIN || currentPage == FRAGMENT_NONE) && + (newFragment != FRAGMENT_STARTUP && newFragment != FRAGMENT_LOGIN && (getKVV().isLoggedIn() || mOfflineMode)) + ); if (newFragment != FRAGMENT_STARTUP && newFragment != FRAGMENT_NONE && newFragment != FRAGMENT_LOGIN) { this.fragmentPage = newFragment; this.fragmentData = newData; } this.currentPage = newFragment; + this.currentData = newData; invalidateOptionsMenu(); + if (isChangeLoginState) + refreshNavigation(); + else + setNavigationSelection(currentPage, currentData); } private void setOfflineBanner(boolean onlineMode) { @@ -573,6 +574,6 @@ public class MainActivity extends AppCompatActivity else mNavigationView.inflateMenu(R.menu.activity_main_drawer); afterAnyMenuInflate(isLoggedIn); - setNavigationSelection(fragmentPage, fragmentData); + setNavigationSelection(currentPage, currentData); } } diff --git a/app/src/main/java/de/sebse/fuplanner/services/KVV/types/Modules.java b/app/src/main/java/de/sebse/fuplanner/services/KVV/types/Modules.java index 4dca667..6c0f3d5 100644 --- a/app/src/main/java/de/sebse/fuplanner/services/KVV/types/Modules.java +++ b/app/src/main/java/de/sebse/fuplanner/services/KVV/types/Modules.java @@ -35,6 +35,7 @@ public class Modules implements Iterable, Serializable { this.list.add(m); } + @NonNull @Override public String toString() { return this.list.toString(); @@ -153,6 +154,7 @@ public class Modules implements Iterable, Serializable { return ID; } + @NonNull @Override public String toString() { return "Semester: "+semester+