Improved method to display last event time and sort chat rooms
This commit is contained in:
parent
a001ebf871
commit
3be49ea97e
2 changed files with 3 additions and 13 deletions
|
@ -90,11 +90,7 @@ public class ChatRoomsAdapter extends ListSelectionAdapter {
|
||||||
mRooms = new ArrayList<>(Arrays.asList(LinphoneManager.getLc().getChatRooms()));
|
mRooms = new ArrayList<>(Arrays.asList(LinphoneManager.getLc().getChatRooms()));
|
||||||
Collections.sort(mRooms, new Comparator<ChatRoom>() {
|
Collections.sort(mRooms, new Comparator<ChatRoom>() {
|
||||||
public int compare(ChatRoom cr1, ChatRoom cr2) {
|
public int compare(ChatRoom cr1, ChatRoom cr2) {
|
||||||
EventLog cr1Logs[] = cr1.getHistoryEvents(1);
|
long timeDiff = cr1.getLastUpdateTime() - cr2.getLastUpdateTime();
|
||||||
EventLog cr2Logs[] = cr2.getHistoryEvents(1);
|
|
||||||
if (cr1Logs.length <= 0) return 1;
|
|
||||||
if (cr2Logs.length <= 0) return -1;
|
|
||||||
long timeDiff = cr1Logs[0].getCreationTime() - cr2Logs[0].getCreationTime();
|
|
||||||
if (timeDiff > 0) return -1;
|
if (timeDiff > 0) return -1;
|
||||||
else if (timeDiff == 0) return 0;
|
else if (timeDiff == 0) return 0;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -151,13 +147,7 @@ public class ChatRoomsAdapter extends ListSelectionAdapter {
|
||||||
int unreadMessagesCount = chatRoom.getUnreadMessagesCount();
|
int unreadMessagesCount = chatRoom.getUnreadMessagesCount();
|
||||||
ChatMessage lastMessage = chatRoom.getLastMessageInHistory();
|
ChatMessage lastMessage = chatRoom.getLastMessageInHistory();
|
||||||
holder.lastMessageView.setText("");
|
holder.lastMessageView.setText("");
|
||||||
holder.date.setText("");
|
holder.date.setText(LinphoneUtils.timestampToHumanDate(mContext, chatRoom.getLastUpdateTime(), R.string.messages_list_date_format));
|
||||||
|
|
||||||
EventLog[] lastEvent = chatRoom.getHistoryEvents(1);
|
|
||||||
if (lastEvent.length > 0) {
|
|
||||||
time = lastEvent[0].getCreationTime();
|
|
||||||
holder.date.setText(LinphoneUtils.timestampToHumanDate(mContext, time, R.string.messages_list_date_format));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lastMessage != null) {
|
if (lastMessage != null) {
|
||||||
if (lastMessage.getFileTransferInformation() != null || lastMessage.getExternalBodyUrl() != null || lastMessage.getAppdata() != null) {
|
if (lastMessage.getFileTransferInformation() != null || lastMessage.getExternalBodyUrl() != null || lastMessage.getAppdata() != null) {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 107aa11e139df6b3ab76f18930e75b9129bcbad7
|
Subproject commit 9f5a74bd4232c14d9be52dd81aea4bf4cc03402b
|
Loading…
Reference in a new issue