protected void updateReadStatus () { if (message != null) { int resource = R.drawable.ic_message_received; ReadStatus status = message.getReadStatus(); // Hide the read receipt for public threads if(message.getThread().typeIs(ThreadType.Public) || ChatSDK.readReceipts() == null) { status = ReadStatus.hide(); } if(status.is(ReadStatus.delivered())) { resource = R.drawable.ic_message_delivered; } if(status.is(ReadStatus.read())) { resource = R.drawable.ic_message_read; } if(readReceiptImageView != null) { readReceiptImageView.setImageResource(resource); readReceiptImageView.setVisibility(status.is(ReadStatus.hide()) ? View.INVISIBLE : View.VISIBLE); } } }
public boolean isRead() { ReadStatus status = readStatusForUser(ChatSDK.currentUser()); if (status != null && status.is(ReadStatus.read())) { return true; } else if (sender != null && sender.isMe()) { return true; } else if (read == null) { return false; } else { return read; } }
public void handleLocalNotifications () { if (localNotificationDisposable != null) { localNotificationDisposable.dispose(); } // TODO: Check this localNotificationDisposable = ChatSDK.events().sourceOnMain() .filter(NetworkEvent.filterType(EventType.MessageAdded)) .subscribe(networkEvent -> { Message message = networkEvent.message; Thread thread = networkEvent.thread; if(message != null && !AppBackgroundMonitor.shared().inBackground()) { if (thread.typeIs(ThreadType.Private) || (thread.typeIs(ThreadType.Public) && ChatSDK.config().pushNotificationsForPublicChatRoomsEnabled)) { if(!message.getSender().isMe() && ChatSDK.ui().showLocalNotifications(message.getThread())) { ReadStatus status = message.readStatusForUser(ChatSDK.currentUser()); if (!message.isRead() && !status.is(ReadStatus.delivered())) { // Only show the alert if we'recyclerView not on the private threads tab ChatSDK.ui().notificationDisplayHandler().createMessageNotification(message); } } } } }); }