[Android] Set a cache for placeholder BitmapDrawable

Geoffrey Métais git at videolan.org
Tue Feb 26 09:56:10 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Feb 25 16:24:52 2019 +0100| [307a4c4382d44a12859f60c0bf2112d075b7342e] | committer: Geoffrey Métais

Set a cache for placeholder BitmapDrawable

> https://code.videolan.org/videolan/vlc-android/commit/307a4c4382d44a12859f60c0bf2112d075b7342e
---

 vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt b/vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt
index dc9e6accd..65ba61329 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt
@@ -2,6 +2,7 @@ package org.videolan.vlc.gui.helpers
 
 import android.graphics.Bitmap
 import android.graphics.drawable.BitmapDrawable
+import android.graphics.drawable.Drawable
 import android.net.Uri
 import android.view.View
 import android.widget.ImageView
@@ -76,11 +77,13 @@ fun getIconDrawable(type: Int): BitmapDrawable? {
     }
 }
 
+private var placeholderTvBg : Drawable? = null
 @MainThread
 @BindingAdapter("placeholder")
 fun placeHolderView(v: View, item: MediaLibraryItem?) {
     if (item == null) {
-        v.background = ContextCompat.getDrawable(v.context, R.drawable.rounded_corners_grey)
+        if (placeholderTvBg === null) placeholderTvBg = ContextCompat.getDrawable(v.context, R.drawable.rounded_corners_grey)
+        v.background = placeholderTvBg
     } else {
         v.background = null
     }



More information about the Android mailing list