[Android] Fix blank covers on TV
Nicolas Pomepuy
git at videolan.org
Wed Aug 7 13:40:25 CEST 2019
vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Wed Aug 7 12:08:11 2019 +0200| [fab123e26c080002b4dfe41bc74e6f535593fda0] | committer: Nicolas Pomepuy
Fix blank covers on TV
> https://code.videolan.org/videolan/vlc-android/commit/fab123e26c080002b4dfe41bc74e6f535593fda0
---
vlc-android/src/org/videolan/vlc/gui/tv/FileTvItemAdapter.kt | 5 +++++
vlc-android/src/org/videolan/vlc/gui/tv/MediaTvItemAdapter.kt | 5 +++++
vlc-android/src/org/videolan/vlc/gui/view/FadableImageView.kt | 11 ++++++++---
3 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/FileTvItemAdapter.kt b/vlc-android/src/org/videolan/vlc/gui/tv/FileTvItemAdapter.kt
index 34b469ed4..533cd6b12 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/FileTvItemAdapter.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/FileTvItemAdapter.kt
@@ -66,6 +66,11 @@ class FileTvItemAdapter(type: Int, private val eventsHandler: IEventsHandler, va
}
}
+ override fun onViewRecycled(holder: MediaTvItemAdapter.AbstractMediaItemViewHolder<MediaBrowserTvItemBinding>) {
+ super.onViewRecycled(holder)
+ holder.recycle()
+ }
+
override fun hasSections() = true
override fun setOnFocusChangeListener(focusListener: FocusableRecyclerView.FocusListener?) {
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/MediaTvItemAdapter.kt b/vlc-android/src/org/videolan/vlc/gui/tv/MediaTvItemAdapter.kt
index e674b84db..f6303ff97 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/MediaTvItemAdapter.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/MediaTvItemAdapter.kt
@@ -75,6 +75,11 @@ class MediaTvItemAdapter(type: Int, private val eventsHandler: IEventsHandler, v
}
}
+ override fun onViewRecycled(holder: AbstractMediaItemViewHolder<ViewDataBinding>) {
+ super.onViewRecycled(holder)
+ holder.recycle()
+ }
+
override fun hasSections() = true
override fun submitList(pagedList: Any?) {
diff --git a/vlc-android/src/org/videolan/vlc/gui/view/FadableImageView.kt b/vlc-android/src/org/videolan/vlc/gui/view/FadableImageView.kt
index bbc70e08f..33170be6b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/view/FadableImageView.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/view/FadableImageView.kt
@@ -2,13 +2,17 @@ package org.videolan.vlc.gui.view
import android.content.Context
import android.graphics.Bitmap
+import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable
import android.graphics.drawable.Icon
import android.net.Uri
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatImageView
+import java.util.concurrent.atomic.AtomicBoolean
class FadableImageView : AppCompatImageView {
+ private var animationRunning = AtomicBoolean(false)
+
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
@@ -16,9 +20,10 @@ class FadableImageView : AppCompatImageView {
constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle)
private fun fade() {
+ if (animationRunning.get()) return
alpha = 0f
- animate().cancel()
- animate().alpha(1f)
+ animationRunning.set(true)
+ animate().withEndAction { animationRunning.set(false) }.alpha(1f)
}
fun resetFade() {
@@ -30,7 +35,7 @@ class FadableImageView : AppCompatImageView {
override fun setBackground(background: Drawable?) {
super.setBackground(background)
- if (background != null) fade() else resetFade()
+ if (background == null || background is ColorDrawable) resetFade() else fade()
}
override fun setBackgroundResource(resid: Int) {
More information about the Android
mailing list