Scroll to top by long-pressing toolbar

Supports all lists except "all episodes" list because that one still
displays tabs. Can be added as soon as the tabs are no longer required.
This commit is contained in:
ByteHamster 2022-07-09 15:29:15 +02:00
parent 5576ae8560
commit 239a30c267
6 changed files with 31 additions and 0 deletions

View File

@ -80,6 +80,11 @@ public class CompletedDownloadsFragment extends Fragment
toolbar.setTitle(R.string.downloads_label);
toolbar.inflateMenu(R.menu.downloads_completed);
toolbar.setOnMenuItemClickListener(this);
toolbar.setOnLongClickListener(v -> {
recyclerView.scrollToPosition(5);
recyclerView.post(() -> recyclerView.smoothScrollToPosition(0));
return false;
});
refreshToolbarState();
displayUpArrow = getParentFragmentManager().getBackStackEntryCount() != 0;
if (savedInstanceState != null) {

View File

@ -129,6 +129,12 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
speedDialBinding = MultiSelectSpeedDialBinding.bind(viewBinding.getRoot());
viewBinding.toolbar.inflateMenu(R.menu.feedlist);
viewBinding.toolbar.setOnMenuItemClickListener(this);
viewBinding.toolbar.setOnLongClickListener(v -> {
viewBinding.recyclerView.scrollToPosition(5);
viewBinding.recyclerView.post(() -> viewBinding.recyclerView.smoothScrollToPosition(0));
viewBinding.appBar.setExpanded(true);
return false;
});
displayUpArrow = getParentFragmentManager().getBackStackEntryCount() != 0;
if (savedInstanceState != null) {
displayUpArrow = savedInstanceState.getBoolean(KEY_UP_ARROW);

View File

@ -58,6 +58,11 @@ public class InboxFragment extends EpisodesListFragment implements Toolbar.OnMen
toolbar = inboxContainer.findViewById(R.id.toolbar);
toolbar.setOnMenuItemClickListener(this);
toolbar.inflateMenu(R.menu.inbox);
toolbar.setOnLongClickListener(v -> {
recyclerView.scrollToPosition(5);
recyclerView.post(() -> recyclerView.smoothScrollToPosition(0));
return false;
});
displayUpArrow = getParentFragmentManager().getBackStackEntryCount() != 0;
if (savedInstanceState != null) {
displayUpArrow = savedInstanceState.getBoolean(KEY_UP_ARROW);

View File

@ -51,6 +51,11 @@ public class PlaybackHistoryFragment extends EpisodesListFragment implements Too
toolbar = historyContainer.findViewById(R.id.toolbar);
toolbar.setTitle(R.string.playback_history_label);
toolbar.setOnMenuItemClickListener(this);
toolbar.setOnLongClickListener(v -> {
recyclerView.scrollToPosition(5);
recyclerView.post(() -> recyclerView.smoothScrollToPosition(0));
return false;
});
displayUpArrow = getParentFragmentManager().getBackStackEntryCount() != 0;
if (savedInstanceState != null) {
displayUpArrow = savedInstanceState.getBoolean(KEY_UP_ARROW);

View File

@ -445,6 +445,11 @@ public class QueueFragment extends Fragment implements Toolbar.OnMenuItemClickLi
View root = inflater.inflate(R.layout.queue_fragment, container, false);
toolbar = root.findViewById(R.id.toolbar);
toolbar.setOnMenuItemClickListener(this);
toolbar.setOnLongClickListener(v -> {
recyclerView.scrollToPosition(5);
recyclerView.post(() -> recyclerView.smoothScrollToPosition(0));
return false;
});
displayUpArrow = getParentFragmentManager().getBackStackEntryCount() != 0;
if (savedInstanceState != null) {
displayUpArrow = savedInstanceState.getBoolean(KEY_UP_ARROW);

View File

@ -125,6 +125,11 @@ public class SubscriptionFragment extends Fragment
View root = inflater.inflate(R.layout.fragment_subscriptions, container, false);
toolbar = root.findViewById(R.id.toolbar);
toolbar.setOnMenuItemClickListener(this);
toolbar.setOnLongClickListener(v -> {
subscriptionRecycler.scrollToPosition(5);
subscriptionRecycler.post(() -> subscriptionRecycler.smoothScrollToPosition(0));
return false;
});
displayUpArrow = getParentFragmentManager().getBackStackEntryCount() != 0;
if (savedInstanceState != null) {
displayUpArrow = savedInstanceState.getBoolean(KEY_UP_ARROW);