[Android] MediaLibrary: remove passing of Context when not needed

Jean-Baptiste Kempf git at videolan.org
Sun Jul 6 08:24:11 CEST 2014


vlc-ports/android | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Sun Jul  6 07:32:26 2014 +0200| [9f804c8eb0ca243ca117c38ec5252054e17ad966] | committer: Jean-Baptiste Kempf

MediaLibrary: remove passing of Context when not needed

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

 vlc-android/src/org/videolan/vlc/MediaLibrary.java |   11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/MediaLibrary.java b/vlc-android/src/org/videolan/vlc/MediaLibrary.java
index cbfe115..a59d156 100644
--- a/vlc-android/src/org/videolan/vlc/MediaLibrary.java
+++ b/vlc-android/src/org/videolan/vlc/MediaLibrary.java
@@ -60,7 +60,7 @@ public class MediaLibrary {
     private Context mRestartContext;
     protected Thread mLoadingThread;
 
-    private MediaLibrary(Context context) {
+    private MediaLibrary() {
         mInstance = this;
         mItemList = new ArrayList<Media>();
         mUpdateHandler = new ArrayList<Handler>();
@@ -82,7 +82,7 @@ public class MediaLibrary {
         if (mLoadingThread == null || mLoadingThread.getState() == State.TERMINATED) {
             isStopping = false;
             VideoGridFragment.actionScanStart();
-            mLoadingThread = new Thread(new GetMediaItemsRunnable(context.getApplicationContext()));
+            mLoadingThread = new Thread(new GetMediaItemsRunnable());
             mLoadingThread.start();
         }
     }
@@ -102,7 +102,7 @@ public class MediaLibrary {
 
     public static MediaLibrary getInstance(Context context) {
         if (mInstance == null)
-            mInstance = new MediaLibrary(context);
+            mInstance = new MediaLibrary();
         return mInstance;
     }
 
@@ -200,10 +200,8 @@ public class MediaLibrary {
 
         private final Stack<File> directories = new Stack<File>();
         private final HashSet<String> directoriesScanned = new HashSet<String>();
-        private Context mContext;
 
-        public GetMediaItemsRunnable(Context context) {
-            mContext = context;
+        public GetMediaItemsRunnable() {
         }
 
         @Override
@@ -364,7 +362,6 @@ public class MediaLibrary {
                     restartHandler.sendEmptyMessageDelayed(1, 200);
                 } else {
                     mRestartContext = null;
-                    mContext = null;
                 }
             }
         }



More information about the Android mailing list