Commit 919a11ec authored by Thomas's avatar Thomas
Browse files

Fix some issues with markers

parent f11ea8fc
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -180,6 +180,22 @@ public class FragmentMastodonConversation extends Fragment implements Conversati
    }


    private void storeMarker() {
        if (mLayoutManager != null) {
            int position = mLayoutManager.findFirstVisibleItemPosition();
            if (conversationList != null && conversationList.size() > position) {
                try {
                    Conversation conversation = conversationList.get(position);
                    SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
                    SharedPreferences.Editor editor = sharedpreferences.edit();
                    editor.putString(getString(R.string.SET_INNER_MARKER) + BaseMainActivity.currentUserID + BaseMainActivity.currentInstance + Timeline.TimeLineEnum.CONVERSATION, conversation.id);
                    editor.apply();
                } catch (Exception ignored) {
                }
            }
        }
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
@@ -283,6 +299,19 @@ public class FragmentMastodonConversation extends Fragment implements Conversati

    }

    @Override
    public void onDestroyView() {
        if (isAdded()) {
            storeMarker();
        }
        super.onDestroyView();
    }

    @Override
    public void onPause() {
        storeMarker();
        super.onPause();
    }

    /**
     * Update view and pagination when scrolling down
+23 −0
Original line number Diff line number Diff line
@@ -430,6 +430,25 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
    }


    private void storeMarker() {
        if (mLayoutManager != null) {
            int position = mLayoutManager.findFirstVisibleItemPosition();
            if (notificationList != null && notificationList.size() > position) {
                try {
                    if (notificationType == NotificationTypeEnum.ALL) {
                        Notification notification = notificationList.get(position);
                        SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
                        SharedPreferences.Editor editor = sharedpreferences.edit();
                        editor.putString(getString(R.string.SET_INNER_MARKER) + BaseMainActivity.currentUserID + BaseMainActivity.currentInstance + Timeline.TimeLineEnum.NOTIFICATION, notification.id);
                        editor.apply();
                        TimelinesVM timelinesVM = new ViewModelProvider(FragmentMastodonNotification.this).get(TimelinesVM.class);
                        timelinesVM.addMarker(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, null, notification.id);
                    }
                } catch (Exception ignored) {
                }
            }
        }
    }

    /**
     * Update view and pagination when scrolling down
@@ -535,11 +554,15 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
    @Override
    public void onDestroyView() {
        LocalBroadcastManager.getInstance(requireActivity()).unregisterReceiver(receive_action);
        if (isAdded()) {
            storeMarker();
        }
        super.onDestroyView();
    }

    @Override
    public void onPause() {
        storeMarker();
        super.onPause();
    }

+4 −3
Original line number Diff line number Diff line
@@ -596,7 +596,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.


    private void storeMarker() {
        if (timelineType == Timeline.TimeLineEnum.HOME && mLayoutManager != null) {
        if (mLayoutManager != null) {
            int position = mLayoutManager.findFirstVisibleItemPosition();
            if (timelineStatuses != null && timelineStatuses.size() > position) {
                try {
@@ -605,8 +605,9 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
                    SharedPreferences.Editor editor = sharedpreferences.edit();
                    editor.putString(getString(R.string.SET_INNER_MARKER) + BaseMainActivity.currentUserID + BaseMainActivity.currentInstance + slug, status.id);
                    editor.apply();
                    if (timelineType == Timeline.TimeLineEnum.HOME) {
                        timelinesVM.addMarker(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, status.id, null);

                    }
                } catch (Exception ignored) {
                }
            }