コード例 #1
0
    @Override
    public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
      AbsContactItem item = (AbsContactItem) adapter.getItem(position - 1);
      if (item == null) {
        return false;
      }

      if (NimUIKit.getContactEventListener() != null) {
        NimUIKit.getContactEventListener()
            .onItemLongClick(getActivity(), (((ContactItem) item).getContact()).getContactId());
      }

      return true;
    }
コード例 #2
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());
  }
コード例 #3
0
    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
      AbsContactItem item = (AbsContactItem) adapter.getItem(position - 1);
      if (item == null) {
        return;
      }

      int type = item.getItemType();

      if (type == ItemTypes.FUNC && customization != null) {
        customization.onFuncItemClick(item);
        return;
      }

      if (type == ItemTypes.FRIEND && NimUIKit.getContactEventListener() != null) {
        NimUIKit.getContactEventListener()
            .onItemClick(getActivity(), (((ContactItem) item).getContact()).getContactId());
      }
    }
コード例 #4
0
  /** 构建头像缓存 */
  public static void buildAvatarCache(List<String> accounts) {
    if (accounts == null || accounts.isEmpty()) {
      return;
    }

    UserInfoProvider.UserInfo userInfo;
    for (String account : accounts) {
      userInfo = NimUIKit.getUserInfoProvider().getUserInfo(account);
      asyncLoadAvatarBitmapToCache(userInfo);
    }

    LogUtil.i(TAG, "build avatar cache completed, avatar count =" + accounts.size());
  }
コード例 #5
0
  /** 邀请群成员 */
  @Override
  public void onAddMember() {
    ContactSelectActivity.Option option = new ContactSelectActivity.Option();
    option.title = "邀请成员";
    ArrayList<String> disableAccounts = new ArrayList<>();
    disableAccounts.addAll(memberAccounts);
    option.itemDisableFilter = new ContactIdFilter(disableAccounts);

    // 限制群成员数量在群容量范围内
    int capacity = teamCapacity - memberAccounts.size();
    option.maxSelectNum = capacity;
    option.maxSelectedTip = getString(R.string.reach_team_member_capacity, teamCapacity);
    NimUIKit.startContactSelect(NormalTeamInfoActivity.this, option, REQUEST_CODE_CONTACT_SELECT);
  }
コード例 #6
0
  @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;
  }
コード例 #7
0
  public void requestUserData() {
    NimUIKit.getContactProvider()
        .getUserInfoOfMyFriends(
            new RequestCallback<List<UserInfoProvider.UserInfo>>() {
              @Override
              public void onSuccess(List<UserInfoProvider.UserInfo> users) {
                if (!users.isEmpty()) {
                  refresh();
                }

                listView.onRefreshComplete();
              }

              @Override
              public void onFailed(int code) {
                if (code == 400 || code == 401) {
                  if (getActivity() != null) {
                    Toast.makeText(
                            getActivity(), "access_token无效,请重试。code=" + code, Toast.LENGTH_SHORT)
                        .show();
                  }
                } else {
                  if (getActivity() != null) {
                    Toast.makeText(
                            getActivity(), "request failed, code=" + code, Toast.LENGTH_SHORT)
                        .show();
                  }
                }

                listView.onRefreshComplete();
              }

              @Override
              public void onException(Throwable exception) {}
            });
  }
コード例 #8
0
 @Override
 public void onHeadImageViewClick(String account) {
   NimUIKit.getContactEventListener().onAvatarClick(this, account);
 }