mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-23 01:00:04 +02:00
Fix #676 - Rollback to previous changes
This commit is contained in:
parent
ef2aafed67
commit
1fb129eada
1 changed files with 80 additions and 83 deletions
|
@ -315,89 +315,8 @@ public class PinnedTimelineHelper {
|
|||
return;
|
||||
}
|
||||
//Pinned tab position will start after BOTTOM_TIMELINE_COUNT (ie 5)
|
||||
int toRemove = BOTTOM_TIMELINE_COUNT;
|
||||
activityMainBinding.tabLayout.removeAllTabs();
|
||||
LinearLayout tabStrip = (LinearLayout) activityMainBinding.tabLayout.getChildAt(0);
|
||||
int finalToRemove = toRemove;
|
||||
activityMainBinding.viewPager.setAdapter(null);
|
||||
activityMainBinding.viewPager.clearOnPageChangeListeners();
|
||||
activityMainBinding.tabLayout.clearOnTabSelectedListeners();
|
||||
FedilabPageAdapter fedilabPageAdapter = new FedilabPageAdapter(activity, activity.getSupportFragmentManager(), pinned, bottomMenu);
|
||||
activityMainBinding.viewPager.setAdapter(fedilabPageAdapter);
|
||||
activityMainBinding.viewPager.setOffscreenPageLimit(tabStrip.getChildCount());
|
||||
activityMainBinding.viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(activityMainBinding.tabLayout));
|
||||
if (!singleBar) {
|
||||
activityMainBinding.viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
if (position < BOTTOM_TIMELINE_COUNT - finalToRemove) {
|
||||
activityMainBinding.bottomNavView.getMenu().getItem(position).setChecked(true);
|
||||
} else {
|
||||
activityMainBinding.bottomNavView.getMenu().setGroupCheckable(0, true, false);
|
||||
for (int i = 0; i < activityMainBinding.bottomNavView.getMenu().size(); i++) {
|
||||
activityMainBinding.bottomNavView.getMenu().getItem(i).setChecked(false);
|
||||
}
|
||||
activityMainBinding.bottomNavView.getMenu().setGroupCheckable(0, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
activityMainBinding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||
@Override
|
||||
public void onTabSelected(TabLayout.Tab tab) {
|
||||
activityMainBinding.viewPager.setCurrentItem(tab.getPosition());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabUnselected(TabLayout.Tab tab) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabReselected(TabLayout.Tab tab) {
|
||||
if (!singleBar && tab.getTag() != null) {
|
||||
if (tab.getTag().equals(Timeline.TimeLineEnum.HOME.getValue())) {
|
||||
activityMainBinding.bottomNavView.removeBadge(R.id.nav_home);
|
||||
} else if (tab.getTag().equals(Timeline.TimeLineEnum.LOCAL.getValue())) {
|
||||
activityMainBinding.bottomNavView.removeBadge(R.id.nav_local);
|
||||
} else if (tab.getTag().equals(Timeline.TimeLineEnum.PUBLIC.getValue())) {
|
||||
activityMainBinding.bottomNavView.removeBadge(R.id.nav_public);
|
||||
} else if (tab.getTag().equals(Timeline.TimeLineEnum.NOTIFICATION.getValue())) {
|
||||
activityMainBinding.bottomNavView.removeBadge(R.id.nav_notifications);
|
||||
} else if (tab.getTag().equals(Timeline.TimeLineEnum.CONVERSATION.getValue())) {
|
||||
activityMainBinding.bottomNavView.removeBadge(R.id.nav_privates);
|
||||
}
|
||||
|
||||
}
|
||||
Fragment fragment = fedilabPageAdapter.getCurrentFragment();
|
||||
View view = tab.getCustomView();
|
||||
if (view != null) {
|
||||
TextView counter = view.findViewById(R.id.tab_counter);
|
||||
if (counter != null) {
|
||||
counter.setVisibility(View.GONE);
|
||||
counter.setText("0");
|
||||
}
|
||||
}
|
||||
if (fragment instanceof FragmentMastodonTimeline) {
|
||||
((FragmentMastodonTimeline) fragment).scrollToTop();
|
||||
} else if (fragment instanceof FragmentMastodonConversation) {
|
||||
((FragmentMastodonConversation) fragment).scrollToTop();
|
||||
} else if (fragment instanceof FragmentNotificationContainer) {
|
||||
((FragmentNotificationContainer) fragment).scrollToTop();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
int toRemove = BOTTOM_TIMELINE_COUNT;
|
||||
if (!singleBar) {
|
||||
//Small hack to hide first tabs (they represent the item of the bottom menu)
|
||||
toRemove = itemToRemoveInBottomMenu(activity);
|
||||
|
@ -588,6 +507,8 @@ public class PinnedTimelineHelper {
|
|||
});
|
||||
|
||||
|
||||
LinearLayout tabStrip = (LinearLayout) activityMainBinding.tabLayout.getChildAt(0);
|
||||
int finalToRemove = toRemove;
|
||||
for (int i = 0; i < tabStrip.getChildCount(); i++) {
|
||||
// Set LongClick listener to each Tab
|
||||
int finalI = i;
|
||||
|
@ -618,7 +539,83 @@ public class PinnedTimelineHelper {
|
|||
});
|
||||
}
|
||||
|
||||
activityMainBinding.viewPager.setAdapter(null);
|
||||
activityMainBinding.viewPager.clearOnPageChangeListeners();
|
||||
activityMainBinding.tabLayout.clearOnTabSelectedListeners();
|
||||
FedilabPageAdapter fedilabPageAdapter = new FedilabPageAdapter(activity, activity.getSupportFragmentManager(), pinned, bottomMenu);
|
||||
activityMainBinding.viewPager.setAdapter(fedilabPageAdapter);
|
||||
activityMainBinding.viewPager.setOffscreenPageLimit(tabStrip.getChildCount());
|
||||
activityMainBinding.viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(activityMainBinding.tabLayout));
|
||||
if (!singleBar) {
|
||||
activityMainBinding.viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
if (position < BOTTOM_TIMELINE_COUNT - finalToRemove) {
|
||||
activityMainBinding.bottomNavView.getMenu().getItem(position).setChecked(true);
|
||||
} else {
|
||||
activityMainBinding.bottomNavView.getMenu().setGroupCheckable(0, true, false);
|
||||
for (int i = 0; i < activityMainBinding.bottomNavView.getMenu().size(); i++) {
|
||||
activityMainBinding.bottomNavView.getMenu().getItem(i).setChecked(false);
|
||||
}
|
||||
activityMainBinding.bottomNavView.getMenu().setGroupCheckable(0, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
activityMainBinding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||
@Override
|
||||
public void onTabSelected(TabLayout.Tab tab) {
|
||||
activityMainBinding.viewPager.setCurrentItem(tab.getPosition());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabUnselected(TabLayout.Tab tab) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabReselected(TabLayout.Tab tab) {
|
||||
if (!singleBar && tab.getTag() != null) {
|
||||
if (tab.getTag().equals(Timeline.TimeLineEnum.HOME.getValue())) {
|
||||
activityMainBinding.bottomNavView.removeBadge(R.id.nav_home);
|
||||
} else if (tab.getTag().equals(Timeline.TimeLineEnum.LOCAL.getValue())) {
|
||||
activityMainBinding.bottomNavView.removeBadge(R.id.nav_local);
|
||||
} else if (tab.getTag().equals(Timeline.TimeLineEnum.PUBLIC.getValue())) {
|
||||
activityMainBinding.bottomNavView.removeBadge(R.id.nav_public);
|
||||
} else if (tab.getTag().equals(Timeline.TimeLineEnum.NOTIFICATION.getValue())) {
|
||||
activityMainBinding.bottomNavView.removeBadge(R.id.nav_notifications);
|
||||
} else if (tab.getTag().equals(Timeline.TimeLineEnum.CONVERSATION.getValue())) {
|
||||
activityMainBinding.bottomNavView.removeBadge(R.id.nav_privates);
|
||||
}
|
||||
|
||||
}
|
||||
Fragment fragment = fedilabPageAdapter.getCurrentFragment();
|
||||
View view = tab.getCustomView();
|
||||
if (view != null) {
|
||||
TextView counter = view.findViewById(R.id.tab_counter);
|
||||
if (counter != null) {
|
||||
counter.setVisibility(View.GONE);
|
||||
counter.setText("0");
|
||||
}
|
||||
}
|
||||
if (fragment instanceof FragmentMastodonTimeline) {
|
||||
((FragmentMastodonTimeline) fragment).scrollToTop();
|
||||
} else if (fragment instanceof FragmentMastodonConversation) {
|
||||
((FragmentMastodonConversation) fragment).scrollToTop();
|
||||
} else if (fragment instanceof FragmentNotificationContainer) {
|
||||
((FragmentNotificationContainer) fragment).scrollToTop();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue