Loading app/src/main/java/app/fedilab/android/helper/PinnedTimelineHelper.java +6 −0 Original line number Diff line number Diff line Loading @@ -798,6 +798,7 @@ public class PinnedTimelineHelper { } catch (DBException e) { e.printStackTrace(); } SharedPreferences.Editor editor = sharedpreferences.edit(); editor.putString(activity.getString(R.string.SET_INNER_MARKER) + BaseMainActivity.currentUserID + BaseMainActivity.currentInstance + slug, null); editor.commit(); Loading @@ -813,6 +814,7 @@ public class PinnedTimelineHelper { FragmentTransaction fragTransaction2 = activity.getSupportFragmentManager().beginTransaction(); fragTransaction2.attach(fragmentMastodonTimeline); fragTransaction2.commit(); ((FragmentMastodonTimeline) fragmentMastodonTimeline).recreate(); } } } Loading Loading @@ -1057,6 +1059,7 @@ public class PinnedTimelineHelper { FragmentTransaction fragTransaction2 = activity.getSupportFragmentManager().beginTransaction(); fragTransaction2.attach(fragmentMastodonTimeline); fragTransaction2.commit(); fragmentMastodonTimeline.recreate(); popup.getMenu().close(); return false; }); Loading Loading @@ -1108,6 +1111,7 @@ public class PinnedTimelineHelper { FragmentTransaction fragTransaction2 = activity.getSupportFragmentManager().beginTransaction(); fragTransaction2.attach(fragmentMastodonTimeline); fragTransaction2.commit(); fragmentMastodonTimeline.recreate(); return false; }); } Loading Loading @@ -1187,6 +1191,7 @@ public class PinnedTimelineHelper { FragmentTransaction fragTransaction2 = activity.getSupportFragmentManager().beginTransaction(); fragTransaction2.attach(fragmentMastodonTimeline); fragTransaction2.commit(); fragmentMastodonTimeline.recreate(); } }); Loading Loading @@ -1256,6 +1261,7 @@ public class PinnedTimelineHelper { FragmentTransaction fragTransaction2 = activity.getSupportFragmentManager().beginTransaction(); fragTransaction2.attach(fragmentMastodonTimeline); fragTransaction2.commit(); fragmentMastodonTimeline.recreate(); }); AlertDialog alertDialog = dialogBuilder.create(); alertDialog.show(); Loading app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java +31 −4 Original line number Diff line number Diff line Loading @@ -167,6 +167,32 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. private boolean canBeFederated; private boolean rememberPosition; //Allow to recreate data when detaching/attaching fragment public void recreate() { initialStatuses = null; int count = 0; if (timelineStatuses != null && timelineStatuses.size() > 0) { count = timelineStatuses.size(); timelineStatuses.clear(); timelineStatuses = new ArrayList<>(); if (statusAdapter != null) { statusAdapter.notifyItemRangeRemoved(0, count); max_id = statusReport != null ? statusReport.id : null; SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity()); rememberPosition = sharedpreferences.getBoolean(getString(R.string.SET_REMEMBER_POSITION), true); //Inner marker are only for pinned timelines and main timelines, they have isViewInitialized set to false if (max_id == null && !isViewInitialized && rememberPosition) { max_id = sharedpreferences.getString(getString(R.string.SET_INNER_MARKER) + BaseMainActivity.currentUserID + BaseMainActivity.currentInstance + slug, null); } //Only fragment in main view pager should not have the view initialized //AND Only the first fragment will initialize its view flagLoading = false; router(null); } } } @Override public void onResume() { super.onResume(); Loading Loading @@ -250,12 +276,10 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); } public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { timelineType = Timeline.TimeLineEnum.HOME; canBeFederated = true; if (getArguments() != null) { Loading Loading @@ -589,7 +613,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. * @param direction - DIRECTION null if first call, then is set to TOP or BOTTOM depending of scroll */ private void routeCommon(DIRECTION direction, boolean fetchingMissing, Status status) { if (binding == null || getActivity() == null || !isAdded()) { return; } Loading Loading @@ -809,7 +832,10 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. if (pinnedTimeline != null && pinnedTimeline.remoteInstance.type == RemoteInstance.InstanceType.NITTER) { if (direction == null) { timelinesVM.getNitter(pinnedTimeline.remoteInstance.host, null) .observe(getViewLifecycleOwner(), this::initializeStatusesCommonView); .observe(getViewLifecycleOwner(), nitterStatuses -> { initialStatuses = nitterStatuses; initializeStatusesCommonView(nitterStatuses); }); } else if (direction == DIRECTION.BOTTOM) { timelinesVM.getNitter(pinnedTimeline.remoteInstance.host, max_id) .observe(getViewLifecycleOwner(), statusesBottom -> dealWithPagination(statusesBottom, DIRECTION.BOTTOM, false)); Loading Loading @@ -993,6 +1019,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. FETCH_NEW } public interface UpdateCounters { void onUpdate(int count, Timeline.TimeLineEnum type, String slug); } Loading Loading
app/src/main/java/app/fedilab/android/helper/PinnedTimelineHelper.java +6 −0 Original line number Diff line number Diff line Loading @@ -798,6 +798,7 @@ public class PinnedTimelineHelper { } catch (DBException e) { e.printStackTrace(); } SharedPreferences.Editor editor = sharedpreferences.edit(); editor.putString(activity.getString(R.string.SET_INNER_MARKER) + BaseMainActivity.currentUserID + BaseMainActivity.currentInstance + slug, null); editor.commit(); Loading @@ -813,6 +814,7 @@ public class PinnedTimelineHelper { FragmentTransaction fragTransaction2 = activity.getSupportFragmentManager().beginTransaction(); fragTransaction2.attach(fragmentMastodonTimeline); fragTransaction2.commit(); ((FragmentMastodonTimeline) fragmentMastodonTimeline).recreate(); } } } Loading Loading @@ -1057,6 +1059,7 @@ public class PinnedTimelineHelper { FragmentTransaction fragTransaction2 = activity.getSupportFragmentManager().beginTransaction(); fragTransaction2.attach(fragmentMastodonTimeline); fragTransaction2.commit(); fragmentMastodonTimeline.recreate(); popup.getMenu().close(); return false; }); Loading Loading @@ -1108,6 +1111,7 @@ public class PinnedTimelineHelper { FragmentTransaction fragTransaction2 = activity.getSupportFragmentManager().beginTransaction(); fragTransaction2.attach(fragmentMastodonTimeline); fragTransaction2.commit(); fragmentMastodonTimeline.recreate(); return false; }); } Loading Loading @@ -1187,6 +1191,7 @@ public class PinnedTimelineHelper { FragmentTransaction fragTransaction2 = activity.getSupportFragmentManager().beginTransaction(); fragTransaction2.attach(fragmentMastodonTimeline); fragTransaction2.commit(); fragmentMastodonTimeline.recreate(); } }); Loading Loading @@ -1256,6 +1261,7 @@ public class PinnedTimelineHelper { FragmentTransaction fragTransaction2 = activity.getSupportFragmentManager().beginTransaction(); fragTransaction2.attach(fragmentMastodonTimeline); fragTransaction2.commit(); fragmentMastodonTimeline.recreate(); }); AlertDialog alertDialog = dialogBuilder.create(); alertDialog.show(); Loading
app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java +31 −4 Original line number Diff line number Diff line Loading @@ -167,6 +167,32 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. private boolean canBeFederated; private boolean rememberPosition; //Allow to recreate data when detaching/attaching fragment public void recreate() { initialStatuses = null; int count = 0; if (timelineStatuses != null && timelineStatuses.size() > 0) { count = timelineStatuses.size(); timelineStatuses.clear(); timelineStatuses = new ArrayList<>(); if (statusAdapter != null) { statusAdapter.notifyItemRangeRemoved(0, count); max_id = statusReport != null ? statusReport.id : null; SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity()); rememberPosition = sharedpreferences.getBoolean(getString(R.string.SET_REMEMBER_POSITION), true); //Inner marker are only for pinned timelines and main timelines, they have isViewInitialized set to false if (max_id == null && !isViewInitialized && rememberPosition) { max_id = sharedpreferences.getString(getString(R.string.SET_INNER_MARKER) + BaseMainActivity.currentUserID + BaseMainActivity.currentInstance + slug, null); } //Only fragment in main view pager should not have the view initialized //AND Only the first fragment will initialize its view flagLoading = false; router(null); } } } @Override public void onResume() { super.onResume(); Loading Loading @@ -250,12 +276,10 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); } public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { timelineType = Timeline.TimeLineEnum.HOME; canBeFederated = true; if (getArguments() != null) { Loading Loading @@ -589,7 +613,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. * @param direction - DIRECTION null if first call, then is set to TOP or BOTTOM depending of scroll */ private void routeCommon(DIRECTION direction, boolean fetchingMissing, Status status) { if (binding == null || getActivity() == null || !isAdded()) { return; } Loading Loading @@ -809,7 +832,10 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. if (pinnedTimeline != null && pinnedTimeline.remoteInstance.type == RemoteInstance.InstanceType.NITTER) { if (direction == null) { timelinesVM.getNitter(pinnedTimeline.remoteInstance.host, null) .observe(getViewLifecycleOwner(), this::initializeStatusesCommonView); .observe(getViewLifecycleOwner(), nitterStatuses -> { initialStatuses = nitterStatuses; initializeStatusesCommonView(nitterStatuses); }); } else if (direction == DIRECTION.BOTTOM) { timelinesVM.getNitter(pinnedTimeline.remoteInstance.host, max_id) .observe(getViewLifecycleOwner(), statusesBottom -> dealWithPagination(statusesBottom, DIRECTION.BOTTOM, false)); Loading Loading @@ -993,6 +1019,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. FETCH_NEW } public interface UpdateCounters { void onUpdate(int count, Timeline.TimeLineEnum type, String slug); } Loading