|
@@ -298,7 +298,11 @@ public class MainActivity extends Activity {
|
|
|
|
|
|
if(item.getItemId() == android.R.id.home){
|
|
if(item.getItemId() == android.R.id.home){
|
|
if(!mDrawerToggle.isDrawerIndicatorEnabled()){
|
|
if(!mDrawerToggle.isDrawerIndicatorEnabled()){
|
|
- if(getFragmentManager().getBackStackEntryCount() > 0) getFragmentManager().popBackStack();
|
|
|
|
|
|
+ if(getFragmentManager().getBackStackEntryCount() > 0) {
|
|
|
|
+ getFragmentManager().popBackStackImmediate();
|
|
|
|
+ this.mDisplayedFragment = getFragmentManager().findFragmentById(R.id.content_frame);
|
|
|
|
+ this.mInvalidMenuItem = true;
|
|
|
|
+ }
|
|
|
|
|
|
if(getCurrentFragment().getTag() != null) mDrawerToggle.setDrawerIndicatorEnabled(true);
|
|
if(getCurrentFragment().getTag() != null) mDrawerToggle.setDrawerIndicatorEnabled(true);
|
|
return true;
|
|
return true;
|
|
@@ -408,9 +412,9 @@ public class MainActivity extends Activity {
|
|
injectFragment(fragment, enableBack, null);
|
|
injectFragment(fragment, enableBack, null);
|
|
}
|
|
}
|
|
|
|
|
|
- private void injectFragment(Fragment fragment, boolean enableBack, Object tagObj){
|
|
|
|
|
|
+ public void injectFragment(Fragment fragment, boolean enableBack, Object tagObj){
|
|
if(enableBack){
|
|
if(enableBack){
|
|
- //mDrawerToggle.setDrawerIndicatorEnabled(false);
|
|
|
|
|
|
+ mDrawerToggle.setDrawerIndicatorEnabled(false);
|
|
}
|
|
}
|
|
|
|
|
|
String tag = (tagObj == null ? null : tagObj.toString());
|
|
String tag = (tagObj == null ? null : tagObj.toString());
|
|
@@ -419,7 +423,7 @@ public class MainActivity extends Activity {
|
|
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
|
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
|
fragmentTransaction.replace(R.id.content_frame, fragment, tag);
|
|
fragmentTransaction.replace(R.id.content_frame, fragment, tag);
|
|
|
|
|
|
- if(tagObj == null || !(fragmentManager.getBackStackEntryCount() == 0 && tagObj.equals(MainMenuItem.HOME))) fragmentTransaction.addToBackStack(tag);
|
|
|
|
|
|
+ fragmentTransaction.addToBackStack(tag);
|
|
|
|
|
|
fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
|
|
fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
|
|
fragmentTransaction.commit();
|
|
fragmentTransaction.commit();
|
|
@@ -433,8 +437,14 @@ public class MainActivity extends Activity {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void onBackPressed() {
|
|
public void onBackPressed() {
|
|
- super.onBackPressed();
|
|
|
|
- //if(getCurrentFragment().getTag() != null) mDrawerToggle.setDrawerIndicatorEnabled(true);
|
|
|
|
|
|
+ if(getFragmentManager().getBackStackEntryCount() == 1) {
|
|
|
|
+ finish();
|
|
|
|
+ } else {
|
|
|
|
+ super.onBackPressed();
|
|
|
|
+ this.mDisplayedFragment = getFragmentManager().findFragmentById(R.id.content_frame);
|
|
|
|
+ this.mInvalidMenuItem = true;
|
|
|
|
+ if(getCurrentFragment().getTag() != null) mDrawerToggle.setDrawerIndicatorEnabled(true);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
public static void displayBackStack(FragmentManager fm) {
|
|
public static void displayBackStack(FragmentManager fm) {
|