/**
   * 注册群信息更新监听
   *
   * @param register
   */
  private void registerObservers(boolean register) {
    if (register) {
      TeamDataCache.getInstance().registerTeamDataChangedObserver(teamDataObserver);
    } else {
      TeamDataCache.getInstance().unregisterTeamDataChangedObserver(teamDataObserver);
    }

    registerUserInfoChangedObserver(register);
  }
 /** *************************** 加载&变更数据源 ******************************** */
 private void requestMembers() {
   gridView.setVisibility(View.GONE);
   memberAccounts.clear();
   if (team != null) {
     TeamDataCache.getInstance()
         .fetchTeamMemberList(
             teamId,
             new SimpleCallback<List<TeamMember>>() {
               @Override
               public void onResult(boolean success, List<TeamMember> members) {
                 if (success && members != null && !members.isEmpty()) {
                   gridView.setVisibility(View.VISIBLE);
                   List<String> accounts = new ArrayList<>();
                   for (TeamMember member : members) {
                     // 标记创建者(群主)
                     if (member.getType() == TeamMemberType.Owner) {
                       creator = member.getAccount();
                       if (creator.equals(NimUIKit.getAccount())) {
                         isSelfAdmin = true;
                       }
                     }
                     accounts.add(member.getAccount());
                   }
                   addMember(accounts, true);
                 } else {
                   Toast.makeText(NormalTeamInfoActivity.this, "获取成员列表失败", Toast.LENGTH_SHORT)
                       .show();
                 }
               }
             });
   }
 }
Ejemplo n.º 3
0
 /**
  * 打开讨论组或高级群资料页
  *
  * @param context 上下文
  * @param teamId 群id
  */
 public static void startTeamInfo(Context context, String teamId) {
   Team team = TeamDataCache.getInstance().getTeamById(teamId);
   if (team == null) {
     return;
   }
   if (team.getType() == TeamTypeEnum.Advanced) {
     AdvancedTeamInfoActivity.start(context, teamId); // 启动固定群资料页
   } else if (team.getType() == TeamTypeEnum.Normal) {
     NormalTeamInfoActivity.start(context, teamId); // 启动讨论组资料页
   }
 }
 private void loadTeamInfo() {
   creator = "";
   Team t = TeamDataCache.getInstance().getTeamById(teamId);
   if (t != null) {
     updateTeamInfo(t);
   } else {
     TeamDataCache.getInstance()
         .fetchTeamById(
             teamId,
             new SimpleCallback<Team>() {
               @Override
               public void onResult(boolean success, Team result) {
                 if (success && result != null) {
                   updateTeamInfo(result);
                 } else {
                   onGetTeamInfoFailed();
                 }
               }
             });
   }
 }
  @Override
  public void refresh(ContactDataAdapter adapter, int position, final ContactItem item) {
    // contact info
    final IContact contact = item.getContact();
    if (contact.getContactType() == IContact.Type.Friend) {
      head.loadBuddyAvatar(contact.getContactId());
    } else {
      Team team = TeamDataCache.getInstance().getTeamById(contact.getContactId());
      head.loadTeamIconByTeam(team);
    }
    name.setText(contact.getDisplayName());
    headLayout.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (contact.getContactType() == IContact.Type.Friend) {
              if (NimUIKit.getContactEventListener() != null) {
                NimUIKit.getContactEventListener()
                    .onAvatarClick(context, item.getContact().getContactId());
              }
            }
          }
        });

    // query result
    desc.setVisibility(View.GONE);
    /*
    TextQuery query = adapter.getQuery();
    HitInfo hitInfo = query != null ? ContactSearch.hitInfo(contact, query) : null;
    if (hitInfo != null && !hitInfo.text.equals(contact.getDisplayName())) {
        desc.setVisibility(View.VISIBLE);
    } else {
        desc.setVisibility(View.GONE);
    }
    */
  }
 private String getTeamUserDisplayName(String tid, String account) {
   return TeamDataCache.getInstance().getTeamMemberDisplayName(tid, account);
 }