Commit 18739166 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Fix close warning not shown in browsers

parent 6e64f80d
......@@ -200,11 +200,10 @@ public class AudioPlayerContainerActivity extends BaseActivity implements Playba
switch (item.getItemId()) {
case android.R.id.home:
// Current fragment loaded
Fragment current = getCurrentFragment();
if (current instanceof StorageBrowserFragment)
((StorageBrowserFragment) current).goBack();
else
finish();
final Fragment current = getCurrentFragment();
if (current instanceof StorageBrowserFragment && ((StorageBrowserFragment) current).goBack())
return true;
finish();
return true;
default:
return super.onOptionsItemSelected(item);
......
......@@ -347,8 +347,7 @@ public class MainActivity extends ContentActivity implements FilterQueryProvider
// If it's the directory view, a "backpressed" action shows a parent.
final Fragment fragment = getCurrentFragment();
if (fragment instanceof BaseBrowserFragment){
((BaseBrowserFragment)fragment).goBack();
if (fragment instanceof BaseBrowserFragment && ((BaseBrowserFragment)fragment).goBack()){
return;
} else if (fragment instanceof ExtensionBrowser) {
((ExtensionBrowser) fragment).goBack();
......
......@@ -277,15 +277,14 @@ public abstract class BaseBrowserFragment extends SortableFragment<BaseBrowserAd
return mCurrentMedia != null ? mrl : null;
}
public void goBack(){
public boolean goBack(){
final FragmentActivity activity = getActivity();
if (activity == null)
return;
if (activity == null) return false;
if (!mRoot) {
if (!activity.getSupportFragmentManager().popBackStackImmediate() && activity instanceof MainActivity)
((MainActivity)activity).showFragment(this instanceof NetworkBrowserFragment ? R.id.nav_network : R.id.nav_directories);
} else
activity.finish();
}
return !mRoot;
}
public void browse(MediaWrapper media, int position, boolean save) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment