Disable scroll when item is already visible
This commit is contained in:
parent
034ef821e8
commit
0514d90998
2 changed files with 9 additions and 0 deletions
|
@ -160,6 +160,7 @@ class QueueActivity : SimpleControllerActivity() {
|
|||
withPlayer {
|
||||
val currentTracks = currentMediaItemsShuffled.toTracks() as ArrayList<Track>
|
||||
adapter.updateItems(currentTracks)
|
||||
queue_list.lazySmoothScroll(shuffledMediaItemsIndices.indexOf(currentMediaItemIndex))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,16 @@
|
|||
package com.simplemobiletools.musicplayer.extensions
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
||||
fun RecyclerView.lazySmoothScroll(scrollToPosition: Int) {
|
||||
val layoutManager = layoutManager
|
||||
if (layoutManager is LinearLayoutManager) {
|
||||
if (scrollToPosition in layoutManager.findFirstCompletelyVisibleItemPosition()..layoutManager.findLastCompletelyVisibleItemPosition()) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (scrollToPosition > 100) {
|
||||
post {
|
||||
scrollToPosition(scrollToPosition - 25)
|
||||
|
|
Loading…
Reference in a new issue