[Android] No need to pass context

Geoffrey Métais git at videolan.org
Thu Apr 21 16:36:39 CEST 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Apr 21 16:36:10 2016 +0200| [54244048d05729c9751e4bd0fcaa0a4c4c7cb8c2] | committer: Geoffrey Métais

No need to pass context

> https://code.videolan.org/videolan/vlc-android/commit/54244048d05729c9751e4bd0fcaa0a4c4c7cb8c2
---

 vlc-android/src/org/videolan/vlc/gui/tv/CardPresenter.java | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/CardPresenter.java b/vlc-android/src/org/videolan/vlc/gui/tv/CardPresenter.java
index 494aaec..e64cd44 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/CardPresenter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/CardPresenter.java
@@ -39,6 +39,7 @@ import android.view.ViewGroup;
 import android.widget.ImageView;
 
 import org.videolan.vlc.R;
+import org.videolan.vlc.VLCApplication;
 import org.videolan.vlc.gui.helpers.AsyncImageLoader;
 import org.videolan.vlc.gui.helpers.AudioUtil;
 import org.videolan.vlc.gui.helpers.BitmapUtil;
@@ -85,7 +86,7 @@ public class CardPresenter extends Presenter {
             if (!TextUtils.isEmpty(mediaWrapper.getArtworkURL()) && mediaWrapper.getArtworkURL().startsWith("http")) {
                 AsyncImageLoader.LoadImage(new HttpImageLoader(mediaWrapper.getArtworkURL()), mCardView);
             } else {
-                AsyncImageLoader.LoadImage(new CoverFetcher(mContext, mediaWrapper), mCardView);
+                AsyncImageLoader.LoadImage(new CoverFetcher(mediaWrapper), mCardView);
             }
         }
 
@@ -222,20 +223,18 @@ public class CardPresenter extends Presenter {
 
     public static class CoverFetcher implements AsyncImageLoader.Callbacks{
         MediaWrapper mediaWrapper;
-        private static Activity context;
         private static Resources res;
 
-        CoverFetcher(Activity context, MediaWrapper mediaWrapper){
+        CoverFetcher(MediaWrapper mediaWrapper){
             this.mediaWrapper = mediaWrapper;
-            this.context = context;
-            res = context.getResources();
+            res = VLCApplication.getAppResources();
         }
 
         @Override
         public Bitmap getImage() {
-            Bitmap picture = null;
+            Bitmap picture;
             if (mediaWrapper.getType() == mediaWrapper.TYPE_AUDIO) {
-                picture = AudioUtil.getCover(context, mediaWrapper, 320);
+                picture = AudioUtil.getCover(VLCApplication.getAppContext(), mediaWrapper, 320);
                 if (picture == null)
                     picture = BitmapFactory.decodeResource(res, R.drawable.ic_browser_audio_big_normal);
             } else if (mediaWrapper.getType() == mediaWrapper.TYPE_VIDEO) {



More information about the Android mailing list