enable scrolling to top via toolbar

This commit is contained in:
sk 2023-01-23 12:49:55 +01:00 committed by LucasGGamerM
parent e0dd2e3a08
commit 114283846c
1 changed files with 13 additions and 0 deletions

View File

@ -120,6 +120,18 @@ public class NotificationsFragment extends MastodonToolbarFragment implements Sc
tabLayout.setTabTextSize(V.dp(16)); tabLayout.setTabTextSize(V.dp(16));
tabLayout.setTabTextColors(UiUtils.getThemeColor(getActivity(), R.attr.colorTabInactive), UiUtils.getThemeColor(getActivity(), android.R.attr.textColorPrimary)); tabLayout.setTabTextColors(UiUtils.getThemeColor(getActivity(), R.attr.colorTabInactive), UiUtils.getThemeColor(getActivity(), android.R.attr.textColorPrimary));
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {}
@Override
public void onTabUnselected(TabLayout.Tab tab) {}
@Override
public void onTabReselected(TabLayout.Tab tab) {
scrollToTop();
}
});
pager.setOffscreenPageLimit(4); pager.setOffscreenPageLimit(4);
pager.setUserInputEnabled(!GlobalUserPreferences.disableSwipe); pager.setUserInputEnabled(!GlobalUserPreferences.disableSwipe);
@ -211,6 +223,7 @@ public class NotificationsFragment extends MastodonToolbarFragment implements Sc
protected void updateToolbar(){ protected void updateToolbar(){
super.updateToolbar(); super.updateToolbar();
getToolbar().setOutlineProvider(null); getToolbar().setOutlineProvider(null);
getToolbar().setOnClickListener(v->scrollToTop());
} }
private NotificationsListFragment getFragmentForPage(int page){ private NotificationsListFragment getFragmentForPage(int page){