Fix issues

This commit is contained in:
Thomas 2023-02-02 17:44:16 +01:00
parent 4c89a855c6
commit 440ad039be
1 changed files with 2 additions and 2 deletions

View File

@ -1811,9 +1811,9 @@ 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() {
int position = binding.tabLayout.getSelectedTabPosition();
if (binding.viewPager.getAdapter() != null) { if (binding.viewPager.getAdapter() != null) {
Fragment fragment = (Fragment) binding.viewPager.getAdapter().instantiateItem(binding.viewPager, binding.tabLayout.getSelectedTabPosition()); Fragment fragment = (Fragment) binding.viewPager.getAdapter().instantiateItem(binding.viewPager, Math.max(position, 0));
if (fragment instanceof FragmentMastodonTimeline) { if (fragment instanceof FragmentMastodonTimeline) {
FragmentMastodonTimeline fragmentMastodonTimeline = ((FragmentMastodonTimeline) fragment); FragmentMastodonTimeline fragmentMastodonTimeline = ((FragmentMastodonTimeline) fragment);
fragmentMastodonTimeline.scrollToTop(); fragmentMastodonTimeline.scrollToTop();