Fixed MainActivity Navigation bug

This commit is contained in:
Caesar2011
2018-10-31 00:02:17 +01:00
parent a7ff15142f
commit 582e6e17e8
2 changed files with 18 additions and 15 deletions

View File

@@ -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<String, RequestPermissionsResultListener> 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 (
boolean isChangeLoginState =
(
(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);
);
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);
}
}

View File

@@ -35,6 +35,7 @@ public class Modules implements Iterable<Modules.Module>, Serializable {
this.list.add(m);
}
@NonNull
@Override
public String toString() {
return this.list.toString();
@@ -153,6 +154,7 @@ public class Modules implements Iterable<Modules.Module>, Serializable {
return ID;
}
@NonNull
@Override
public String toString() {
return "Semester: "+semester+