From 5a0411179174c6a91449412a2af48a29ae678bcd Mon Sep 17 00:00:00 2001 From: imndx Date: Fri, 11 Oct 2019 15:11:04 +0800 Subject: [PATCH] only group owner or manager can mention all --- .../mention/MentionGroupMemberFragment.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/chat/kit/src/main/java/cn/wildfire/chat/kit/conversation/mention/MentionGroupMemberFragment.java b/chat/kit/src/main/java/cn/wildfire/chat/kit/conversation/mention/MentionGroupMemberFragment.java index 322e8214c..f805230ba 100644 --- a/chat/kit/src/main/java/cn/wildfire/chat/kit/conversation/mention/MentionGroupMemberFragment.java +++ b/chat/kit/src/main/java/cn/wildfire/chat/kit/conversation/mention/MentionGroupMemberFragment.java @@ -14,9 +14,13 @@ import cn.wildfire.chat.kit.contact.model.UIUserInfo; import cn.wildfire.chat.kit.group.GroupViewModel; import cn.wildfirechat.model.GroupInfo; +import cn.wildfirechat.model.GroupMember; +import cn.wildfirechat.remote.ChatManager; public class MentionGroupMemberFragment extends BaseUserListFragment { private GroupInfo groupInfo; + private GroupMember groupMember; + private GroupViewModel groupViewModel; public static MentionGroupMemberFragment newInstance(GroupInfo groupInfo) { Bundle args = new Bundle(); @@ -29,14 +33,15 @@ public static MentionGroupMemberFragment newInstance(GroupInfo groupInfo) { @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); - groupInfo = getArguments().getParcelable("groupInfo"); showQuickIndexBar(true); + groupInfo = getArguments().getParcelable("groupInfo"); + groupViewModel = ViewModelProviders.of(getActivity()).get(GroupViewModel.class); + groupMember = groupViewModel.getGroupMember(groupInfo.target, ChatManager.Instance().getUserId()); } @Override protected void afterViews(View view) { super.afterViews(view); - GroupViewModel groupViewModel = ViewModelProviders.of(getActivity()).get(GroupViewModel.class); groupViewModel.getGroupMemberUIUserInfosLiveData(groupInfo.target, false).observe(this, uiUserInfos -> { showContent(); userListAdapter.setUsers(uiUserInfos); @@ -50,7 +55,11 @@ public UserListAdapter onCreateUserListAdapter() { @Override public void initHeaderViewHolders() { - addHeaderViewHolder(MentionAllHeaderViewHolder.class, new HeaderValue()); + if (groupMember != null) { + if (groupMember.type == GroupMember.GroupMemberType.Manager || groupMember.type == GroupMember.GroupMemberType.Owner) { + addHeaderViewHolder(MentionAllHeaderViewHolder.class, new HeaderValue()); + } + } } @Override