[Android] Fix close warning not shown in browsers

Geoffrey Métais git at videolan.org
Fri Jan 12 10:47:20 CET 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Jan 12 10:43:44 2018 +0100| [18739166e0285a92de8f4e363d6932d03a22da3f] | committer: Geoffrey Métais

Fix close warning not shown in browsers

> https://code.videolan.org/videolan/vlc-android/commit/18739166e0285a92de8f4e363d6932d03a22da3f
---

 .../src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java   | 9 ++++-----
 vlc-android/src/org/videolan/vlc/gui/MainActivity.java           | 3 +--
 .../src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java    | 9 ++++-----
 3 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java b/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
index ab3dd23c2..c7cc73582 100644
--- a/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
@@ -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);
diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index 8b67e1d78..2c41cb986 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -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();
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
index e22d3c49d..4078c36cb 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
@@ -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) {



More information about the Android mailing list