[Android] Use the right drawable + allow using vector drawable on TV

Nicolas Pomepuy git at videolan.org
Fri Jul 5 12:24:23 CEST 2019


vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Fri Jul  5 12:18:55 2019 +0200| [66b0d8596b2f0fe38126cf0a8bc66ed9e56eb247] | committer: Nicolas Pomepuy

Use the right drawable + allow using vector drawable on TV

> https://code.videolan.org/videolan/vlc-android/commit/66b0d8596b2f0fe38126cf0a8bc66ed9e56eb247
---

 vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt  | 16 ++++++++--------
 vlc-android/src/org/videolan/vlc/gui/tv/CardPresenter.kt |  6 +++---
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt b/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt
index 2966c2bee..45d04de4f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt
@@ -104,7 +104,7 @@ object UiTools {
 
     fun getDefaultVideoDrawable(context: Context): BitmapDrawable {
         if (DEFAULT_COVER_VIDEO_DRAWABLE == null) {
-            val DEFAULT_COVER_VIDEO = BitmapCache.getFromResource(context.resources, R.drawable.ic_no_thumbnail_1610)
+            val DEFAULT_COVER_VIDEO = getBitmapFromDrawable(context, R.drawable.ic_no_thumbnail_1610)
             DEFAULT_COVER_VIDEO_DRAWABLE = BitmapDrawable(context.resources, DEFAULT_COVER_VIDEO)
         }
         return DEFAULT_COVER_VIDEO_DRAWABLE!!
@@ -112,7 +112,7 @@ object UiTools {
 
     fun getDefaultAudioDrawable(context: Context): BitmapDrawable {
         if (DEFAULT_COVER_AUDIO_DRAWABLE == null) {
-            val DEFAULT_COVER_AUDIO = BitmapCache.getFromResource(context.resources, R.drawable.ic_no_song)
+            val DEFAULT_COVER_AUDIO = getBitmapFromDrawable(context, R.drawable.ic_no_song)
             DEFAULT_COVER_AUDIO_DRAWABLE = BitmapDrawable(context.resources, DEFAULT_COVER_AUDIO)
         }
         return DEFAULT_COVER_AUDIO_DRAWABLE!!
@@ -120,21 +120,21 @@ object UiTools {
 
     fun getDefaultAlbumDrawable(context: Context): BitmapDrawable {
         if (DEFAULT_COVER_ALBUM_DRAWABLE == null) {
-            DEFAULT_COVER_ALBUM_DRAWABLE = BitmapDrawable(context.resources, BitmapCache.getFromResource(context.resources, R.drawable.ic_no_album))
+            DEFAULT_COVER_ALBUM_DRAWABLE = BitmapDrawable(context.resources, getBitmapFromDrawable(context, R.drawable.ic_no_album))
         }
         return DEFAULT_COVER_ALBUM_DRAWABLE!!
     }
 
     fun getDefaultArtistDrawable(context: Context): BitmapDrawable {
         if (DEFAULT_COVER_ARTIST_DRAWABLE == null) {
-            DEFAULT_COVER_ARTIST_DRAWABLE = BitmapDrawable(context.resources, BitmapCache.getFromResource(context.resources, R.drawable.ic_no_artist))
+            DEFAULT_COVER_ARTIST_DRAWABLE = BitmapDrawable(context.resources, getBitmapFromDrawable(context, R.drawable.ic_no_artist))
         }
         return DEFAULT_COVER_ARTIST_DRAWABLE!!
     }
 
     fun getDefaultVideoDrawableBig(context: Context): BitmapDrawable {
         if (DEFAULT_COVER_VIDEO_DRAWABLE_BIG == null) {
-            val DEFAULT_COVER_VIDEO = BitmapCache.getFromResource(context.resources, R.drawable.ic_no_thumbnail_1610)
+            val DEFAULT_COVER_VIDEO = getBitmapFromDrawable(context, R.drawable.ic_no_thumbnail_1610)
             DEFAULT_COVER_VIDEO_DRAWABLE_BIG = BitmapDrawable(context.resources, DEFAULT_COVER_VIDEO)
         }
         return DEFAULT_COVER_VIDEO_DRAWABLE_BIG!!
@@ -142,7 +142,7 @@ object UiTools {
 
     fun getDefaultAudioDrawableBig(context: Context): BitmapDrawable {
         if (DEFAULT_COVER_AUDIO_DRAWABLE_BIG == null) {
-            val DEFAULT_COVER_AUDIO = BitmapCache.getFromResource(context.resources, R.drawable.ic_no_song)
+            val DEFAULT_COVER_AUDIO = getBitmapFromDrawable(context, R.drawable.ic_song_big)
             DEFAULT_COVER_AUDIO_DRAWABLE_BIG = BitmapDrawable(context.resources, DEFAULT_COVER_AUDIO)
         }
         return DEFAULT_COVER_AUDIO_DRAWABLE_BIG!!
@@ -150,14 +150,14 @@ object UiTools {
 
     fun getDefaultAlbumDrawableBig(context: Context): BitmapDrawable {
         if (DEFAULT_COVER_ALBUM_DRAWABLE_BIG == null) {
-            DEFAULT_COVER_ALBUM_DRAWABLE_BIG = BitmapDrawable(context.resources, BitmapCache.getFromResource(context.resources, R.drawable.ic_album_big))
+            DEFAULT_COVER_ALBUM_DRAWABLE_BIG = BitmapDrawable(context.resources, getBitmapFromDrawable(context, R.drawable.ic_album_big))
         }
         return DEFAULT_COVER_ALBUM_DRAWABLE_BIG!!
     }
 
     fun getDefaultArtistDrawableBig(context: Context): BitmapDrawable {
         if (DEFAULT_COVER_ARTIST_DRAWABLE_BIG == null) {
-            DEFAULT_COVER_ARTIST_DRAWABLE_BIG = BitmapDrawable(context.resources, BitmapCache.getFromResource(context.resources, R.drawable.ic_artist_big))
+            DEFAULT_COVER_ARTIST_DRAWABLE_BIG = BitmapDrawable(context.resources, getBitmapFromDrawable(context, R.drawable.ic_artist_big))
         }
         return DEFAULT_COVER_ARTIST_DRAWABLE_BIG!!
     }
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/CardPresenter.kt b/vlc-android/src/org/videolan/vlc/gui/tv/CardPresenter.kt
index dcb446c1a..fd1eba8cf 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/CardPresenter.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/CardPresenter.kt
@@ -40,8 +40,8 @@ import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
 import kotlinx.coroutines.ExperimentalCoroutinesApi
 import kotlinx.coroutines.ObsoleteCoroutinesApi
 import org.videolan.medialibrary.Tools
-import org.videolan.medialibrary.media.DummyItem
 import org.videolan.medialibrary.interfaces.media.AbstractMediaWrapper
+import org.videolan.medialibrary.media.DummyItem
 import org.videolan.medialibrary.media.MediaLibraryItem
 import org.videolan.vlc.R
 import org.videolan.vlc.VLCApplication
@@ -81,7 +81,7 @@ class CardPresenter(private val context: Activity) : Presenter() {
                 val video = item.type == AbstractMediaWrapper.TYPE_VIDEO
                 if (!folder && (group || video && !item.isThumbnailGenerated)) {
                     if (noArt) {
-                        cardView.mainImageView.scaleType = ImageView.ScaleType.FIT_CENTER
+                        cardView.mainImageView.scaleType = ImageView.ScaleType.CENTER_INSIDE
                         cardView.mainImage = BitmapDrawable(cardView.resources, getDefaultImage(item))
                     }
                     loadImage(cardView, item)
@@ -94,7 +94,7 @@ class CardPresenter(private val context: Activity) : Presenter() {
                     loadPlaylistImageWithWidth(cardView.mainImageView, item, imageDefaultWidth.toInt())
                 }
                 noArt -> {
-                    cardView.mainImageView.scaleType = ImageView.ScaleType.FIT_CENTER
+                    cardView.mainImageView.scaleType = ImageView.ScaleType.CENTER_INSIDE
                     cardView.mainImage = BitmapDrawable(cardView.resources, getDefaultImage(item))
                 }
                 else -> loadImage(cardView, item)



More information about the Android mailing list