mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Add "go to last seen" (#1641)
This commit is contained in:
@@ -126,7 +126,10 @@ public class ConversationAdapter <V extends View & BindableConversationItem>
|
||||
|
||||
public void updateLastSeenPosition() {
|
||||
this.lastSeenPosition = findLastSeenPosition(lastSeen);
|
||||
}
|
||||
|
||||
void setLastSeenPosition(int pos) {
|
||||
lastSeenPosition = pos;
|
||||
}
|
||||
|
||||
public int getLastSeenPosition() {
|
||||
|
||||
@@ -172,6 +172,12 @@ public class ConversationFragment extends Fragment
|
||||
super.onActivityCreated(bundle);
|
||||
initializeResources();
|
||||
initializeListAdapter();
|
||||
|
||||
int freshMsgs = dcContext.getFreshMsgCount((int) chatId);
|
||||
if (freshMsgs > 0) {
|
||||
setLastSeenPosition(freshMsgs - 1);
|
||||
moveToLastSeen();
|
||||
}
|
||||
}
|
||||
|
||||
private void setNoMessageText() {
|
||||
@@ -269,7 +275,7 @@ public class ConversationFragment extends Fragment
|
||||
if (getListAdapter().getLastSeenPosition() < 0) {
|
||||
return;
|
||||
}
|
||||
scrollToLastSeenPosition(getListAdapter().getLastSeenPosition());
|
||||
scrollToLastSeenPosition(getListAdapter().getLastSeenPosition() + 1);
|
||||
}
|
||||
|
||||
private void initializeResources() {
|
||||
@@ -350,14 +356,24 @@ public class ConversationFragment extends Fragment
|
||||
}
|
||||
}
|
||||
|
||||
public void setLastSeen(long lastSeen) {
|
||||
void setLastSeen(long lastSeen) {
|
||||
getListAdapter().setLastSeen(lastSeen);
|
||||
if (lastSeenDecoration != null) {
|
||||
list.removeItemDecoration(lastSeenDecoration);
|
||||
}
|
||||
|
||||
if (lastSeen > 0) {
|
||||
lastSeenDecoration = new ConversationAdapter.LastSeenHeader(getListAdapter()/*, lastSeen*/);
|
||||
lastSeenDecoration = new ConversationAdapter.LastSeenHeader(getListAdapter());
|
||||
list.addItemDecoration(lastSeenDecoration);
|
||||
}
|
||||
}
|
||||
|
||||
private void setLastSeenPosition(int position) {
|
||||
getListAdapter().setLastSeenPosition(position);
|
||||
if (lastSeenDecoration != null) {
|
||||
list.removeItemDecoration(lastSeenDecoration);
|
||||
}
|
||||
if (position >= 0) {
|
||||
lastSeenDecoration = new ConversationAdapter.LastSeenHeader(getListAdapter());
|
||||
list.addItemDecoration(lastSeenDecoration);
|
||||
}
|
||||
}
|
||||
@@ -561,14 +577,12 @@ public class ConversationFragment extends Fragment
|
||||
boolean currentlyAtZoomScrollHeight = isAtZoomScrollHeight();
|
||||
// int positionId = getHeaderPositionId();
|
||||
|
||||
if (currentlyAtBottom && !wasAtBottom) {
|
||||
ViewUtil.animateOut(scrollToBottomButton, scrollButtonOutAnimation, View.INVISIBLE);
|
||||
}
|
||||
|
||||
if (currentlyAtZoomScrollHeight && !wasAtZoomScrollHeight) {
|
||||
ViewUtil.animateIn(scrollToBottomButton, scrollButtonInAnimation);
|
||||
} else if (currentlyAtBottom && !wasAtBottom) {
|
||||
ViewUtil.animateOut(scrollToBottomButton, scrollButtonOutAnimation, View.INVISIBLE);
|
||||
}
|
||||
|
||||
|
||||
// if (positionId != lastPositionId) {
|
||||
// bindScrollHeader(conversationDateHeader, positionId);
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user