[Android] Don't release MediaBrowser too soon

Geoffrey Métais git at videolan.org
Mon Jun 1 11:29:10 CEST 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Sat May 30 16:17:41 2015 +0200| [f68a57791287c8b4caf5842e4b4506bf3d93dbbf] | committer: Geoffrey Métais

Don't release MediaBrowser too soon

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=f68a57791287c8b4caf5842e4b4506bf3d93dbbf
---

 .../videolan/vlc/gui/browser/BaseBrowserFragment.java   |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

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 fc29694..36f4470 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
@@ -90,7 +90,6 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
     protected MediaWrapper mCurrentMedia;
     protected int mSavedPosition = -1, mFavorites = 0;
     public boolean mRoot;
-    protected LibVLC mLibVLC;
 
     private SparseArray<ArrayList<MediaWrapper>> mMediaLists = new SparseArray<ArrayList<MediaWrapper>>();
     private ArrayList<MediaWrapper> mediaList;
@@ -107,8 +106,6 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
 
     public void onCreate(Bundle bundle){
         super.onCreate(bundle);
-        mLibVLC = VLCInstance.get();
-        mMediaBrowser = new MediaBrowser(mLibVLC, this);
 
         if (bundle == null)
             bundle = getArguments();
@@ -142,10 +139,15 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
         return v;
     }
 
+    @Override
+    public void onStart() {
+        super.onStart();
+        mMediaBrowser = new MediaBrowser(VLCInstance.get(), this);
+    }
+
     public void onStop(){
         super.onStop();
-        if (mMediaBrowser != null)
-            mMediaBrowser.release();
+        mMediaBrowser.release();
     }
 
     public void onSaveInstanceState(Bundle outState){
@@ -216,7 +218,6 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
 
     @Override
     public void onBrowseEnd() {
-        mMediaBrowser.release();
         mHandler.sendEmptyMessage(BrowserFragmentHandler.MSG_HIDE_LOADING);
         if (mReadyToDisplay)
             display();
@@ -515,7 +516,6 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
         public void onBrowseEnd() {
             if (mAdapter.isEmpty()) {
                 mCurrentParsedPosition = -1;
-                mMediaBrowser.release();
                 return;
             }
             String holderText = getDescription(directories.size(), files.size());
@@ -543,7 +543,6 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
                     mMediaBrowser.browse(mw.getUri());
                 } else {
                     mCurrentParsedPosition = -1;
-                    mMediaBrowser.release();
                 }
             }
             directories .clear();



More information about the Android mailing list