亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

插件化-插件APK的解析

標簽:
Android

融云设置已读,未读消息标识

需求:会话列表,以及会话界面发出去的消息前面加上已读,未读的标识

官方给的解决方案

1、您可以通过 rc_config.xml 里的开关,开启消息的阅读回执功能。默认 false 为关闭状态,设置成 true 为开启
2、请在 init 之后调用下面方法来设置支持消息回执的会话类型。目前只支持 PRIVATE、GROUP 和 DISCUSSION 三种类型
官方还有一个说的更详细的文档,忘了在哪里,找不到了

官方的没法解决我的需求,就算它能显示也不是我想要的。

处理会话界面

1、自定义类继承自 MessageListAdpater, 然后重写其中的 holder.sentStatus

2、布局是 rc_item_message.xml

3、自定义类集成自 ConversationFragment,然后重写onResolveAdpater 中得到自定义adpter并返回
参考代码

public class MyMessageListAdapter extends MessageListAdapter {public MyMessageListAdapter(Context context) {    super(context);
}@Overrideprotected void bindView(View v, int position, UIMessage data) {    super.bindView(v, position, data);    if(data != null){        final MessageListAdapter.ViewHolder holder = (MessageListAdapter.ViewHolder) v.getTag();        if(holder != null){            if (data.getMessageDirection().equals(Message.MessageDirection.RECEIVE)) {
                holder.sentStatus.setVisibility(View.GONE);
            } else {
                LogUtils.i("msgStatus", data.getSentStatus().getValue() + "");                if (data.getSentStatus() == Message.SentStatus.SENT) {
                    holder.sentStatus.setCompoundDrawablesWithIntrinsicBounds(v.getContext().getResources().getDrawable(R.mipmap.ic_msg_sent),null,null,null);
                    holder.sentStatus.setText(R.string.im_msg_sent);
                    holder.sentStatus.setVisibility(View.VISIBLE);
                } else if (data.getSentStatus() == Message.SentStatus.READ) {
                    holder.sentStatus.setText(R.string.im_msg_read);
                    holder.sentStatus.setCompoundDrawablesWithIntrinsicBounds(v.getContext().getResources().getDrawable(R.mipmap.ic_msg_read),null,null,null);
                    holder.sentStatus.setVisibility(View.VISIBLE);

                }
            }
        }

    }


}}

敲黑板:rc_config.xml 里的开关,开启消息的阅读回执功能。默认 false 为关闭状态,设置成 true 为开启 ,如果能正常显示最好,不能正常显示,需要在会话界面自己发送阅读回执。

处理会话列表界面

集成 PrivateConversationProvider  然后重新 bindView 方法, 然后在此方法中 根据 Message.SentStatus来进行修改显示内容
参考代码:

@ConversationProviderTag(
conversationType = "private",
portraitPosition = 1)public class MyPrivateConversationProvider extends PrivateConversationProvider {@Overridepublic void bindView(View view, int position, UIConversation data) {    super.bindView(view, position, data);
    PrivateConversationProvider.ViewHolder holder = (PrivateConversationProvider.ViewHolder)view.getTag();        if(null != data && data.getConversationSenderId() != null && data.getConversationSenderId().equals(RongIM.getInstance().getCurrentUserId())){            if(data.getSentStatus() != null){                if(data.getSentStatus() == Message.SentStatus.FAILED || data.getSentStatus() == Message.SentStatus.SENDING){
                    holder.readStatus.setVisibility(View.GONE);
                } else {                    if(data.getSentStatus() == Message.SentStatus.SENT){
                        holder.readStatus.setImageResource(R.mipmap.ic_msg_sent);
                        holder.readStatus.setVisibility(View.VISIBLE);
                    } else if(data.getSentStatus() == Message.SentStatus.READ){
                        holder.readStatus.setImageResource(R.mipmap.ic_msg_read);
                        holder.readStatus.setVisibility(View.VISIBLE);
                    }
                }
            }

        }

}}



作者:你的益达233
链接:https://www.jianshu.com/p/ba080e90ad98


點擊查看更多內容
TA 點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優質文章

正在加載中
JAVA開發工程師
手記
粉絲
205
獲贊與收藏
1011

關注作者,訂閱最新文章

閱讀免費教程

  • 推薦
  • 評論
  • 收藏
  • 共同學習,寫下你的評論
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

舉報

0/150
提交
取消