Ejemplo n.º 1
0
 @Override
 protected void onDestroy() {
   super.onDestroy();
   HXSDKHelper.getInstance().isVideoCalling = false;
   stopMonitor();
   try {
     callHelper.setSurfaceView(null);
     cameraHelper.stopCapture();
     oppositeSurface = null;
     cameraHelper = null;
   } catch (Exception e) {
   }
 }
Ejemplo n.º 2
0
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.btn_refuse_call: // 拒绝接听
        refuseBtn.setEnabled(false);
        if (ringtone != null) ringtone.stop();
        try {
          EMChatManager.getInstance().rejectCall();
        } catch (Exception e1) {
          e1.printStackTrace();
          saveCallRecord(1);
          finish();
        }
        callingState = CallingState.REFUESD;
        break;

      case R.id.btn_answer_call: // 接听电话
        answerBtn.setEnabled(false);
        if (ringtone != null) ringtone.stop();
        if (isInComingCall) {
          try {
            callStateTextView.setText("正在接听...");
            EMChatManager.getInstance().answerCall();
            cameraHelper.setStartFlag(true);

            openSpeakerOn();
            handsFreeImage.setImageResource(R.drawable.icon_speaker_on);
            isAnswered = true;
            isHandsfreeState = true;
          } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            saveCallRecord(1);
            finish();
            return;
          }
        }
        comingBtnContainer.setVisibility(View.INVISIBLE);
        hangupBtn.setVisibility(View.VISIBLE);
        voiceContronlLayout.setVisibility(View.VISIBLE);
        localSurface.setVisibility(View.VISIBLE);
        break;

      case R.id.btn_hangup_call: // 挂断电话
        hangupBtn.setEnabled(false);
        if (soundPool != null) soundPool.stop(streamID);
        chronometer.stop();
        endCallTriggerByMe = true;
        callStateTextView.setText(getResources().getString(R.string.hanging_up));
        try {
          EMChatManager.getInstance().endCall();
        } catch (Exception e) {
          e.printStackTrace();
          saveCallRecord(1);
          finish();
        }
        break;

      case R.id.iv_mute: // 静音开关
        if (isMuteState) {
          // 关闭静音
          muteImage.setImageResource(R.drawable.icon_mute_normal);
          audioManager.setMicrophoneMute(false);
          isMuteState = false;
        } else {
          // 打开静音
          muteImage.setImageResource(R.drawable.icon_mute_on);
          audioManager.setMicrophoneMute(true);
          isMuteState = true;
        }
        break;
      case R.id.iv_handsfree: // 免提开关
        if (isHandsfreeState) {
          // 关闭免提
          handsFreeImage.setImageResource(R.drawable.icon_speaker_normal);
          closeSpeakerOn();
          isHandsfreeState = false;
        } else {
          handsFreeImage.setImageResource(R.drawable.icon_speaker_on);
          openSpeakerOn();
          isHandsfreeState = true;
        }
        break;
      case R.id.root_layout:
        if (callingState == CallingState.NORMAL) {
          if (bottomContainer.getVisibility() == View.VISIBLE) {
            bottomContainer.setVisibility(View.GONE);
            topContainer.setVisibility(View.GONE);

          } else {
            bottomContainer.setVisibility(View.VISIBLE);
            topContainer.setVisibility(View.VISIBLE);
          }
        }

        break;
      default:
        break;
    }
  }