[Android] Fix fast scroller provider in audio lists

Nicolas Pomepuy git at videolan.org
Fri Aug 2 14:35:45 CEST 2019


vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Fri Aug  2 05:57:47 2019 +0200| [fa0bb06778ee1707e717944a12943cbe6eb8b073] | committer: Nicolas Pomepuy

Fix fast scroller provider in audio lists

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

 vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt | 6 +++---
 vlc-android/src/org/videolan/vlc/gui/view/FastScroller.kt          | 4 +++-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt
index efd469ca5..f4599dd82 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt
@@ -287,7 +287,7 @@ class AudioBrowserFragment : BaseAudioBrowser<AudioBrowserViewModel>(), SwipeRef
 
     override fun onTabSelected(tab: TabLayout.Tab) {
         super.onTabSelected(tab)
-        fastScroller.setRecyclerView(lists[tab.position]!!, viewModel.providers[currentTab])
+        fastScroller.setRecyclerView(lists[tab.position], viewModel.providers[tab.position])
         settings.edit().putInt(KEY_AUDIO_CURRENT_TAB, tab.position).apply()
         if (viewModel.providers[currentTab].isRefreshing)
             handler.sendEmptyMessage(SET_REFRESHING)
@@ -298,12 +298,12 @@ class AudioBrowserFragment : BaseAudioBrowser<AudioBrowserViewModel>(), SwipeRef
 
     override fun onTabUnselected(tab: TabLayout.Tab) {
         super.onTabUnselected(tab)
-        onDestroyActionMode(lists[tab.position]!!.adapter as AudioBrowserAdapter?)
+        onDestroyActionMode(lists[tab.position].adapter as AudioBrowserAdapter?)
         viewModel.restore()
     }
 
     override fun onTabReselected(tab: TabLayout.Tab) {
-        lists[tab.position]?.smoothScrollToPosition(0)
+        lists[tab.position].smoothScrollToPosition(0)
     }
 
     override fun onCtxAction(position: Int, option: Int) {
diff --git a/vlc-android/src/org/videolan/vlc/gui/view/FastScroller.kt b/vlc-android/src/org/videolan/vlc/gui/view/FastScroller.kt
index bc2d5b8c1..bdebc55d7 100644
--- a/vlc-android/src/org/videolan/vlc/gui/view/FastScroller.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/view/FastScroller.kt
@@ -55,6 +55,8 @@ import org.videolan.vlc.providers.HeadersIndex
 import org.videolan.vlc.providers.medialibrary.MedialibraryProvider
 import org.videolan.vlc.util.WeakHandler
 import java.util.concurrent.atomic.AtomicBoolean
+import kotlin.math.max
+import kotlin.math.min
 
 private const val TAG = "FastScroller"
 private const val HANDLE_ANIMATION_DURATION = 100
@@ -313,7 +315,7 @@ class FastScroller : LinearLayout, CoroutineScope, Observer<HeadersIndex> {
     }
 
     private fun getValueInRange(min: Int, max: Int, value: Int): Int {
-        return Math.min(Math.max(min, value), max)
+        return min(max(min, value), max)
     }
 
 



More information about the Android mailing list