[Android] Check if activity scope is active in FastScroller

Geoffrey Métais git at videolan.org
Tue Feb 11 16:00:55 CET 2020


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Feb 11 11:48:55 2020 +0100| [4a8654155166352caa2565b88f4a74032495e36c] | committer: Geoffrey Métais

Check if activity scope is active in FastScroller

> https://code.videolan.org/videolan/vlc-android/commit/4a8654155166352caa2565b88f4a74032495e36c
---

 .../vlc-android/src/org/videolan/vlc/gui/view/FastScroller.kt        | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/view/FastScroller.kt b/application/vlc-android/src/org/videolan/vlc/gui/view/FastScroller.kt
index c7065750f..3d5e7fc0a 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/view/FastScroller.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/view/FastScroller.kt
@@ -52,6 +52,7 @@ import org.videolan.vlc.R
 import org.videolan.resources.util.HeadersIndex
 import org.videolan.vlc.providers.medialibrary.MedialibraryProvider
 import org.videolan.tools.WeakHandler
+import org.videolan.tools.safeOffer
 import org.videolan.vlc.util.scope
 import java.util.concurrent.atomic.AtomicBoolean
 import kotlin.math.max
@@ -373,10 +374,10 @@ class FastScroller : LinearLayout, Observer<HeadersIndex> {
         val proportion = if (recyclerviewTotalHeight == 0) 0f else verticalScrollOffset / recyclerviewTotalHeight.toFloat()
         setPosition(currentHeight * proportion)
         if (visibility == View.INVISIBLE) handler.sendEmptyMessage(SHOW_SCROLLER)
-        actor.offer(Unit)
+        actor.safeOffer(Unit)
     }
 
     override fun onChanged(t: HeadersIndex?) {
-        actor.offer(Unit)
+        actor.safeOffer(Unit)
     }
 }



More information about the Android mailing list