diff --git a/app/src/main/java/de/sebse/fuplanner/MainActivity.java b/app/src/main/java/de/sebse/fuplanner/MainActivity.java index a3fde9d..7ddcd08 100644 --- a/app/src/main/java/de/sebse/fuplanner/MainActivity.java +++ b/app/src/main/java/de/sebse/fuplanner/MainActivity.java @@ -64,6 +64,7 @@ public class MainActivity extends AppCompatActivity private NavigationView mNavigationView; private int fragmentPage = FRAGMENT_NONE; + private int currentPage = FRAGMENT_NONE; private String fragmentData = ""; private CanteenBrowser mCanteenBrowser; private boolean mOfflineMode = false; @@ -116,7 +117,7 @@ public class MainActivity extends AppCompatActivity @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. - if (fragmentPage == FRAGMENT_SCHEDULE) { + if (currentPage == FRAGMENT_SCHEDULE) { getMenuInflater().inflate(R.menu.options_schedule, menu); return true; } @@ -337,7 +338,7 @@ public class MainActivity extends AppCompatActivity findViewById(R.id.app_bar_layout).setVisibility(View.VISIBLE); } // switch to logout - if ((fragmentPage != FRAGMENT_STARTUP && fragmentPage != FRAGMENT_LOGIN) && (newFragment == FRAGMENT_STARTUP || newFragment == FRAGMENT_LOGIN)) { + if ((currentPage != FRAGMENT_STARTUP && currentPage != FRAGMENT_LOGIN) && (newFragment == FRAGMENT_STARTUP || newFragment == FRAGMENT_LOGIN)) { View header = mNavigationView.getHeaderView(0); //header.findViewById(R.id.imageView).setVisibility(View.GONE); header.findViewById(R.id.login_name).setVisibility(View.GONE); @@ -355,7 +356,7 @@ public class MainActivity extends AppCompatActivity afterAnyMenuInflate(); } // switch to login else if ( - (fragmentPage == FRAGMENT_STARTUP || fragmentPage == FRAGMENT_LOGIN || fragmentPage == FRAGMENT_NONE) && + (currentPage == FRAGMENT_STARTUP || currentPage == FRAGMENT_LOGIN || currentPage == FRAGMENT_NONE) && (newFragment != FRAGMENT_STARTUP && newFragment != FRAGMENT_LOGIN && getKVV().isLoggedIn()) ) { View header = mNavigationView.getHeaderView(0); @@ -402,8 +403,11 @@ public class MainActivity extends AppCompatActivity }, log::e); } - this.fragmentPage = newFragment; - this.fragmentData = newData; + if (newFragment != FRAGMENT_STARTUP && newFragment != FRAGMENT_NONE) { + this.fragmentPage = newFragment; + this.fragmentData = newData; + } + this.currentPage = newFragment; invalidateOptionsMenu(); }