更新时间: 2021-04-16
# 功能描述
RongConfigCenter.conversationListConfig() 为会话列表页统一配置入口,支持如下功能。
- 所有配置相关方法在 Application 内设置一次即可。
- 在 init() 之后配置。
# 数据处理器
通过 setDataProcessor() 可以对会话列表数据进行预处理,设置数据是否聚合显示,是否被过滤。
# 参数说明
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
dataWrapper | DataProcessor | 是 | 数据预处理器 |
# 示例代码
RongConfigCenter.conversationListConfig().setDataProcessor(new DataProcessor<Conversation>() { /** * 设置会话列表页支持的会话类型 * @return 所支持的会话类型 */ @Override public Conversation.ConversationType[] supportedTypes() { Conversation.ConversationType[] supportedTypes = {Conversation.ConversationType.PRIVATE, Conversation.ConversationType.GROUP, Conversation.ConversationType.SYSTEM, Conversation.ConversationType.APP_PUBLIC_SERVICE, Conversation.ConversationType.PUBLIC_SERVICE, }; return supportedTypes; } /** * 对会话数据进行过滤。 * <p>从数据库批量拉取到会话列表时和在线收到消息产生新会话时都会回调此方法</p> * @param data 待过滤的数据 * @return 过滤完的数据。 */ @Override public List<Conversation> filtered(List<Conversation> data) { for(Conversation conversation : data) { if(conversation.getConversationType().equals(Conversation.ConversationType.GROUP) && conversation.getTargetId().equals("XXX")) { data.remove(conversation); //此处以过滤 "XXX" 这个群组会话为例。 } } return data; } /** * 某一会话类型是否聚合状态显示。 * @param type 会话类型 * @return 该会话类型是否聚合显示。 */ @Override public boolean isGathered(Conversation.ConversationType type) { if (type.equals(Conversation.ConversationType.SYSTEM)) { return true; //以配置系统会话聚合显示为例 } else { return false; } } });
已复制
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# 事件监听
设置会话列表页面各种点击事件的监听。
# 参数说明
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
listener | ConversationListBehaviorListener | 是 | 监听回调 |
# 示例代码
RongConfigCenter.conversationListConfig().setConversationListBehaviorListener(new ConversationListBehaviorListener() { /** * 会话头像点击监听 * * @param context 上下文。 * @param conversationType 会话类型。 * @param targetId 被点击的用户id。 * @return true 拦截事件, false 执行融云 SDK 内部默认处理逻辑 */ @Override public boolean onConversationPortraitClick(Context context, Conversation.ConversationType conversationType, String targetId) { return false; } /** * 会话头像长按监听 * * @param context 上下文。 * @param conversationType 会话类型。 * @param targetId 被点击的用户id。 * @return true 拦截事件, false 执行融云 SDK 内部默认处理逻辑 */ @Override public boolean onConversationPortraitLongClick(Context context, Conversation.ConversationType conversationType, String targetId) { return false; } /** * 会话列表中的 Item 长按监听 * * @param context 上下文。 * @param view 触发点击的 View。 * @param conversation 长按时的会话条目 * @return true 拦截事件, false 执行融云 SDK 内部默认处理逻辑 */ @Override public boolean onConversationLongClick(Context context, View view, BaseUiConversation conversation) { return false; } /** * 会话列表中的 Item 点击监听 * * @param context 上下文。 * @param view 触发点击的 View。 * @param conversation 长按时的会话条目 * @return true 拦截事件, false 执行融云 SDK 内部默认处理逻辑 */ @Override public boolean onConversationClick(Context context, View view, BaseUiConversation conversation) { return false; } });
已复制
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51