@@ -233,6 +233,22 @@ public void onFail(int errorCode) {
233233 return result ;
234234 }
235235
236+ public MutableLiveData <OperateResult <Boolean >> muteGroupMember (String groupId , boolean mute , List <String > memberIds , NotificationMessageContent notifyMsg , List <Integer > lines ) {
237+ MutableLiveData <OperateResult <Boolean >> result = new MutableLiveData <>();
238+ ChatManager .Instance ().muteGroupMember (groupId , mute , memberIds , lines , notifyMsg , new GeneralCallback () {
239+ @ Override
240+ public void onSuccess () {
241+ result .setValue (new OperateResult <>(0 ));
242+ }
243+
244+ @ Override
245+ public void onFail (int errorCode ) {
246+ result .setValue (new OperateResult <>(errorCode ));
247+ }
248+ });
249+ return result ;
250+ }
251+
236252 public MutableLiveData <OperateResult <Boolean >> muteAll (String groupId , boolean mute , MessageContent notifyMsg , List <Integer > notifyLines ) {
237253 MutableLiveData <OperateResult <Boolean >> result = new MutableLiveData <>();
238254 ChatManager .Instance ().modifyGroupInfo (groupId , ModifyGroupInfoType .Modify_Group_Mute , mute ? "1" : "0" , notifyLines , notifyMsg , new GeneralCallback () {
@@ -319,8 +335,19 @@ public MutableLiveData<List<GroupMember>> getGroupMembersLiveData(String groupId
319335 public MutableLiveData <List <UIUserInfo >> getGroupManagerUIUserInfosLiveData (String groupId , boolean refresh ) {
320336 MutableLiveData <List <UIUserInfo >> data = new MutableLiveData <>();
321337 ChatManager .Instance ().getWorkHandler ().post (() -> {
322- List <GroupMember > members = ChatManager .Instance ().getGroupMembers (groupId , false );
323- List <UIUserInfo > userInfos = memberToUIUserInfo (groupId , members );
338+ List <GroupMember > managers = getGroupManagers (groupId );
339+ List <UIUserInfo > userInfos = managerMemberToUIUserInfo (groupId , managers );
340+ data .postValue (userInfos );
341+ });
342+
343+ return data ;
344+ }
345+
346+ public MutableLiveData <List <UIUserInfo >> getMutedMemberUIUserInfosLiveData (String groupId , boolean refresh ) {
347+ MutableLiveData <List <UIUserInfo >> data = new MutableLiveData <>();
348+ ChatManager .Instance ().getWorkHandler ().post (() -> {
349+ List <GroupMember > mutedMembers = getMutedMembers (groupId );
350+ List <UIUserInfo > userInfos = mutedMemberToUIUserInfo (groupId , mutedMembers );
324351 data .postValue (userInfos );
325352 });
326353
@@ -332,7 +359,7 @@ public List<GroupMember> getGroupManagers(String groupId) {
332359 List <GroupMember > managers = new ArrayList <>();
333360 if (members != null ) {
334361 for (GroupMember member : members ) {
335- if (member .type == GroupMember .GroupMemberType .Manager ) {
362+ if (member .type == GroupMember .GroupMemberType .Manager || member . type == GroupMember . GroupMemberType . Owner ) {
336363 managers .add (member );
337364 }
338365 }
@@ -351,24 +378,49 @@ public List<String> getGroupManagerIds(String groupId) {
351378 return mangerIds ;
352379 }
353380
354- private List <UIUserInfo > memberToUIUserInfo (String groupId , List <GroupMember > members ) {
381+
382+ public List <GroupMember > getMutedMembers (String groupId ) {
383+ List <GroupMember > members = ChatManager .Instance ().getGroupMembers (groupId , false );
384+ List <GroupMember > managers = new ArrayList <>();
385+ if (members != null ) {
386+ for (GroupMember member : members ) {
387+ if (member .type == GroupMember .GroupMemberType .Silent ) {
388+ managers .add (member );
389+ }
390+ }
391+ }
392+ return managers ;
393+ }
394+
395+
396+ public List <String > getMutedMemberIds (String groupId ) {
397+ List <GroupMember > mutedMembers = getMutedMembers (groupId );
398+ List <String > mutedIds = new ArrayList <>();
399+ if (mutedMembers != null ) {
400+ for (GroupMember manager : mutedMembers ) {
401+ mutedIds .add (manager .memberId );
402+ }
403+ }
404+ return mutedIds ;
405+
406+ }
407+
408+ private List <UIUserInfo > managerMemberToUIUserInfo (String groupId , List <GroupMember > members ) {
355409 if (members == null || members .isEmpty ()) {
356410 return null ;
357411 }
358412
359413 List <String > memberIds = new ArrayList <>(members .size ());
360414 for (GroupMember member : members ) {
361- if (member .type == GroupMember .GroupMemberType .Owner || member .type == GroupMember .GroupMemberType .Manager ) {
362- memberIds .add (member .memberId );
363- }
415+ memberIds .add (member .memberId );
364416 }
365417
366418 List <UIUserInfo > uiUserInfos = new ArrayList <>();
367419 List <UserInfo > userInfos = UserViewModel .getUsers (memberIds , groupId );
368420 boolean showManagerCategory = false ;
369421 for (UserInfo userInfo : userInfos ) {
370422 UIUserInfo info = new UIUserInfo (userInfo );
371- String name = ChatManager .Instance ().getGroupMemberDisplayName (groupId , userInfo . uid );
423+ String name = ChatManager .Instance ().getGroupMemberDisplayName (userInfo );
372424 if (!TextUtils .isEmpty (name )) {
373425 String pinyin = PinyinUtils .getPinyin (name );
374426 char c = pinyin .toUpperCase ().charAt (0 );
@@ -403,6 +455,44 @@ private List<UIUserInfo> memberToUIUserInfo(String groupId, List<GroupMember> me
403455 return uiUserInfos ;
404456 }
405457
458+ private List <UIUserInfo > mutedMemberToUIUserInfo (String groupId , List <GroupMember > members ) {
459+ if (members == null || members .isEmpty ()) {
460+ return null ;
461+ }
462+
463+ List <String > memberIds = new ArrayList <>(members .size ());
464+ for (GroupMember member : members ) {
465+ memberIds .add (member .memberId );
466+ }
467+
468+ List <UIUserInfo > uiUserInfos = new ArrayList <>();
469+ List <UserInfo > userInfos = UserViewModel .getUsers (memberIds , groupId );
470+ boolean showManagerCategory = false ;
471+ for (UserInfo userInfo : userInfos ) {
472+ UIUserInfo info = new UIUserInfo (userInfo );
473+ String name = ChatManager .Instance ().getGroupMemberDisplayName (userInfo );
474+ if (!TextUtils .isEmpty (name )) {
475+ String pinyin = PinyinUtils .getPinyin (name );
476+ char c = pinyin .toUpperCase ().charAt (0 );
477+ if (c >= 'A' && c <= 'Z' ) {
478+ info .setSortName (pinyin );
479+ } else {
480+ // 为了让排序排到最后
481+ info .setSortName ("{" + pinyin );
482+ }
483+ } else {
484+ info .setSortName ("" );
485+ }
486+ info .setCategory ("禁言列表" );
487+ if (!showManagerCategory ) {
488+ showManagerCategory = true ;
489+ info .setShowCategory (true );
490+ }
491+ uiUserInfos .add (info );
492+ }
493+ return uiUserInfos ;
494+ }
495+
406496 public GroupMember getGroupMember (String groupId , String memberId ) {
407497 return ChatManager .Instance ().getGroupMember (groupId , memberId );
408498 }
0 commit comments