forked from upstream-mirrors/quik
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…
This commit is contained in:
@@ -589,12 +589,12 @@ public class MessageListAdapter extends RecyclerCursorAdapter<MessageListViewHol
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void changeCursor(Cursor cursor) {
|
public void changeCursor(Cursor cursor) {
|
||||||
super.changeCursor(cursor);
|
|
||||||
|
|
||||||
if (CursorUtils.isValid(cursor)) {
|
if (CursorUtils.isValid(cursor)) {
|
||||||
mColumnsMap = new MessageColumns.ColumnsMap(cursor);
|
mColumnsMap = new MessageColumns.ColumnsMap(cursor);
|
||||||
mMessageItemCache = new MessageItemCache(mContext, mColumnsMap, mSearchHighlighter, MessageColumns.CACHE_SIZE);
|
mMessageItemCache = new MessageItemCache(mContext, mColumnsMap, mSearchHighlighter, MessageColumns.CACHE_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
super.changeCursor(cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -134,7 +134,6 @@ public class MessageListFragment extends QKFragment implements ActivityLauncher,
|
|||||||
// If the value >= 0, then we jump to that line. If the
|
// If the value >= 0, then we jump to that line. If the
|
||||||
// value is maxint, then we jump to the end.
|
// value is maxint, then we jump to the end.
|
||||||
|
|
||||||
private long mLastMessageId;
|
|
||||||
private BackgroundQueryHandler mBackgroundQueryHandler;
|
private BackgroundQueryHandler mBackgroundQueryHandler;
|
||||||
|
|
||||||
private long mThreadId;
|
private long mThreadId;
|
||||||
@@ -208,6 +207,7 @@ public class MessageListFragment extends QKFragment implements ActivityLauncher,
|
|||||||
mAdapter.setItemClickListener(this);
|
mAdapter.setItemClickListener(this);
|
||||||
mAdapter.setMultiSelectListener(this);
|
mAdapter.setMultiSelectListener(this);
|
||||||
mAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
|
mAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
|
||||||
|
private long mLastMessageId = -1;
|
||||||
@Override
|
@Override
|
||||||
public void onChanged() {
|
public void onChanged() {
|
||||||
LinearLayoutManager manager = (LinearLayoutManager) mRecyclerView.getLayoutManager();
|
LinearLayoutManager manager = (LinearLayoutManager) mRecyclerView.getLayoutManager();
|
||||||
@@ -225,8 +225,15 @@ public class MessageListFragment extends QKFragment implements ActivityLauncher,
|
|||||||
position = mAdapter.getItemCount() - 1;
|
position = mAdapter.getItemCount() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (position != -1) {
|
if(mAdapter.getCount() > 0) {
|
||||||
manager.smoothScrollToPosition(mRecyclerView, null, position);
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -941,10 +948,6 @@ public class MessageListFragment extends QKFragment implements ActivityLauncher,
|
|||||||
mConversation.setMessageCount(0);
|
mConversation.setMessageCount(0);
|
||||||
// fall through
|
// fall through
|
||||||
case DELETE_MESSAGE_TOKEN:
|
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.
|
// Update the notification for new messages since they may be deleted.
|
||||||
NotificationManager.update(mContext);
|
NotificationManager.update(mContext);
|
||||||
|
|||||||
Reference in New Issue
Block a user