From 13673aa036f2f2464c6115b7310e93ede29af06a Mon Sep 17 00:00:00 2001 From: sspanak Date: Tue, 1 Oct 2024 11:16:17 +0300 Subject: [PATCH] regression: fixed the last item remains selected after wrap-scrolling to the first one, when a stem is displayed in the suggestion bar --- .../tt9/ui/tray/SuggestionsAdapter.java | 13 ++++- .../sspanak/tt9/ui/tray/SuggestionsBar.java | 49 +++++++++---------- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/app/src/main/java/io/github/sspanak/tt9/ui/tray/SuggestionsAdapter.java b/app/src/main/java/io/github/sspanak/tt9/ui/tray/SuggestionsAdapter.java index 5432a7c4..9aec3af6 100644 --- a/app/src/main/java/io/github/sspanak/tt9/ui/tray/SuggestionsAdapter.java +++ b/app/src/main/java/io/github/sspanak/tt9/ui/tray/SuggestionsAdapter.java @@ -1,5 +1,6 @@ package io.github.sspanak.tt9.ui.tray; +import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Color; import android.view.LayoutInflater; @@ -57,8 +58,16 @@ public class SuggestionsAdapter extends RecyclerView.Adapter 0) { alternativeScrollingHandler.removeCallbacksAndMessages(null); - alternativeScrollingHandler.postDelayed(this::scrollToSelectedIndex, settings.getSuggestionScrollingDelay()); + alternativeScrollingHandler.postDelayed(this::scrollView, settings.getSuggestionScrollingDelay()); } else { - scrollToSelectedIndex(); + scrollView(); } } /** - * Tells the adapter to scroll. Always call scrollToSuggestionOnScreen() first, + * Tells the adapter to scroll. Always call scrollToIndex() first, * to set the selected index in the adapter. */ - private void scrollToSelectedIndex() { - if (containsStem() && selectedIndex == 1 && getSuggestion(1).length() < getSuggestion(suggestions.size() - 1).length()) { + private void scrollView() { + if (containsStem() && selectedIndex == 1) { mView.scrollToPosition(0); } else { mView.scrollToPosition(selectedIndex);