Fix offset with pinned

This commit is contained in:
Thomas 2022-09-14 11:27:27 +02:00
parent 9f6ca2270d
commit a658d17e2c
2 changed files with 6 additions and 3 deletions

View File

@ -242,6 +242,7 @@ public class PinnedTimelineHelper {
} }
} }
List<PinnedTimeline> pinnedTimelineVisibleList = new ArrayList<>(); List<PinnedTimeline> pinnedTimelineVisibleList = new ArrayList<>();
List<PinnedTimeline> pinnedToRemove = new ArrayList<>();
for (PinnedTimeline pinnedTimeline : pinned.pinnedTimelines) { for (PinnedTimeline pinnedTimeline : pinned.pinnedTimelines) {
//Default timelines are not added if we are not in the single bar mode //Default timelines are not added if we are not in the single bar mode
if (!singleBar) { if (!singleBar) {
@ -251,6 +252,7 @@ public class PinnedTimelineHelper {
case PUBLIC: case PUBLIC:
case NOTIFICATION: case NOTIFICATION:
case DIRECT: case DIRECT:
pinnedToRemove.add(pinnedTimeline);
continue; continue;
} }
} }
@ -328,7 +330,7 @@ public class PinnedTimelineHelper {
pinnedTimelineVisibleList.add(pinnedTimeline); pinnedTimelineVisibleList.add(pinnedTimeline);
} }
} }
pinned.pinnedTimelines.removeAll(pinnedToRemove);
Pinned finalPinned = pinned; Pinned finalPinned = pinned;
int finalToRemove1 = toRemove; int finalToRemove1 = toRemove;

View File

@ -45,13 +45,14 @@ public class FedilabPageAdapter extends FragmentStatePagerAdapter {
private final BottomMenu bottomMenu; private final BottomMenu bottomMenu;
private final int toRemove; private final int toRemove;
private Fragment mCurrentFragment; private Fragment mCurrentFragment;
private final boolean singleBar;
public FedilabPageAdapter(BaseMainActivity activity, FragmentManager fm, Pinned pinned, BottomMenu bottomMenu) { public FedilabPageAdapter(BaseMainActivity activity, FragmentManager fm, Pinned pinned, BottomMenu bottomMenu) {
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT); super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
this.pinned = pinned; this.pinned = pinned;
this.bottomMenu = bottomMenu; this.bottomMenu = bottomMenu;
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(activity); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(activity);
boolean singleBar = sharedpreferences.getBoolean(activity.getString(R.string.SET_USE_SINGLE_TOPBAR), false); singleBar = sharedpreferences.getBoolean(activity.getString(R.string.SET_USE_SINGLE_TOPBAR), false);
if (!singleBar) { if (!singleBar) {
toRemove = PinnedTimelineHelper.itemToRemoveInBottomMenu(activity); toRemove = PinnedTimelineHelper.itemToRemoveInBottomMenu(activity);
} else { } else {
@ -87,7 +88,7 @@ public class FedilabPageAdapter extends FragmentStatePagerAdapter {
FragmentMastodonTimeline fragment = new FragmentMastodonTimeline(); FragmentMastodonTimeline fragment = new FragmentMastodonTimeline();
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
//Position 3 is for notifications //Position 3 is for notifications
if (position < (BOTTOM_TIMELINE_COUNT - toRemove)) { if (position < (BOTTOM_TIMELINE_COUNT - toRemove) && !singleBar) {
if (bottomMenu != null) { if (bottomMenu != null) {
BottomMenu.ItemMenuType type = BottomMenu.getType(bottomMenu, position); BottomMenu.ItemMenuType type = BottomMenu.getType(bottomMenu, position);
if (type == null) { if (type == null) {