[Android] Adapters: clear marquee task on recycle

Geoffrey Métais git at videolan.org
Fri Feb 14 14:03:15 CET 2020


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Feb 13 17:49:19 2020 +0100| [88ac9f7dff852485006b761a7abd594b276b0608] | committer: Geoffrey Métais

Adapters: clear marquee task on recycle

> https://code.videolan.org/videolan/vlc-android/commit/88ac9f7dff852485006b761a7abd594b276b0608
---

 .../src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.kt     | 11 +++++------
 .../src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.kt    |  9 +++++----
 .../src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.kt |  5 ++---
 3 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.kt b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.kt
index 28a25c61c..9b4be94bb 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.kt
@@ -123,7 +123,7 @@ class AudioBrowserAdapter @JvmOverloads constructor(
     }
 
     override fun onDetachedFromRecyclerView(recyclerView: RecyclerView) {
-        handler.removeCallbacksAndMessages(null)
+        if (Settings.listTitleEllipsize == 4) handler.removeCallbacksAndMessages(null)
         super.onDetachedFromRecyclerView(recyclerView)
     }
 
@@ -162,6 +162,7 @@ class AudioBrowserAdapter @JvmOverloads constructor(
     }
 
     override fun onViewRecycled(h: AbstractMediaItemViewHolder<ViewDataBinding>) {
+        if (Settings.listTitleEllipsize == 4) handler.removeCallbacksAndMessages(null)
         h.recycle()
         super.onViewRecycled(h)
     }
@@ -309,8 +310,8 @@ class AudioBrowserAdapter @JvmOverloads constructor(
         }
     }
 
-    abstract inner class AbstractMediaItemViewHolder<T : ViewDataBinding> @TargetApi(Build.VERSION_CODES.M)
-    internal constructor(binding: T) : SelectorViewHolder<T>(binding), MarqueeViewHolder {
+    @TargetApi(Build.VERSION_CODES.M)
+    abstract inner class AbstractMediaItemViewHolder<T : ViewDataBinding>(binding: T) : SelectorViewHolder<T>(binding), MarqueeViewHolder {
 
         val canBeReordered: Boolean
             get() = reorder
@@ -336,9 +337,7 @@ class AudioBrowserAdapter @JvmOverloads constructor(
         }
 
 
-        override fun isSelected(): Boolean {
-            return multiSelectHelper.isSelected(layoutPosition)
-        }
+        override fun isSelected() = multiSelectHelper.isSelected(layoutPosition)
 
         abstract fun setItem(item: MediaLibraryItem?)
 
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.kt b/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.kt
index 9bb9ec4a0..ec253274f 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.kt
@@ -42,8 +42,11 @@ import org.videolan.medialibrary.media.MediaLibraryItem
 import org.videolan.medialibrary.media.MediaLibraryItem.TYPE_MEDIA
 import org.videolan.medialibrary.media.MediaLibraryItem.TYPE_STORAGE
 import org.videolan.medialibrary.media.Storage
+import org.videolan.resources.AndroidDevices
+import org.videolan.resources.UPDATE_SELECTION
 import org.videolan.tools.MultiSelectAdapter
 import org.videolan.tools.MultiSelectHelper
+import org.videolan.tools.Settings
 import org.videolan.vlc.R
 import org.videolan.vlc.databinding.BrowserItemBinding
 import org.videolan.vlc.databinding.BrowserItemSeparatorBinding
@@ -51,9 +54,6 @@ import org.videolan.vlc.gui.DiffUtilAdapter
 import org.videolan.vlc.gui.helpers.MarqueeViewHolder
 import org.videolan.vlc.gui.helpers.SelectorViewHolder
 import org.videolan.vlc.gui.helpers.enableMarqueeEffect
-import org.videolan.resources.AndroidDevices
-import org.videolan.tools.Settings
-import org.videolan.resources.UPDATE_SELECTION
 import java.util.*
 
 
@@ -114,7 +114,7 @@ open class BaseBrowserAdapter(protected val fragment: BaseBrowserFragment) : Dif
     }
 
     override fun onDetachedFromRecyclerView(recyclerView: RecyclerView) {
-        handler.removeCallbacksAndMessages(null)
+        if (Settings.listTitleEllipsize == 0 || Settings.listTitleEllipsize == 4) handler.removeCallbacksAndMessages(null)
         super.onDetachedFromRecyclerView(recyclerView)
     }
 
@@ -155,6 +155,7 @@ open class BaseBrowserAdapter(protected val fragment: BaseBrowserFragment) : Dif
     }
 
     override fun onViewRecycled(holder: ViewHolder<ViewDataBinding>) {
+        if (Settings.listTitleEllipsize == 0 || Settings.listTitleEllipsize == 4) handler.removeCallbacksAndMessages(null)
         super.onViewRecycled(holder)
         holder.titleView?.isSelected = false
     }
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.kt b/application/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.kt
index 10436f08c..1a8be1f11 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.kt
@@ -33,10 +33,10 @@ import org.videolan.medialibrary.interfaces.Medialibrary
 import org.videolan.medialibrary.interfaces.media.MediaWrapper
 import org.videolan.medialibrary.media.MediaLibraryItem
 import org.videolan.medialibrary.media.Storage
+import org.videolan.tools.containsPath
 import org.videolan.vlc.MediaParsingService
 import org.videolan.vlc.gui.helpers.ThreeStatesCheckbox
 import org.videolan.vlc.repository.DirectoryRepository
-import org.videolan.tools.containsPath
 
 @ObsoleteCoroutinesApi
 @ExperimentalCoroutinesApi
@@ -68,8 +68,7 @@ internal class StorageBrowserAdapter(fragment: StorageBrowserFragment) : BaseBro
                 hasDiscoveredChildren(storagePath) -> vh.binding.browserCheckbox.state = ThreeStatesCheckbox.STATE_PARTIAL
                 else -> vh.binding.browserCheckbox.state = ThreeStatesCheckbox.STATE_UNCHECKED
             }
-            vh.binding.checkEnabled = !(fragment as StorageBrowserFragment).scannedDirectory
-            vh.job = null
+            vh.binding.checkEnabled = !fragment.scannedDirectory
         }
     }
 



More information about the Android mailing list