[Android] Earlier test for image validity

Geoffrey Métais git at videolan.org
Tue Dec 6 14:32:25 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Dec  6 13:36:10 2016 +0100| [0f348431b77d4f95192dacfd402f5ae2d2138052] | committer: Geoffrey Métais

Earlier test for image validity

> https://code.videolan.org/videolan/vlc-android/commit/0f348431b77d4f95192dacfd402f5ae2d2138052
---

 .../videolan/vlc/gui/helpers/AsyncImageLoader.java | 23 +++++++++-------------
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/AsyncImageLoader.java b/vlc-android/src/org/videolan/vlc/gui/helpers/AsyncImageLoader.java
index 2fa3e7d..9aa80be 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/AsyncImageLoader.java
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/AsyncImageLoader.java
@@ -144,29 +144,24 @@ public class AsyncImageLoader {
     }
 
     private static void updateTargetImage(final Bitmap bitmap, final View target, final ViewDataBinding vdb) {
+        if (bitmap == null || bitmap.getWidth() <= 1 || bitmap.getHeight() <= 1)
+            return;
         if (vdb != null) {
-            if (bitmap != null && bitmap.getWidth() != 1 && bitmap.getHeight() != 1) {
-                vdb.setVariable(BR.scaleType, ImageView.ScaleType.FIT_CENTER);
-                vdb.setVariable(BR.cover, new BitmapDrawable(VLCApplication.getAppResources(), bitmap));
-                vdb.setVariable(BR.protocol, null);
-            }
+            vdb.setVariable(BR.scaleType, ImageView.ScaleType.FIT_CENTER);
+            vdb.setVariable(BR.cover, new BitmapDrawable(VLCApplication.getAppResources(), bitmap));
+            vdb.setVariable(BR.protocol, null);
         } else {
-            final boolean isBitmapValid = bitmap != null && bitmap.getWidth() != 1 && bitmap.getHeight() != 1;
             sHandler.post(new Runnable() {
                 @Override
                 public void run() {
                     if (target instanceof ImageView) {
                         ImageView iv = (ImageView) target;
                         iv.setVisibility(View.VISIBLE);
-                        if (isBitmapValid) {
-                            iv.setScaleType(ImageView.ScaleType.FIT_CENTER);
-                            iv.setImageBitmap(bitmap);
-                        }
+                        iv.setScaleType(ImageView.ScaleType.FIT_CENTER);
+                        iv.setImageBitmap(bitmap);
                     } else if (target instanceof TextView) {
-                        if (isBitmapValid) {
-                            target.setBackgroundDrawable(new BitmapDrawable(VLCApplication.getAppResources(), bitmap));
-                            ((TextView) target).setText(null);
-                        }
+                        target.setBackgroundDrawable(new BitmapDrawable(VLCApplication.getAppResources(), bitmap));
+                        ((TextView) target).setText(null);
                     }
                 }
             });



More information about the Android mailing list