[Android] Fixed folder icon and card size for TV browser

Nicolas Pomepuy git at videolan.org
Thu May 14 15:04:08 CEST 2020


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed May 13 09:59:40 2020 +0200| [1f4b3040bb685e89b26823e2e94e290a657eda29] | committer: Nicolas Pomepuy

Fixed folder icon and card size for TV browser

> https://code.videolan.org/videolan/vlc-android/commit/1f4b3040bb685e89b26823e2e94e290a657eda29
---

 .../videolan/television/ui/FileTvItemAdapter.kt    |  5 ++--
 .../org/videolan/vlc/gui/helpers/ImageLoader.kt    |  1 +
 .../src/org/videolan/vlc/gui/helpers/UiTools.kt    | 28 +++++++++++++++-------
 3 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/application/television/src/main/java/org/videolan/television/ui/FileTvItemAdapter.kt b/application/television/src/main/java/org/videolan/television/ui/FileTvItemAdapter.kt
index eadd39ce7..9d991433b 100644
--- a/application/television/src/main/java/org/videolan/television/ui/FileTvItemAdapter.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/FileTvItemAdapter.kt
@@ -26,6 +26,7 @@ import org.videolan.television.ui.browser.TvAdapterUtils
 import org.videolan.vlc.gui.DiffUtilAdapter
 import org.videolan.vlc.gui.helpers.getBitmapFromDrawable
 import org.videolan.vlc.gui.helpers.getMediaIconDrawable
+import org.videolan.vlc.gui.helpers.getTvIconRes
 import org.videolan.vlc.gui.view.FastScroller
 import org.videolan.vlc.interfaces.IEventsHandler
 import org.videolan.vlc.util.generateResolutionClass
