[Android] TV : Fix categories icons centering issue
Alexandre Perraud
git at videolan.org
Wed Nov 8 12:05:40 CET 2017
vlc-android | branch: 2.5.x | Alexandre Perraud <4leyx4ndre at gmail.com> | Mon Nov 6 10:31:46 2017 +0100| [41dc0645f49aa684eda9495412971cebea97c61d] | committer: Geoffrey Métais
TV : Fix categories icons centering issue
(cherry picked from commit 4266e4bc41a47d5b944051d5db617790ccff6d70)
> https://code.videolan.org/videolan/vlc-android/commit/41dc0645f49aa684eda9495412971cebea97c61d
---
.../src/org/videolan/vlc/gui/tv/CardPresenter.java | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 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 18aaf2405..df532fb1c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/CardPresenter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/CardPresenter.java
@@ -36,6 +36,7 @@ import android.support.v17.leanback.widget.ImageCardView;
import android.support.v17.leanback.widget.Presenter;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
+import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
@@ -76,7 +77,7 @@ public class CardPresenter extends Presenter {
public ViewHolder(View view) {
super(view);
mCardView = (ImageCardView) view;
- mCardView.getMainImageView().setScaleType(ImageView.ScaleType.CENTER_CROP);
+ mCardView.getMainImageView().setScaleType(ImageView.ScaleType.FIT_CENTER);
}
void updateCardViewImage(MediaLibraryItem mediaLibraryItem) {
@@ -89,6 +90,7 @@ public class CardPresenter extends Presenter {
void updateCardViewImage(Drawable image) {
mCardView.setMainImage(image);
+ mCardView.getMainImageView().setScaleType(ImageView.ScaleType.FIT_CENTER);
}
}
@@ -286,10 +288,17 @@ public class CardPresenter extends Presenter {
@Override
public void run() {
ImageCardView cardView = (ImageCardView) target;
- if (picture != null && picture.getByteCount() > 4)
+ if (picture != null && picture.getByteCount() > 4) {
+ if (mediaLibraryItem.getArtworkMrl() !=null && !mediaLibraryItem.getArtworkMrl().isEmpty())
+ cardView.getMainImageView().setScaleType(ImageView.ScaleType.CENTER_CROP);
+ else
+ cardView.getMainImageView().setScaleType(ImageView.ScaleType.FIT_CENTER);
cardView.setMainImage(new BitmapDrawable(res, picture));
- else
+ }
+ else {
cardView.setMainImage(sDefaultCardImage);
+ cardView.getMainImageView().setScaleType(ImageView.ScaleType.FIT_CENTER);
+ }
}
}
);
More information about the Android
mailing list