updateGroupData static method
void
updateGroupData(
- dynamic obj
更新群组和成员数据
Implementation
static void updateGroupData(dynamic obj){
//获取群组数据
List<dynamic> groups=obj["groups"];
Log.i(tag, "updateGroupData:groups:${groups.length}");
//记录更新前是否临时群组(用于播报判断),再updateGroupData之前
bool isInTmpGroup=false;
if(pocChangeNotifier.hasTmpGroup()){
isInTmpGroup=true;
}
Log.i(tag, "updateGroupData:isInTmpGroup:$isInTmpGroup");
//更新群组和成员数据
//设置群组的状态人数
setGroupsUserCount(groups);
Log.i(tag, "updateGroupData:setGroupsUserCount");
//Log.i(tag, "UpdateUserList:setGroups:"+groups.size());
//更新群组数据
pocChangeNotifier.setGroups(groups);
Log.i(tag, "updateGroupData:setGroups");
bool final_isInTmpGroup=isInTmpGroup;
//获取当前所在群组id
int activeGroupId=obj["activeGroupId"];
Log.i(tag, "updateGroupData:activeGroupId:$activeGroupId");
//将4294967295l转成0处理
if(activeGroupId==4294967295){
activeGroupId=0;
}
//updateuserlist和updateGroup都在调用,activeGroupId更新了但是可能此时还没更新群组数据
//此时直接return
if(activeGroupId>0){
dynamic activeGroup=pocChangeNotifier.getGroup(activeGroupId);
if(activeGroup==null){
Log.i(tag, "updateGroupData:activeGroup还不存在");
return;
}
}
if(activeGroupId>0){//在组
Log.i(tag, "updateGroupData:activeGroupId:$activeGroupId");
Log.i(tag, "updateGroupData:pocChangeNotifier.activeGroupId:${pocChangeNotifier.activeGroupId}");
if(pocChangeNotifier.activeGroupId!=activeGroupId){//从不在组变成在组或者切换群组
bool hasTmpGroup=pocChangeNotifier.hasTmpGroup();
if(hasTmpGroup){//在临时群组
if(activeGroupId==pocChangeNotifier.id){//自己发起的
playText(getTranslation("InviteTmp"), true);
Log.i(tag, "updateGroupData:临时呼叫成功");
}else{//别人发起的
Log.i(tag, "updateGroupData:getGroup:$activeGroupId");
dynamic group=pocChangeNotifier.getGroup(activeGroupId);
Log.i(tag, "updateGroupData:临时呼叫:group:$group");
if(group!=null){
dynamic user=pocChangeNotifier.getUser(activeGroupId);
Log.i(tag, "updateGroupData:临时呼叫:user:$user");
if(user!=null){
playText("${user["name"]} ${getTranslation("InviteTmp")}", true);
Log.i(tag, "updateGroupData:${user["name"]}发起临时呼叫");
}
}
}
pocChangeNotifier.setLastVoiceEnterGroupId(0);
pocChangeNotifier.setShowGroupId(activeGroupId);
pocChangeNotifier.resetCheckedUserIds();
}else{//在普通组
String activeGroupName="";
dynamic group=pocChangeNotifier.getGroup(activeGroupId);
if(group!=null){
activeGroupName=group["name"];
}
//从不在组变成在组,不打断播报
if(pocChangeNotifier.activeGroupId==0){
if(pocChangeNotifier.lastVoiceEnterGroupId!=activeGroupId){
playText("${getTranslation("EnterGroup")}:$activeGroupName", false);
Log.i(tag, "updateGroupData:进入群组:$activeGroupName");
pocChangeNotifier.setLastVoiceEnterGroupId(activeGroupId);
}else{
Log.i(tag, "updateGroupData:lastVoiceEnterGroupId:${pocChangeNotifier.lastVoiceEnterGroupId}");
Log.i(tag, "updateGroupData:已播报");
}
}else{//不同组切换,立即打断(连续点击进组)
if(final_isInTmpGroup){
Log.i(tag, "updateGroupData:退出临时呼叫,进入群组:$activeGroupName");
playText("${getTranslation("EnterGroup")}:$activeGroupName", true);
}else{
Log.i(tag, "updateGroupData:进入群组:$activeGroupName");
playText("${getTranslation("EnterGroup")}:$activeGroupName", true);
}
}
//进组,显示该组成员列表
if(waitShowUserGroupId==activeGroupId){
pocChangeNotifier.setShowGroupId(activeGroupId);
}
}
}else{
//当前组无变化
Log.i(tag, "updateGroupData:当前组无变化");
}
//重置等待显组的id
setWaitShowUserGroupId(0);
}else{//不在群组
if(pocChangeNotifier.activeGroupId>0){//从在组变成不在组
//在组掉线后重新登录,防止播报一次退出群组,故延时播报
Log.i(tag, "updateGroupData:post 退出群组");
Future.delayed(const Duration(milliseconds: 500),(){
//延时后依然不在群组,才播报
if(pocChangeNotifier.activeGroupId==0){
playText(getTranslation("LeaveGroup"), true);
Log.i(tag, "updateGroupData:退出群组");
}
});
//退出成员列表
pocChangeNotifier.setShowGroupId(0);
}
}
//更新当前所在群组id
Log.i(tag, "updateGroupData:setActiveGroupId:$activeGroupId");
pocChangeNotifier.setActiveGroupId(activeGroupId);
}