Merge pull request #5962 from ByteHamster/long-press-toolbar

Scroll to top by long-pressing toolbar
This commit is contained in:
ByteHamster 2022-07-09 19:46:46 +02:00 committed by GitHub
commit f5ae881561
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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);