融云即时通讯的自定义会话列表
来源:互联网 发布:淘宝店铺怎么关闭 编辑:程序博客网 时间:2024/06/06 00:56
集成了融云的会话列表,本以为万事大吉了但是我们的项目有夜间模式呀.....有木有很坑.好吧我还是乖乖的做夜间模式吧
1.自定义会话列表adapter继承ConversationListAdapter
因为我只是想改变item的背景颜色,自定义的内容不是很多.因此只展示这些.其他需求的话在重写的newView中可以换成自己的布局.,重写item的layout.
在bindView方法中可以把数据绑定给自己重写的布局.大家根据自己的需求看着来吧.
public class ConversationListAdapterEx extends ConversationListAdapter { private Context context; public ConversationListAdapterEx(Context context) { super(context); this.context = context; } @Override protected View newView(Context context, int position, ViewGroup group) { return super.newView(context, position, group); } @Override protected void bindView(View v, int position, UIConversation data) { super.bindView(v, position, data); if(data.getConversationType().equals(Conversation.ConversationType.DISCUSSION)) { data.setUnreadType(UIConversation.UnreadRemindType.REMIND_ONLY); } if(SharedPreferencesUtil.isNightModel(context)){ v.setBackgroundColor(context.getResources().getColor(R.color.colorBlack)); }else{ v.setBackgroundColor(context.getResources().getColor(R.color.colorWhite)); } }}
2.因为动态加载fragment.将刚刚自定义的adapter设置给ConversationListFragment,这个fragment是融云的类.
conversationListFragment.setAdapter(newConversationListAdapterEx(RongContext.getInstance()));
private void AddConversationListFragment(){ //会话列表 conversationListFragment.setAdapter(new ConversationListAdapterEx(RongContext.getInstance())); Uri uri = Uri.parse("rong://" + getActivity().getApplicationInfo().packageName).buildUpon() .appendPath("conversationlist") .appendQueryParameter(Conversation.ConversationType.PRIVATE.getName(), "false") //设置私聊会话,该会话聚合不显示 .build(); conversationListFragment.setUri(uri); FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.add(R.id.rong_container,conversationListFragment); transaction.commit(); }
至此会话列表上的背景变成了黑色在夜间模式下,但是ConversationListFragment的北京是白的.....聪明的我去修改了会话列表fragment'的布局R.layour.rc_fr_conversationlist.xml,将其背景置为透明.这样ConversationListFragment的父fragmet,也就是我自己的fragment的夜间模式就可以显示出来了.
还有就是切换账号的时候会话列表的数据混乱.切换后重新加载一遍ConversationListFragment
删除会话列表的某一条数据 :
private void removeList(String mid){ RongIM.getInstance().getRongIMClient().removeConversation(Conversation.ConversationType.PRIVATE, mid, new RongIMClient.ResultCallback<Boolean>() { @Override public void onSuccess(Boolean aBoolean) { Log.e("onSuccess","你已经删除了会话列表上用户id为mid的人"); } @Override public void onError(RongIMClient.ErrorCode errorCode) { Log.e("onError","onError"+errorCode.getMessage()); } }); }
阅读全文
0 0
- 融云即时通讯的自定义会话列表
- 融云基于IMkit自定义会话列表
- android 即时通讯 容云集成 融云会话界面 融云会话列表 头像和昵称设置
- iOS-OC-自定义融云会话列表(自定义cell)
- Android融云会话及会话列表的实现
- 重写融云会话列表
- 融云集成4--会话列表,会话界面的集成
- 融云集成2--用户信息在会话列表和会话界面的显示
- 基于融云的即时通讯开发(一)
- iOS - 融云即时通讯的简单使用
- 即时通讯云的调研
- iOS-融云即时通讯
- 融云即时通讯
- ios--融云即时通讯
- 融云即时通讯
- 融云即时通讯
- 融云即时通讯集成
- 融云即时通讯
- redis centos 安装
- 文章标题
- BZOJ 1588 [HNOI2002]营业额统计(Splay)
- HDU1166(敌兵布阵)
- jmeter用正则表达式获取token并使用
- 融云即时通讯的自定义会话列表
- java中两个Integer类型的值相比较的问题
- Git详解之九 Git内部原理
- 同一台服务器上安装mysql5.5和mysql5.7 不同版本的实例
- 硬件管理 远程开机,网络开机
- 迷宫问题,另辟蹊径,不用递归不用栈
- 在使用git bash时,报错:segmentation fault
- [Amazon] Second Max of Array
- Vue大括号字符换行踩的坑