欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 教育 > 锐评 > Android开发融云获取多个会话的总未读数

Android开发融云获取多个会话的总未读数

2026/5/2 22:14:15 来源:https://blog.csdn.net/u010074743/article/details/146801812  浏览:    关键词:Android开发融云获取多个会话的总未读数
Android开发融云获取多个会话的总未读数

融云没有获取多个会话总未读数的api,只有获取单个会话的未读数。这样我只能通过递归获取。

private void secretLetterUnReadCount(final List<String> targetIds, final List<Integer> greetUnCount, final int unReadCount, final TextView unread){if(Utils.isNotNull(targetIds) && targetIds.size() > 0){RongIM.getInstance().getUnreadCount(Conversation.ConversationType.PRIVATE, targetIds.get(0), new RongIMClient.ResultCallback<Integer>() {@Overridepublic void onSuccess(Integer integer) {if(unReadCount == -1){greetUnCount.set(0,greetUnCount.get(0) + integer);}else {greetUnCount.set(1,greetUnCount.get(1) + 1);}targetIds.remove(0);secretLetterUnReadCount(targetIds, greetUnCount, unReadCount, tv_content, unread);}@Overridepublic void onError(RongIMClient.ErrorCode errorCode) {targetIds.remove(0);secretLetterUnReadCount(targetIds, greetUnCount, unReadCount, tv_content, unread);}});}else {if(unReadCount == -1){if(greetUnCount.get(0) > 0){secretLetterUnReadCount(SPNoCleanUtil.getSecretReceiveSet() , greetUnCount, greetUnCount.get(0), tv_content, unread);} else {unread.setVisibility(View.GONE);}}else {if(!(unReadCount + "").equals(unread.getText().toString())){unread.setText(unReadCount > 99 ? "99+" : unReadCount + "");}if(unread.getVisibility() != View.VISIBLE){unread.setVisibility(View.VISIBLE);}}}}

调用:

secretLetterUnReadCount(SPNoCleanUtil.getSecretReceiveSet(), secretLetterUnCount, -1, ((TextView)holder.getView(R.id.tv_unread_count)));

其中SPNoCleanUtil.getSecretReceiveSet()就是你的多个会话的集合它是List的,secretLetterUnCount默认是0,tv_unread_count就是你的TextView控件

还有问题可以评论或者私信我

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词