@@ -160,7 +161,6 @@ class FileTvItemAdapter(private val eventsHandler: IEventsHandler<MediaLibraryIt
 
         override fun setItem(item: MediaLibraryItem?) {
             binding.item = item
-            var isSquare = true
             var progress = 0
             var seen = 0L
             var description = item?.description
@@ -168,7 +168,6 @@ class FileTvItemAdapter(private val eventsHandler: IEventsHandler<MediaLibraryIt
             if (item is MediaWrapper) {
                 if (item.type == MediaWrapper.TYPE_VIDEO) {
                     resolution = generateResolutionClass(item.width, item.height) ?: ""
-                    isSquare = false
                     description = if (item.time == 0L) Tools.millisToString(item.length) else Tools.getProgressText(item)
                     binding.badge = resolution
                     seen = item.seen
@@ -186,7 +185,7 @@ class FileTvItemAdapter(private val eventsHandler: IEventsHandler<MediaLibraryIt
             }
 
             binding.progress = progress
-            binding.isSquare = isSquare
+            binding.isSquare = true
             binding.seen = seen
             binding.description = description
             if (showProtocol && item is MediaWrapper) binding.protocol = getProtocol(item)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt b/application/vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt
index f388808d0..a58a18e90 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt
@@ -106,6 +106,7 @@ fun getMediaIconDrawable(context: Context?, type: Int, big: Boolean = false): Bi
         MediaWrapper.TYPE_ARTIST -> if (big) UiTools.getDefaultArtistDrawableBig(it) else UiTools.getDefaultArtistDrawable(it)
         MediaWrapper.TYPE_AUDIO -> if (big) UiTools.getDefaultAudioDrawableBig(it) else UiTools.getDefaultAudioDrawable(it)
         MediaWrapper.TYPE_VIDEO -> if (big) UiTools.getDefaultVideoDrawableBig(it) else UiTools.getDefaultAudioDrawable(it)
+        MediaWrapper.TYPE_DIR -> if (big) UiTools.getDefaultFolderDrawableBig(it) else UiTools.getDefaultFolderDrawable(it)
         else -> null
     }
 }
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt b/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt
index 8301e428f..71db8c163 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt
@@ -93,6 +93,7 @@ object UiTools {
     private var DEFAULT_COVER_ARTIST_DRAWABLE: BitmapDrawable? = null
     private var DEFAULT_COVER_MOVIE_DRAWABLE: BitmapDrawable? = null
     private var DEFAULT_COVER_TVSHOW_DRAWABLE: BitmapDrawable? = null
+    private var DEFAULT_COVER_FOLDER_DRAWABLE: BitmapDrawable? = null
 
     private var DEFAULT_COVER_VIDEO_DRAWABLE_BIG: BitmapDrawable? = null
     private var DEFAULT_COVER_AUDIO_DRAWABLE_BIG: BitmapDrawable? = null
@@ -100,26 +101,32 @@ object UiTools {
     private var DEFAULT_COVER_ARTIST_DRAWABLE_BIG: BitmapDrawable? = null
     private var DEFAULT_COVER_MOVIE_DRAWABLE_BIG: BitmapDrawable? = null
     private var DEFAULT_COVER_TVSHOW_DRAWABLE_BIG: BitmapDrawable? = null
+    private var DEFAULT_COVER_FOLDER_DRAWABLE_BIG: BitmapDrawable? = null
 
     private val sHandler = Handler(Looper.getMainLooper())
     const val DELETE_DURATION = 3000
 
     fun getDefaultVideoDrawable(context: Context): BitmapDrawable {
         if (DEFAULT_COVER_VIDEO_DRAWABLE == null) {
-            val DEFAULT_COVER_VIDEO = getBitmapFromDrawable(context, R.drawable.ic_no_thumbnail_1610)
-            DEFAULT_COVER_VIDEO_DRAWABLE = BitmapDrawable(context.resources, DEFAULT_COVER_VIDEO)
+            DEFAULT_COVER_VIDEO_DRAWABLE = BitmapDrawable(context.resources, getBitmapFromDrawable(context, R.drawable.ic_no_thumbnail_1610))
         }
         return DEFAULT_COVER_VIDEO_DRAWABLE!!
     }
 
     fun getDefaultAudioDrawable(context: Context): BitmapDrawable {
         if (DEFAULT_COVER_AUDIO_DRAWABLE == null) {
-            val DEFAULT_COVER_AUDIO = getBitmapFromDrawable(context, R.drawable.ic_no_song)
-            DEFAULT_COVER_AUDIO_DRAWABLE = BitmapDrawable(context.resources, DEFAULT_COVER_AUDIO)
+            DEFAULT_COVER_AUDIO_DRAWABLE = BitmapDrawable(context.resources, getBitmapFromDrawable(context, R.drawable.ic_no_song))
         }
         return DEFAULT_COVER_AUDIO_DRAWABLE!!
     }
 
+    fun getDefaultFolderDrawable(context: Context): BitmapDrawable {
+        if (DEFAULT_COVER_FOLDER_DRAWABLE == null) {
+            DEFAULT_COVER_FOLDER_DRAWABLE = BitmapDrawable(context.resources, getBitmapFromDrawable(context, R.drawable.ic_menu_folder))
+        }
+        return DEFAULT_COVER_FOLDER_DRAWABLE!!
+    }
+
     fun getDefaultAlbumDrawable(context: Context): BitmapDrawable {
         if (DEFAULT_COVER_ALBUM_DRAWABLE == null) {
             DEFAULT_COVER_ALBUM_DRAWABLE = BitmapDrawable(context.resources, getBitmapFromDrawable(context, R.drawable.ic_no_album))
@@ -150,16 +157,14 @@ object UiTools {
 
     fun getDefaultVideoDrawableBig(context: Context): BitmapDrawable {
         if (DEFAULT_COVER_VIDEO_DRAWABLE_BIG == null) {
-            val DEFAULT_COVER_VIDEO = getBitmapFromDrawable(context, R.drawable.ic_browser_video_big_normal)
-            DEFAULT_COVER_VIDEO_DRAWABLE_BIG = BitmapDrawable(context.resources, DEFAULT_COVER_VIDEO)
+            DEFAULT_COVER_VIDEO_DRAWABLE_BIG = BitmapDrawable(context.resources, getBitmapFromDrawable(context, R.drawable.ic_browser_video_big_normal))
         }
         return DEFAULT_COVER_VIDEO_DRAWABLE_BIG!!
     }
 
     fun getDefaultAudioDrawableBig(context: Context): BitmapDrawable {
         if (DEFAULT_COVER_AUDIO_DRAWABLE_BIG == null) {
-            val DEFAULT_COVER_AUDIO = getBitmapFromDrawable(context, R.drawable.ic_song_big)
-            DEFAULT_COVER_AUDIO_DRAWABLE_BIG = BitmapDrawable(context.resources, DEFAULT_COVER_AUDIO)
+            DEFAULT_COVER_AUDIO_DRAWABLE_BIG = BitmapDrawable(context.resources, getBitmapFromDrawable(context, R.drawable.ic_song_big))
         }
         return DEFAULT_COVER_AUDIO_DRAWABLE_BIG!!
     }
@@ -192,6 +197,13 @@ object UiTools {
         return DEFAULT_COVER_TVSHOW_DRAWABLE_BIG!!
     }
 
+    fun getDefaultFolderDrawableBig(context: Context): BitmapDrawable {
+        if (DEFAULT_COVER_FOLDER_DRAWABLE_BIG == null) {
+            DEFAULT_COVER_FOLDER_DRAWABLE_BIG = BitmapDrawable(context.resources, getBitmapFromDrawable(context, R.drawable.ic_menu_folder_big))
+        }
+        return DEFAULT_COVER_FOLDER_DRAWABLE_BIG!!
+    }
+
     /**
      * Print an on-screen message to alert the user
      */



More information about the Android mailing list