|
@@ -35,6 +35,7 @@ import io.reactivex.Observable;
|
|
|
import io.reactivex.disposables.Disposable;
|
|
|
import io.reactivex.functions.Function;
|
|
|
import io.reactivex.internal.disposables.ListCompositeDisposable;
|
|
|
+import io.rong.imlib.RongIMClient;
|
|
|
import io.rong.imlib.model.Conversation;
|
|
|
import io.rong.imlib.model.MessageContent;
|
|
|
import io.rong.imlib.model.UnknownMessage;
|
|
@@ -89,15 +90,43 @@ public class MessageListAdapter extends BaseQuickAdapter<ConversationListVo, Bas
|
|
|
Conversation conversation = vo.getConversation();
|
|
|
if (conversation == null) return;
|
|
|
int unreadMessageCount = conversation.getUnreadMessageCount();
|
|
|
+ TextView tvCount = helper.getView(R.id.tv_item_msg_count);
|
|
|
String unreadCountString = String.valueOf(unreadMessageCount);
|
|
|
if (unreadMessageCount > 99) unreadCountString = "99+";
|
|
|
- TextView tvCount = helper.getView(R.id.tv_item_msg_count);
|
|
|
tvCount.setText(unreadCountString);
|
|
|
tvCount.setVisibility(unreadMessageCount > 0 ? View.VISIBLE : View.INVISIBLE);
|
|
|
+ } else if (i == 444) {
|
|
|
+ Conversation conversation = vo.getConversation();
|
|
|
+ if (conversation == null) return;
|
|
|
+ TextView tvCount = helper.getView(R.id.tv_item_msg_count);
|
|
|
+ getUnReadCount(conversation.getConversationType(), conversation.getTargetId(), tvCount);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void getUnReadCount(Conversation.ConversationType type, String id, TextView tvCount) {
|
|
|
+ if (!AppManager.get().isConnectRongCloud()) return;
|
|
|
+ RongIMClient.getInstance().getUnreadCount(type, id, new RongIMClient.ResultCallback<Integer>() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(Integer count) {
|
|
|
+ if (count != null) {
|
|
|
+ String num;
|
|
|
+ if (count > 99) {
|
|
|
+ num = "99+";
|
|
|
+ } else {
|
|
|
+ num = "" + count;
|
|
|
+ }
|
|
|
+ tvCount.setText(num);
|
|
|
+ tvCount.setVisibility(count > 0 ? View.VISIBLE : View.INVISIBLE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(RongIMClient.ErrorCode errorCode) {
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
protected void convert(@NonNull BaseViewHolder helper, ConversationListVo vo) {
|
|
|
Conversation conversation = vo.getConversation();
|