[Android] TV: Use handler for main thread operations

Geoffrey Métais git at videolan.org
Thu Mar 3 19:16:43 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Mar  3 19:14:54 2016 +0100| [14cc3644a73b60ee687f62fc98d2df86dc403cb5] | committer: Geoffrey Métais

TV: Use handler for main thread operations

> https://code.videolan.org/videolan/vlc-android/commit/14cc3644a73b60ee687f62fc98d2df86dc403cb5
---

 vlc-android/src/org/videolan/vlc/gui/tv/CardPresenter.java | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

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 abf35be..45f8c56 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/CardPresenter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/CardPresenter.java
@@ -29,6 +29,8 @@ import android.graphics.drawable.BitmapDrawable;
 import android.graphics.drawable.Drawable;
 import android.net.Uri;
 import android.os.Build;
+import android.os.Handler;
+import android.os.Looper;
 import android.support.v17.leanback.widget.ImageCardView;
 import android.support.v17.leanback.widget.Presenter;
 import android.text.TextUtils;
@@ -56,6 +58,7 @@ public class CardPresenter extends Presenter {
     private static int CARD_HEIGHT = 0;
     private static MediaDatabase sMediaDatabase = MediaDatabase.getInstance();
     private static Drawable sDefaultCardImage;
+    private static Handler sHandler = new Handler(Looper.getMainLooper());
 
     public CardPresenter(Activity context){
         mContext = context;
@@ -237,7 +240,7 @@ public class CardPresenter extends Presenter {
         public void updateImage(final Bitmap picture, final View target) {
             if (!TextUtils.isEmpty(mediaWrapper.getArtworkURL()) && mediaWrapper.getArtworkURL().startsWith("http"))
                 AsyncImageLoader.LoadImage(new HttpImageLoader(mediaWrapper.getArtworkURL()), target);
-            context.runOnUiThread(
+            sHandler.post(
                     new Runnable() {
                         @Override
                         public void run() {



More information about the Android mailing list