From 2fdac736b3ab0edc30f5bfb46e8ff5d6021f8e60 Mon Sep 17 00:00:00 2001 From: Antic1tizen One Date: Mon, 20 Aug 2018 22:23:55 +0300 Subject: [PATCH] Scroll the queue only when the requested song is not on screen (#812) Now if the option "scroll to the queue position" is enabled and a user is selecting a song in queue it immediately disappears from under the finger and jumps to the top of currently visible list. This patch fixes this behaviour - only scroll if next (or previous) song falls out of list view visible range. I.e. sudden scrolling will never happen if user clicks an item in queue as it's currently visible. --- .../blinkenlights/android/vanilla/ShowQueueFragment.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/ch/blinkenlights/android/vanilla/ShowQueueFragment.java b/app/src/main/java/ch/blinkenlights/android/vanilla/ShowQueueFragment.java index a6868f7b..3dc07d70 100644 --- a/app/src/main/java/ch/blinkenlights/android/vanilla/ShowQueueFragment.java +++ b/app/src/main/java/ch/blinkenlights/android/vanilla/ShowQueueFragment.java @@ -187,8 +187,13 @@ public class ShowQueueFragment extends Fragment public void run() { mListAdapter.setData(service, pos); - if(scroll) - scrollToCurrentSong(pos); + if(scroll) { + // check that we really need to jump to this song, i.e. it is not visible in list right now + int min = mListView.getFirstVisiblePosition(); + int max = mListView.getLastVisiblePosition(); + if (pos < min || pos > max) // it's out of visible range, scroll + scrollToCurrentSong(pos); + } } }); mIsPopulated = true;