/** 添加群成员 */
  private void addMembersToTeam(final ArrayList<String> selected) {
    // add members
    DialogMaker.showProgressDialog(this, getString(R.string.empty), true);
    NIMClient.getService(TeamService.class)
        .addMembers(teamId, selected)
        .setCallback(
            new RequestCallback<Void>() {
              @Override
              public void onSuccess(Void param) {
                DialogMaker.dismissProgressDialog();
                addMember(selected, false);
                Toast.makeText(
                        NormalTeamInfoActivity.this,
                        R.string.invite_member_success,
                        Toast.LENGTH_SHORT)
                    .show();
              }

              @Override
              public void onFailed(int code) {
                DialogMaker.dismissProgressDialog();
                Toast.makeText(
                        NormalTeamInfoActivity.this,
                        R.string.invite_member_failed,
                        Toast.LENGTH_SHORT)
                    .show();
              }

              @Override
              public void onException(Throwable exception) {
                DialogMaker.dismissProgressDialog();
              }
            });
  }
  /** 移除群成员 */
  @Override
  public void onRemoveMember(final String account) {
    DialogMaker.showProgressDialog(this, getString(R.string.empty), true);
    NIMClient.getService(TeamService.class)
        .removeMember(teamId, account)
        .setCallback(
            new RequestCallback<Void>() {
              @Override
              public void onSuccess(Void param) {
                DialogMaker.dismissProgressDialog();
                removeMember(account);
                Toast.makeText(
                        NormalTeamInfoActivity.this,
                        R.string.remove_member_success,
                        Toast.LENGTH_SHORT)
                    .show();
              }

              @Override
              public void onFailed(int code) {
                DialogMaker.dismissProgressDialog();
                Toast.makeText(
                        NormalTeamInfoActivity.this,
                        R.string.remove_member_failed,
                        Toast.LENGTH_SHORT)
                    .show();
              }

              @Override
              public void onException(Throwable exception) {
                DialogMaker.dismissProgressDialog();
              }
            });
  }
예제 #3
0
  /** 拨打音视频 */
  public void outGoingCalling(String account, AVChatType callTypeEnum) {
    DialogMaker.showProgressDialog(context, null);
    this.receiverId = account;
    VideoChatParam videoParam = null;
    if (callTypeEnum == AVChatType.AUDIO) {
      onCallStateChange(CallStateEnum.OUTGOING_AUDIO_CALLING);
    } else {
      onCallStateChange(CallStateEnum.OUTGOING_VIDEO_CALLING);
      if (videoParam == null) {
        videoParam = new VideoChatParam(avChatSurface.mCapturePreview, 0, getVideoDimens());
      }
    }

    AVChatNotifyOption notifyOption = new AVChatNotifyOption();
    notifyOption.extendMessage = "extra_data";

    /**
     * 发起通话 account 对方帐号 callTypeEnum 通话类型:语音、视频 videoParam 发起视频通话时传入,发起音频通话传null AVChatCallback
     * 回调函数,返回AVChatInfo
     */
    AVChatManager.getInstance()
        .call(
            account,
            callTypeEnum,
            videoParam,
            notifyOption,
            new AVChatCallback<AVChatData>() {
              @Override
              public void onSuccess(AVChatData data) {
                avChatData = data;
                DialogMaker.dismissProgressDialog();
              }

              @Override
              public void onFailed(int code) {
                LogUtil.d(TAG, "avChat call failed code->" + code);
                DialogMaker.dismissProgressDialog();
                if (code == ResponseCode.RES_FORBIDDEN) {
                  Toast.makeText(context, R.string.avchat_no_permission, Toast.LENGTH_SHORT).show();
                } else {
                  Toast.makeText(context, R.string.avchat_call_failed, Toast.LENGTH_SHORT).show();
                }
                closeSessions(-1);
              }

              @Override
              public void onException(Throwable exception) {
                LogUtil.d(TAG, "avChat call onException->" + exception);
                DialogMaker.dismissProgressDialog();
              }
            });
  }
  /** 非群主退出群 */
  private void quitTeam() {
    DialogMaker.showProgressDialog(this, getString(R.string.empty), true);
    NIMClient.getService(TeamService.class)
        .quitTeam(teamId)
        .setCallback(
            new RequestCallback<Void>() {
              @Override
              public void onSuccess(Void param) {
                DialogMaker.dismissProgressDialog();
                Toast.makeText(
                        NormalTeamInfoActivity.this,
                        R.string.quit_normal_team_success,
                        Toast.LENGTH_SHORT)
                    .show();
                setResult(
                    Activity.RESULT_OK,
                    new Intent()
                        .putExtra(
                            TeamExtras.RESULT_EXTRA_REASON, TeamExtras.RESULT_EXTRA_REASON_QUIT));

                NIMClient.getService(MsgService.class)
                    .deleteRecentContact2(teamId, SessionTypeEnum.Team);
                finish();
              }

              @Override
              public void onFailed(int code) {
                DialogMaker.dismissProgressDialog();
                Toast.makeText(
                        NormalTeamInfoActivity.this,
                        R.string.quit_normal_team_failed,
                        Toast.LENGTH_SHORT)
                    .show();
              }

              @Override
              public void onException(Throwable exception) {
                DialogMaker.dismissProgressDialog();
              }
            });
  }