[Android] Close folder if login dialog is canceled

Geoffrey Métais git at videolan.org
Thu Mar 31 16:01:14 CEST 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Mar 31 16:00:36 2016 +0200| [23ec563943777c2a5546fea0a9991666d3f8e11a] | committer: Geoffrey Métais

Close folder if login dialog is canceled

> https://code.videolan.org/videolan/vlc-android/commit/23ec563943777c2a5546fea0a9991666d3f8e11a
---

 .../vlc/gui/tv/browser/MediaSortedFragment.java    | 26 +++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/MediaSortedFragment.java b/vlc-android/src/org/videolan/vlc/gui/tv/browser/MediaSortedFragment.java
index 6ef9326..9c510c8 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/MediaSortedFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/MediaSortedFragment.java
@@ -39,6 +39,7 @@ import org.videolan.vlc.util.VLCInstance;
 public abstract class MediaSortedFragment extends SortedBrowserFragment implements MediaBrowser.EventListener {
     protected Uri mUri;
     protected MediaBrowser mMediaBrowser;
+    boolean goBack = false;
 
     abstract protected void browseRoot();
 
@@ -65,15 +66,30 @@ public abstract class MediaSortedFragment extends SortedBrowserFragment implemen
         }
     }
 
+    @Override
+    public void onResume() {
+        super.onResume();
+        if (goBack)
+            getActivity().finish();
+    }
+
     public void onPause(){
         super.onPause();
+        ((BrowserActivityInterface)getActivity()).updateEmptyView(false);
+    }
+
+    private void releaseBrowser() {
         if (mMediaBrowser != null) {
             mMediaBrowser.release();
             mMediaBrowser = null;
         }
-        ((BrowserActivityInterface)getActivity()).updateEmptyView(false);
     }
 
+    @Override
+    public void onStop() {
+        super.onStop();
+        releaseBrowser();
+    }
 
     @Override
     public void onSaveInstanceState(Bundle outState) {
@@ -95,7 +111,11 @@ public abstract class MediaSortedFragment extends SortedBrowserFragment implemen
     public void onMediaRemoved(int index, Media media) {}
 
     public void onBrowseEnd() {
-        sort();
-        mHandler.sendEmptyMessage(HIDE_LOADING);
+        releaseBrowser();
+        if (isResumed()) {
+            sort();
+            mHandler.sendEmptyMessage(HIDE_LOADING);
+        } else
+            goBack = true;
     }
 }



More information about the Android mailing list