Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4d2b72dd authored by Moez Bhatti's avatar Moez Bhatti Committed by GitHub
Browse files

Merge pull request #588 from...

Merge pull request #588 from StephaneBausseron/fix-scroll-to-botton-on-sms-reception-on-another-conversation

Does not scroll to bottom of current conversation if no new SMS are r…
parents e2e22836 abd57858
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -589,12 +589,12 @@ public class MessageListAdapter extends RecyclerCursorAdapter<MessageListViewHol

    @Override
    public void changeCursor(Cursor cursor) {
        super.changeCursor(cursor);

        if (CursorUtils.isValid(cursor)) {
            mColumnsMap = new MessageColumns.ColumnsMap(cursor);
            mMessageItemCache = new MessageItemCache(mContext, mColumnsMap, mSearchHighlighter, MessageColumns.CACHE_SIZE);
        }

        super.changeCursor(cursor);
    }

    @Override
+10 −7
Original line number Diff line number Diff line
@@ -134,7 +134,6 @@ public class MessageListFragment extends QKFragment implements ActivityLauncher,
    // If the value >= 0, then we jump to that line. If the
    // value is maxint, then we jump to the end.

    private long mLastMessageId;
    private BackgroundQueryHandler mBackgroundQueryHandler;

    private long mThreadId;
@@ -208,6 +207,7 @@ public class MessageListFragment extends QKFragment implements ActivityLauncher,
        mAdapter.setItemClickListener(this);
        mAdapter.setMultiSelectListener(this);
        mAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
            private long mLastMessageId = -1;
            @Override
            public void onChanged() {
                LinearLayoutManager manager = (LinearLayoutManager) mRecyclerView.getLayoutManager();
@@ -225,10 +225,17 @@ public class MessageListFragment extends QKFragment implements ActivityLauncher,
                    position = mAdapter.getItemCount() - 1;
                }

                if(mAdapter.getCount() > 0) {
                    MessageItem lastMessage = mAdapter.getItem(mAdapter.getCount() - 1);
                    if (mLastMessageId >= 0 && mLastMessageId != lastMessage.getMessageId()) {
                        // Scroll to bottom only if a new message was inserted in this conversation
                        if (position != -1) {
                            manager.smoothScrollToPosition(mRecyclerView, null, position);
                        }
                    }
                    mLastMessageId = lastMessage.getMessageId();
                }
            }
        });

        mRecyclerView.setAdapter(mAdapter);
@@ -941,10 +948,6 @@ public class MessageListFragment extends QKFragment implements ActivityLauncher,
                    mConversation.setMessageCount(0);
                    // fall through
                case DELETE_MESSAGE_TOKEN:
                    if (cookie instanceof Boolean && ((Boolean) cookie).booleanValue()) {
                        // If we just deleted the last message, reset the saved id.
                        mLastMessageId = 0;
                    }

                    // Update the notification for new messages since they may be deleted.
                    NotificationManager.update(mContext);