From 36f1a557d75ec2cdc80b45978ddb83665da5a9f7 Mon Sep 17 00:00:00 2001 From: Grishka Date: Tue, 23 May 2023 12:17:26 +0300 Subject: [PATCH] Fix default tab in profile --- .../android/fragments/ProfileFragment.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java index 76a2c42d..3a98b3d5 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java @@ -362,6 +362,15 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList aboutFragment.setFields(fields); } pager.getAdapter().notifyDataSetChanged(); + pager.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener(){ + @Override + public boolean onPreDraw(){ + pager.getViewTreeObserver().removeOnPreDrawListener(this); + pager.setCurrentItem(1, false); + tabbar.selectTab(tabbar.getTabAt(1)); + return true; + } + }); super.dataLoaded(); } @@ -391,8 +400,6 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList refreshLayout.setEnabled(state!=ViewPager2.SCROLL_STATE_DRAGGING); } }); - pager.setCurrentItem(1, false); - tabbar.selectTab(tabbar.getTabAt(1)); return true; } });