Handle irrational decision to run screaming from file listing

This commit is contained in:
TwistedUmbrella 2014-02-12 19:42:44 -05:00
parent 188d7cbe4f
commit 5485f2f16e
1 changed files with 25 additions and 12 deletions

View File

@ -416,20 +416,19 @@ public class MainActivity extends SlidingFragmentActivity implements
Fragment fragment = (FileBrowser) getSupportFragmentManager()
.findFragmentByTag("MAIN_BROWSER");
if (fragment != null && fragment.isVisible()) {
MainActivity.this.finish();
boolean readyToQuit = true;
if (fragment.getArguments() != null) {
readyToQuit = fragment.getArguments().getBoolean(
"ImgBrowse", true);
}
if (readyToQuit) {
MainActivity.this.finish();
} else {
launchMainFragment(fragment);
}
return true;
} else {
fragment = new FileBrowser();
Bundle args = new Bundle();
args.putBoolean("ImgBrowse", true);
args.putString("browse_entry", null);
args.putBoolean("games_entry", false);
fragment.setArguments(args);
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.fragment_container, fragment,
"MAIN_BROWSER").commit();
setTitle(getString(R.string.browser));
launchMainFragment(fragment);
return true;
}
@ -437,6 +436,20 @@ public class MainActivity extends SlidingFragmentActivity implements
return super.onKeyDown(keyCode, event);
}
private void launchMainFragment(Fragment fragment) {
fragment = new FileBrowser();
Bundle args = new Bundle();
args.putBoolean("ImgBrowse", true);
args.putString("browse_entry", null);
args.putBoolean("games_entry", false);
fragment.setArguments(args);
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.fragment_container, fragment,
"MAIN_BROWSER").commit();
setTitle(getString(R.string.browser));
}
@Override
protected void onPause() {