jump to first unread message if was scrolled to bottom earlier
This commit is contained in:
parent
acc47fbeda
commit
13322a568a
|
@ -1701,6 +1701,12 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
return false;
|
||||
}
|
||||
Log.d(Config.LOGTAG,"reInit(hasExtras="+Boolean.toString(hasExtras)+")");
|
||||
|
||||
if (this.conversation.isRead() && hasExtras) {
|
||||
Log.d(Config.LOGTAG,"trimming conversation");
|
||||
this.conversation.trim();
|
||||
}
|
||||
|
||||
setupIme();
|
||||
|
||||
this.binding.textSendButton.setContentDescription(activity.getString(R.string.send_message_to_x, conversation.getName()));
|
||||
|
@ -1712,7 +1718,11 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
refresh(false);
|
||||
this.conversation.messagesLoaded.set(true);
|
||||
|
||||
if (hasExtras) {
|
||||
final boolean scrolledToBottomAndNoPending = this.scrolledToBottom() && pendingScrollState.peek() == null;
|
||||
|
||||
Log.d(Config.LOGTAG,"scrolledToBottomAndNoPending="+Boolean.toString(scrolledToBottomAndNoPending));
|
||||
|
||||
if (hasExtras || scrolledToBottomAndNoPending) {
|
||||
synchronized (this.messageList) {
|
||||
Log.d(Config.LOGTAG,"jump to first unread message");
|
||||
final Message first = conversation.getFirstUnreadMessage();
|
||||
|
@ -1735,6 +1745,11 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
return true;
|
||||
}
|
||||
|
||||
private boolean scrolledToBottom() {
|
||||
final ListView l = this.binding.messagesView;
|
||||
return l.getLastVisiblePosition() == l.getAdapter().getCount() -1 && l.getChildAt(l.getChildCount() - 1).getBottom() <= l.getHeight();
|
||||
}
|
||||
|
||||
private void processExtras(Bundle extras) {
|
||||
final String downloadUuid = extras.getString(ConversationActivity.EXTRA_DOWNLOAD_UUID);
|
||||
final String text = extras.getString(ConversationActivity.EXTRA_TEXT);
|
||||
|
|
Loading…
Reference in a new issue