Пример #1
0
  public void buildCache() {
    // 获取我所有的好友关系
    List<Friend> friends = NIMClient.getService(FriendService.class).getFriends();
    for (Friend f : friends) {
      friendMap.put(f.getAccount(), f);
    }

    // 获取我所有好友的帐号
    List<String> accounts = NIMClient.getService(FriendService.class).getFriendAccounts();
    if (accounts == null || accounts.isEmpty()) {
      return;
    }

    // 排除黑名单
    List<String> blacks = NIMClient.getService(FriendService.class).getBlackList();
    accounts.removeAll(blacks);

    // 排除掉自己
    accounts.remove(NimUIKit.getAccount());

    // 确定缓存
    friendAccountSet.addAll(accounts);

    LogUtil.i(
        UIKitLogTag.FRIEND_CACHE,
        "build FriendDataCache completed, friends count = " + friendAccountSet.size());
  }
  @Override
  protected String getContent() {
    String content = descOfMsg();

    String fromId = recent.getFromAccount();
    if (!TextUtils.isEmpty(fromId)
        && !fromId.equals(NimUIKit.getAccount())
        && !(recent.getAttachment() instanceof NotificationAttachment)) {
      String tid = recent.getContactId();
      String teamNick = getTeamUserDisplayName(tid, fromId);
      content = teamNick + ": " + content;
    }

    return content;
  }