Fixed MainActivity Navigation bug
This commit is contained in:
@@ -70,6 +70,7 @@ public class MainActivity extends AppCompatActivity
|
|||||||
private int fragmentPage = FRAGMENT_NONE;
|
private int fragmentPage = FRAGMENT_NONE;
|
||||||
private int currentPage = FRAGMENT_NONE;
|
private int currentPage = FRAGMENT_NONE;
|
||||||
private String fragmentData = "";
|
private String fragmentData = "";
|
||||||
|
private String currentData = "";
|
||||||
private CanteenBrowser mCanteenBrowser;
|
private CanteenBrowser mCanteenBrowser;
|
||||||
private boolean mOfflineMode = false;
|
private boolean mOfflineMode = false;
|
||||||
private HashMap<String, RequestPermissionsResultListener> permissionListeners = new HashMap<>();
|
private HashMap<String, RequestPermissionsResultListener> permissionListeners = new HashMap<>();
|
||||||
@@ -358,27 +359,27 @@ public class MainActivity extends AppCompatActivity
|
|||||||
} else {
|
} else {
|
||||||
findViewById(R.id.app_bar_layout).setVisibility(View.VISIBLE);
|
findViewById(R.id.app_bar_layout).setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
// switch to logout
|
|
||||||
if (
|
boolean isChangeLoginState =
|
||||||
|
(
|
||||||
(newFragment == FRAGMENT_STARTUP || newFragment == FRAGMENT_LOGIN) &&
|
(newFragment == FRAGMENT_STARTUP || newFragment == FRAGMENT_LOGIN) &&
|
||||||
(currentPage != FRAGMENT_STARTUP && currentPage != FRAGMENT_LOGIN)
|
(currentPage != FRAGMENT_STARTUP && currentPage != FRAGMENT_LOGIN)
|
||||||
) {
|
) || (
|
||||||
refreshNavigation();
|
|
||||||
} // switch to login
|
|
||||||
else if (
|
|
||||||
(currentPage == FRAGMENT_STARTUP || currentPage == FRAGMENT_LOGIN || currentPage == FRAGMENT_NONE) &&
|
(currentPage == FRAGMENT_STARTUP || currentPage == FRAGMENT_LOGIN || currentPage == FRAGMENT_NONE) &&
|
||||||
(newFragment != FRAGMENT_STARTUP && newFragment != FRAGMENT_LOGIN && (getKVV().isLoggedIn() || mOfflineMode))
|
(newFragment != FRAGMENT_STARTUP && newFragment != FRAGMENT_LOGIN && (getKVV().isLoggedIn() || mOfflineMode))
|
||||||
) {
|
);
|
||||||
refreshNavigation();
|
|
||||||
}
|
|
||||||
setNavigationSelection(newFragment, newData);
|
|
||||||
|
|
||||||
if (newFragment != FRAGMENT_STARTUP && newFragment != FRAGMENT_NONE && newFragment != FRAGMENT_LOGIN) {
|
if (newFragment != FRAGMENT_STARTUP && newFragment != FRAGMENT_NONE && newFragment != FRAGMENT_LOGIN) {
|
||||||
this.fragmentPage = newFragment;
|
this.fragmentPage = newFragment;
|
||||||
this.fragmentData = newData;
|
this.fragmentData = newData;
|
||||||
}
|
}
|
||||||
this.currentPage = newFragment;
|
this.currentPage = newFragment;
|
||||||
|
this.currentData = newData;
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
|
if (isChangeLoginState)
|
||||||
|
refreshNavigation();
|
||||||
|
else
|
||||||
|
setNavigationSelection(currentPage, currentData);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setOfflineBanner(boolean onlineMode) {
|
private void setOfflineBanner(boolean onlineMode) {
|
||||||
@@ -573,6 +574,6 @@ public class MainActivity extends AppCompatActivity
|
|||||||
else
|
else
|
||||||
mNavigationView.inflateMenu(R.menu.activity_main_drawer);
|
mNavigationView.inflateMenu(R.menu.activity_main_drawer);
|
||||||
afterAnyMenuInflate(isLoggedIn);
|
afterAnyMenuInflate(isLoggedIn);
|
||||||
setNavigationSelection(fragmentPage, fragmentData);
|
setNavigationSelection(currentPage, currentData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ public class Modules implements Iterable<Modules.Module>, Serializable {
|
|||||||
this.list.add(m);
|
this.list.add(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.list.toString();
|
return this.list.toString();
|
||||||
@@ -153,6 +154,7 @@ public class Modules implements Iterable<Modules.Module>, Serializable {
|
|||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Semester: "+semester+
|
return "Semester: "+semester+
|
||||||
|
|||||||
Reference in New Issue
Block a user