some fixes

This commit is contained in:
Thomas 2022-06-24 08:57:17 +02:00
parent 81a3b47134
commit 3068dea862

View file

@ -587,7 +587,6 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
}); });
} }
binding.bottomNavView.setOnItemSelectedListener(item -> { binding.bottomNavView.setOnItemSelectedListener(item -> {
int itemId = item.getItemId(); int itemId = item.getItemId();
int position = BottomMenu.getPosition(bottomMenu, itemId); int position = BottomMenu.getPosition(bottomMenu, itemId);
if (position >= 0) { if (position >= 0) {
@ -878,21 +877,19 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
* Allow to scroll to top for bottom navigation items * Allow to scroll to top for bottom navigation items
*/ */
private void scrollToTop() { private void scrollToTop() {
if (binding.viewPager.getAdapter() != null) { Fragment fragment = getSupportFragmentManager().findFragmentByTag("f" + binding.viewPager.getCurrentItem());
Fragment fragment = getSupportFragmentManager().findFragmentByTag("f" + binding.viewPager.getCurrentItem()); if (fragment instanceof FragmentMastodonTimeline) {
if (fragment instanceof FragmentMastodonTimeline) { FragmentMastodonTimeline fragmentMastodonTimeline = ((FragmentMastodonTimeline) fragment);
FragmentMastodonTimeline fragmentMastodonTimeline = ((FragmentMastodonTimeline) fragment); fragmentMastodonTimeline.scrollToTop();
fragmentMastodonTimeline.scrollToTop(); } else if (fragment instanceof FragmentMastodonNotification) {
} else if (fragment instanceof FragmentMastodonNotification) { FragmentMastodonNotification fragmentMastodonNotification = ((FragmentMastodonNotification) fragment);
FragmentMastodonNotification fragmentMastodonNotification = ((FragmentMastodonNotification) fragment); fragmentMastodonNotification.scrollToTop();
fragmentMastodonNotification.scrollToTop(); } else if (fragment instanceof FragmentMastodonConversation) {
} else if (fragment instanceof FragmentMastodonConversation) { FragmentMastodonConversation fragmentMastodonConversation = ((FragmentMastodonConversation) fragment);
FragmentMastodonConversation fragmentMastodonConversation = ((FragmentMastodonConversation) fragment); fragmentMastodonConversation.scrollToTop();
fragmentMastodonConversation.scrollToTop(); } else if (fragment instanceof FragmentNotificationContainer) {
} else if (fragment instanceof FragmentNotificationContainer) { FragmentNotificationContainer fragmentNotificationContainer = ((FragmentNotificationContainer) fragment);
FragmentNotificationContainer fragmentNotificationContainer = ((FragmentNotificationContainer) fragment); fragmentNotificationContainer.scrollToTop();
fragmentNotificationContainer.scrollToTop();
}
} }
} }