|
@@ -0,0 +1,529 @@
|
|
|
+package com.wdkl.ncs.android.component.home.ui;
|
|
|
+
|
|
|
+import android.annotation.SuppressLint;
|
|
|
+import android.content.BroadcastReceiver;
|
|
|
+import android.content.Context;
|
|
|
+import android.content.Intent;
|
|
|
+import android.content.IntentFilter;
|
|
|
+import android.os.Bundle;
|
|
|
+import android.os.Handler;
|
|
|
+import android.os.Looper;
|
|
|
+import android.os.Message;
|
|
|
+import android.os.SystemClock;
|
|
|
+import android.util.Log;
|
|
|
+import android.view.KeyEvent;
|
|
|
+import android.view.LayoutInflater;
|
|
|
+import android.view.View;
|
|
|
+import android.view.ViewGroup;
|
|
|
+import android.widget.Chronometer;
|
|
|
+import android.widget.ImageView;
|
|
|
+import android.widget.LinearLayout;
|
|
|
+import android.widget.TextView;
|
|
|
+import android.widget.Toast;
|
|
|
+
|
|
|
+import androidx.annotation.NonNull;
|
|
|
+import androidx.annotation.Nullable;
|
|
|
+import androidx.fragment.app.Fragment;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.google.gson.Gson;
|
|
|
+import com.wdkl.ncs.android.component.home.util.MediaPlayHelper;
|
|
|
+import com.wdkl.ncs.android.component.home.util.RingPlayHelper;
|
|
|
+import com.wdkl.ncs.android.component.home.util.SpeechUtil;
|
|
|
+import com.wdkl.ncs.android.lib.utils.ExtendMethodsKt;
|
|
|
+import com.wdkl.ncs.android.middleware.common.Constant;
|
|
|
+import com.wdkl.ncs.android.lib.base.BaseApplication;
|
|
|
+import com.wdkl.ncs.android.lib.vo.MessageEvent;
|
|
|
+import com.wdkl.ncs.android.middleware.model.vo.InteractionVO;
|
|
|
+import com.wdkl.ncs.android.middleware.tcp.TcpClient;
|
|
|
+import com.wdkl.ncs.android.middleware.tcp.dto.TcpCallback;
|
|
|
+import com.wdkl.ncs.android.middleware.tcp.dto.TcpModel;
|
|
|
+import com.wdkl.ncs.android.middleware.tcp.enums.TcpAction;
|
|
|
+import com.wdkl.ncs.android.component.home.R;
|
|
|
+import com.wdkl.ncs.janus.client.JanusClient;
|
|
|
+import com.wdkl.ncs.janus.rtc.WebRTCEngine;
|
|
|
+import com.wdkl.ncs.janus.util.EnumType;
|
|
|
+
|
|
|
+import org.greenrobot.eventbus.EventBus;
|
|
|
+import org.greenrobot.eventbus.Subscribe;
|
|
|
+import org.greenrobot.eventbus.ThreadMode;
|
|
|
+
|
|
|
+import java.math.BigInteger;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
+public abstract class SingleCallFragment extends Fragment {
|
|
|
+ private static final String TAG = "SingleCallFragment";
|
|
|
+ ImageView minimizeImageView;
|
|
|
+ ImageView portraitImageView;// 用户头像
|
|
|
+ TextView nameTextView; // 用户昵称
|
|
|
+ TextView descTextView; // 状态提示用语
|
|
|
+ Chronometer durationTextView; // 通话时长
|
|
|
+
|
|
|
+ LinearLayout transLinearLayout;
|
|
|
+ LinearLayout hangupLinearLayout;
|
|
|
+ LinearLayout muteLinearLayout;
|
|
|
+ LinearLayout speakerLinearLayout;
|
|
|
+
|
|
|
+ ImageView outgoingHangupImageView;
|
|
|
+ ImageView incomingHangupImageView;
|
|
|
+ ImageView incomingTransImageView;
|
|
|
+ ImageView acceptImageView;
|
|
|
+ TextView tvStatus;
|
|
|
+ View outgoingActionContainer;
|
|
|
+ View incomingActionContainer;
|
|
|
+ View connectedActionContainer;
|
|
|
+
|
|
|
+ View lytParent;
|
|
|
+
|
|
|
+ boolean isOutgoing = true;
|
|
|
+
|
|
|
+ CallSingleActivity callSingleActivity;
|
|
|
+ CallHandler handler;
|
|
|
+ boolean isHandoff = false;
|
|
|
+
|
|
|
+ boolean endWithNoAnswerFlag = false;
|
|
|
+ public static final int WHAT_DELAY_END_CALL = 0x01;
|
|
|
+ public static final int FINISH_CURRENT = 0x02;
|
|
|
+ public static final int WHAT_DELAY_CHECK_CALL = 0x03;
|
|
|
+
|
|
|
+ EnumType.CallState currentState;
|
|
|
+ HeadsetPlugReceiver headsetPlugReceiver;
|
|
|
+
|
|
|
+ private boolean callSuccess = false;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
+ setRetainInstance(true);
|
|
|
+
|
|
|
+ handler = new CallHandler();
|
|
|
+ EventBus.getDefault().register(this);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Nullable
|
|
|
+ @Override
|
|
|
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
|
+ View view = inflater.inflate(getLayout(), container, false);
|
|
|
+ initView(view);
|
|
|
+ init();
|
|
|
+ return view;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onViewCreated(View view, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
|
|
|
+ super.onViewCreated(view, savedInstanceState);
|
|
|
+
|
|
|
+ if (isOutgoing) {
|
|
|
+ RingPlayHelper.playRingTone(BaseApplication.appContext, R.raw.ring_back2, true);
|
|
|
+ } else {
|
|
|
+ RingPlayHelper.playRingTone(BaseApplication.appContext, R.raw.ring_tone, true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDestroyView() {
|
|
|
+ if (handler != null) {
|
|
|
+ handler.removeCallbacksAndMessages(null);
|
|
|
+ }
|
|
|
+ if (durationTextView != null)
|
|
|
+ durationTextView.stop();
|
|
|
+ super.onDestroyView();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDestroy() {
|
|
|
+ super.onDestroy();
|
|
|
+ EventBus.getDefault().unregister(this);
|
|
|
+ }
|
|
|
+
|
|
|
+ abstract int getLayout();
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onAttach(@NonNull Context context) {
|
|
|
+ super.onAttach(context);
|
|
|
+ callSingleActivity = (CallSingleActivity) getActivity();
|
|
|
+ if (callSingleActivity != null) {
|
|
|
+ isOutgoing = callSingleActivity.isOutgoing();
|
|
|
+ headsetPlugReceiver = new HeadsetPlugReceiver();
|
|
|
+ IntentFilter filter = new IntentFilter();
|
|
|
+ filter.addAction(Intent.ACTION_HEADSET_PLUG);
|
|
|
+ callSingleActivity.registerReceiver(headsetPlugReceiver, filter);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDetach() {
|
|
|
+ super.onDetach();
|
|
|
+ callSingleActivity.unregisterReceiver(headsetPlugReceiver); //注销监听
|
|
|
+ callSingleActivity = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void initView(View view) {
|
|
|
+ lytParent = view.findViewById(R.id.lytParent);
|
|
|
+ minimizeImageView = view.findViewById(R.id.minimizeImageView);
|
|
|
+ portraitImageView = view.findViewById(R.id.portraitImageView);
|
|
|
+ nameTextView = view.findViewById(R.id.nameTextView);
|
|
|
+ descTextView = view.findViewById(R.id.descTextView);
|
|
|
+ durationTextView = view.findViewById(R.id.durationTextView);
|
|
|
+ outgoingHangupImageView = view.findViewById(R.id.outgoingHangupImageView);
|
|
|
+ incomingHangupImageView = view.findViewById(R.id.incomingHangupImageView);
|
|
|
+ incomingTransImageView = view.findViewById(R.id.incomingTransImageView);
|
|
|
+ acceptImageView = view.findViewById(R.id.acceptImageView);
|
|
|
+ tvStatus = view.findViewById(R.id.tvStatus);
|
|
|
+ outgoingActionContainer = view.findViewById(R.id.outgoingActionContainer);
|
|
|
+ incomingActionContainer = view.findViewById(R.id.incomingActionContainer);
|
|
|
+ connectedActionContainer = view.findViewById(R.id.connectedActionContainer);
|
|
|
+ transLinearLayout = view.findViewById(R.id.transLinearLayout);
|
|
|
+ hangupLinearLayout = view.findViewById(R.id.hangupLinearLayout);
|
|
|
+ muteLinearLayout = view.findViewById(R.id.muteLinearLayout);
|
|
|
+ speakerLinearLayout = view.findViewById(R.id.speakerLinearLayout);
|
|
|
+
|
|
|
+ durationTextView.setVisibility(View.GONE);
|
|
|
+ if (isOutgoing) {
|
|
|
+ //countDownTime();
|
|
|
+ handler.sendEmptyMessageDelayed(WHAT_DELAY_CHECK_CALL, 5000); //5s后检查是否呼叫成功
|
|
|
+ }
|
|
|
+ handler.sendEmptyMessageDelayed(WHAT_DELAY_END_CALL, 60 * 1000);//60s之后未接通,则挂断电话
|
|
|
+ }
|
|
|
+
|
|
|
+ public void init() {
|
|
|
+ if (callSingleActivity.recTcpModel.getData()!=null){
|
|
|
+ InteractionVO interactionVO = new Gson().fromJson(callSingleActivity.recTcpModel.getData().toString(), InteractionVO.class);
|
|
|
+ Constant.interactionId=interactionVO.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isOutgoing) {
|
|
|
+ startOutCall();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @SuppressLint("CheckResult")
|
|
|
+ private void startOutCall() {
|
|
|
+ //发送tcp call
|
|
|
+ TcpCallback transaction = new TcpCallback(callSingleActivity.recTcpModel.getTid()) {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(JSONObject jsonObject) {
|
|
|
+ //
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFailed(JSONObject jsonObject) {
|
|
|
+ if (callSingleActivity != null) {
|
|
|
+ callSingleActivity.runOnUiThread(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ ExtendMethodsKt.showMessage("Failed");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ callSingleActivity.finish();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ TcpClient.getInstance().sendTcp(callSingleActivity.recTcpModel, false, transaction);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void callOutSuccess(TcpModel tcpModel) {
|
|
|
+ callSingleActivity.recTcpModel = tcpModel;
|
|
|
+ InteractionVO interactionVO = new Gson().fromJson(tcpModel.getData().toString(), InteractionVO.class);
|
|
|
+
|
|
|
+ Constant.interactionId=interactionVO.getId();
|
|
|
+ callSuccess = true;
|
|
|
+ //callSingleActivity.janusClient.connect();
|
|
|
+ Log.d(TAG,"voice#success =>" + callSingleActivity.recTcpModel.toJson());
|
|
|
+ runOnUiThread(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ Toast.makeText(SingleCallFragment.this.getContext(), R.string.call_success, Toast.LENGTH_SHORT).show();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ public void didChangeState(EnumType.CallState state) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void didCreateLocalVideoTrack() {
|
|
|
+ }
|
|
|
+
|
|
|
+ public void didReceiveRemoteVideoTrack(BigInteger userId) {
|
|
|
+ }
|
|
|
+
|
|
|
+ public void startRefreshTime() {
|
|
|
+ if (durationTextView != null) {
|
|
|
+ leftTime = 0;
|
|
|
+ durationTextView.setOnChronometerTickListener(null);
|
|
|
+ durationTextView.stop();
|
|
|
+ durationTextView.setVisibility(View.VISIBLE);
|
|
|
+ durationTextView.setBase(SystemClock.elapsedRealtime());
|
|
|
+ durationTextView.start();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private long leftTime = 60;
|
|
|
+ public void countDownTime() {
|
|
|
+ if (durationTextView != null) {
|
|
|
+ durationTextView.setVisibility(View.VISIBLE);
|
|
|
+ durationTextView.setBase(SystemClock.elapsedRealtime());
|
|
|
+ durationTextView.start();
|
|
|
+ durationTextView.setOnChronometerTickListener(
|
|
|
+ new Chronometer.OnChronometerTickListener() {
|
|
|
+ @Override
|
|
|
+ public void onChronometerTick(Chronometer chronometer) {
|
|
|
+ leftTime--;
|
|
|
+ Date d = new Date(leftTime * 1000);
|
|
|
+ SimpleDateFormat timeFormat = new SimpleDateFormat("mm:ss");
|
|
|
+ chronometer.setText(timeFormat.format(d));
|
|
|
+ if (leftTime == 0) {
|
|
|
+ durationTextView.stop();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ void runOnUiThread(Runnable runnable) {
|
|
|
+ if (callSingleActivity != null) {
|
|
|
+ callSingleActivity.runOnUiThread(runnable);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @SuppressLint("HandlerLeak")
|
|
|
+ class CallHandler extends Handler {
|
|
|
+ @Override
|
|
|
+ public void handleMessage(@NonNull Message msg) {
|
|
|
+ switch (msg.what) {
|
|
|
+ case WHAT_DELAY_END_CALL:
|
|
|
+ if (currentState != EnumType.CallState.Connected) {
|
|
|
+ endWithNoAnswerFlag = true;
|
|
|
+ if (callSingleActivity != null) {
|
|
|
+ callSingleActivity.sendHandOffTcp();
|
|
|
+ callSingleActivity.finish();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case WHAT_DELAY_CHECK_CALL:
|
|
|
+ if (callSingleActivity != null && !callSuccess) {
|
|
|
+ Toast.makeText(SingleCallFragment.this.getContext(), R.string.net_error, Toast.LENGTH_SHORT).show();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case FINISH_CURRENT:
|
|
|
+ if (callSingleActivity != null) {
|
|
|
+ callSingleActivity.finish();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public abstract void onBackPressed();
|
|
|
+
|
|
|
+ public abstract boolean onKeyUp(int keyCode, KeyEvent event);
|
|
|
+
|
|
|
+ protected abstract void handleHeadsetHook();
|
|
|
+
|
|
|
+ class HeadsetPlugReceiver extends BroadcastReceiver {
|
|
|
+ @Override
|
|
|
+ public void onReceive(Context context, Intent intent) {
|
|
|
+ if (intent.hasExtra("state")) {
|
|
|
+ if (intent.getIntExtra("state", 0) == 0) { //拔出耳机
|
|
|
+ WebRTCEngine.getInstance().toggleHeadset(false);
|
|
|
+ } else if (intent.getIntExtra("state", 0) == 1) { //插入耳机
|
|
|
+ WebRTCEngine.getInstance().toggleHeadset(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private int reJoinCount = 0;
|
|
|
+
|
|
|
+// @Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
+// public void onEvent(MessageEvent messageEvent) {
|
|
|
+// int code = messageEvent.getTag();
|
|
|
+// if (code == JanusClient.CALLBACK_ADD_LOCALSTREAM) {
|
|
|
+// runOnUiThread(new Runnable() {
|
|
|
+// @Override
|
|
|
+// public void run() {
|
|
|
+// callSingleActivity.getCurrentFragment().didCreateLocalVideoTrack();
|
|
|
+// }
|
|
|
+// });
|
|
|
+// } else if (code == JanusClient.CALLBACK_ADD_REMOTESTREAM) {
|
|
|
+// BigInteger remoteUserId = (BigInteger) messageEvent.getMessage();
|
|
|
+// runOnUiThread(new Runnable() {
|
|
|
+// @Override
|
|
|
+// public void run() {
|
|
|
+// callSingleActivity.getCurrentFragment().didReceiveRemoteVideoTrack(remoteUserId);
|
|
|
+// }
|
|
|
+// });
|
|
|
+// } else if (code == JanusClient.CALLBACK_HANDUP) {
|
|
|
+// if (isHandoff) {
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// BigInteger handleId = (BigInteger)messageEvent.getMessage();
|
|
|
+// if (!handleId.equals(callSingleActivity.janusClient.getCurrentHandleId())){
|
|
|
+// runOnUiThread(new Runnable() {
|
|
|
+// @Override
|
|
|
+// public void run() {
|
|
|
+// Toast.makeText(SingleCallFragment.this.getContext(),R.string.call_end,Toast.LENGTH_SHORT).show();
|
|
|
+// }
|
|
|
+// });
|
|
|
+// }
|
|
|
+//
|
|
|
+// handler.sendEmptyMessageDelayed(FINISH_CURRENT, 100);
|
|
|
+// } else if (code == JanusClient.CALLBACK_ROOM_ERROR) {
|
|
|
+// runOnUiThread(new Runnable() {
|
|
|
+// @Override
|
|
|
+// public void run() {
|
|
|
+// Toast.makeText(SingleCallFragment.this.getContext(), "Room error", Toast.LENGTH_SHORT).show();
|
|
|
+// }
|
|
|
+// });
|
|
|
+//
|
|
|
+// handler.sendEmptyMessageDelayed(FINISH_CURRENT, 100);
|
|
|
+// } else if (code == JanusClient.CALLBACK_CONNECTED) {
|
|
|
+// //通话连接建立,停止铃声
|
|
|
+// MediaPlayHelper.getInstance().stopMusic(true);
|
|
|
+// RingPlayHelper.stopRingTone();
|
|
|
+// SpeechUtil.getInstance().stopSpeak();
|
|
|
+// didChangeState(EnumType.CallState.Connected);
|
|
|
+// } else if (code == JanusClient.CALLBACK_CONNECTED_TIMEOUT) {
|
|
|
+// runOnUiThread(new Runnable() {
|
|
|
+// @Override
|
|
|
+// public void run() {
|
|
|
+// Toast.makeText(SingleCallFragment.this.getContext(), "Connect timeout", Toast.LENGTH_SHORT).show();
|
|
|
+// }
|
|
|
+// });
|
|
|
+//
|
|
|
+// handler.sendEmptyMessageDelayed(FINISH_CURRENT, 100);
|
|
|
+// } else if (code == JanusClient.CALLBACK_LEAVING) {
|
|
|
+// if (isHandoff) {
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// if (isOutgoing){
|
|
|
+// handler.sendEmptyMessageDelayed(FINISH_CURRENT, 100);
|
|
|
+// } else {
|
|
|
+// if (reJoinCount>=3){
|
|
|
+// runOnUiThread(new Runnable() {
|
|
|
+// @Override
|
|
|
+// public void run() {
|
|
|
+// Toast.makeText(SingleCallFragment.this.getContext(), "Connect timeout", Toast.LENGTH_SHORT).show();
|
|
|
+// }
|
|
|
+// });
|
|
|
+//
|
|
|
+// handler.sendEmptyMessageDelayed(FINISH_CURRENT, 100);
|
|
|
+// } else {
|
|
|
+// //未收到挂断或主动挂断 重新进入
|
|
|
+// callSingleActivity.janusClient.connect();
|
|
|
+// reJoinCount++;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// //BigInteger remoteUserId = (BigInteger)messageEvent.getMessage();
|
|
|
+//
|
|
|
+// } else if (code == JanusClient.CALLBACK_REMOTE_QUIT) {
|
|
|
+// if (isHandoff) {
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// //BigInteger remoteUserId = (BigInteger)messageEvent.getMessage();
|
|
|
+// runOnUiThread(new Runnable() {
|
|
|
+// @Override
|
|
|
+// public void run() {
|
|
|
+// Toast.makeText(SingleCallFragment.this.getContext(), R.string.call_end, Toast.LENGTH_SHORT).show();
|
|
|
+// }
|
|
|
+// });
|
|
|
+//
|
|
|
+// handler.sendEmptyMessageDelayed(FINISH_CURRENT, 100);
|
|
|
+// }
|
|
|
+// else if (code == JanusClient.CALLBACK_SLOW_LINK){
|
|
|
+// runOnUiThread(new Runnable() {
|
|
|
+// @Override
|
|
|
+// public void run() {
|
|
|
+// Toast.makeText(SingleCallFragment.this.getContext(), R.string.net_error, Toast.LENGTH_SHORT).show();
|
|
|
+// }
|
|
|
+// });
|
|
|
+// }
|
|
|
+// //TCP处理
|
|
|
+// else if (code == 2) {
|
|
|
+//
|
|
|
+// TcpModel tcpModel = (TcpModel) messageEvent.getMessage();
|
|
|
+// Log.i(TAG, "收到数据222: " + tcpModel.toJson());
|
|
|
+// int curInteractionId = -1;
|
|
|
+// if (tcpModel.getData() != null) {
|
|
|
+// InteractionVO interactionVO = new Gson().fromJson(tcpModel.getData().toString(), InteractionVO.class);
|
|
|
+// curInteractionId = interactionVO.getId();
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (tcpModel.getAction() == TcpAction.VoiceAction.ACCEPT) {
|
|
|
+// if (curInteractionId == Constant.interactionId) {
|
|
|
+// MediaPlayHelper.getInstance().stopMusic(true);
|
|
|
+// RingPlayHelper.stopRingTone();
|
|
|
+// SpeechUtil.getInstance().stopSpeak();
|
|
|
+// callSingleActivity.recTcpModel = tcpModel;
|
|
|
+// Log.d(TAG, "voice#success =>" + callSingleActivity.recTcpModel.toJson());
|
|
|
+// Log.i(TAG, "对方接听电话啦");
|
|
|
+// }
|
|
|
+// } else if (tcpModel.getAction() == TcpAction.VoiceAction.HANDOFF) { //对方挂断
|
|
|
+// if (curInteractionId == Constant.interactionId) {
|
|
|
+// isHandoff = true;
|
|
|
+// callSingleActivity.janusClient.disConnect();
|
|
|
+// runOnUiThread(new Runnable() {
|
|
|
+// @Override
|
|
|
+// public void run() {
|
|
|
+// Toast.makeText(SingleCallFragment.this.getContext(), R.string.call_end, Toast.LENGTH_SHORT).show();
|
|
|
+// }
|
|
|
+// });
|
|
|
+//
|
|
|
+// handler.sendEmptyMessageDelayed(FINISH_CURRENT, 100);
|
|
|
+// }
|
|
|
+// } else if (tcpModel.getAction() == TcpAction.VoiceAction.REJECT) {
|
|
|
+// if (curInteractionId == Constant.interactionId) {
|
|
|
+// handler.sendEmptyMessageDelayed(FINISH_CURRENT, 100);
|
|
|
+//
|
|
|
+// runOnUiThread(new Runnable() {
|
|
|
+// @Override
|
|
|
+// public void run() {
|
|
|
+// Toast.makeText(SingleCallFragment.this.getContext(), R.string.call_reject, Toast.LENGTH_SHORT).show();
|
|
|
+// }
|
|
|
+// });
|
|
|
+// }
|
|
|
+// } else if (tcpModel.getAction() == TcpAction.VoiceAction.CALLING) {
|
|
|
+// if (curInteractionId == Constant.interactionId) {
|
|
|
+// handler.sendEmptyMessageDelayed(FINISH_CURRENT, 100);
|
|
|
+// runOnUiThread(new Runnable() {
|
|
|
+// @Override
|
|
|
+// public void run() {
|
|
|
+// Toast.makeText(SingleCallFragment.this.getContext(), R.string.call_busy, Toast.LENGTH_SHORT).show();
|
|
|
+// }
|
|
|
+// });
|
|
|
+// }
|
|
|
+// } else if (tcpModel.getAction() == TcpAction.VoiceAction.FAILED) {
|
|
|
+// //if (curInteractionId == interactionId) {
|
|
|
+// handler.sendEmptyMessageDelayed(FINISH_CURRENT, 1000);
|
|
|
+// runOnUiThread(new Runnable() {
|
|
|
+// @Override
|
|
|
+// public void run() {
|
|
|
+// Toast.makeText(SingleCallFragment.this.getContext(), R.string.call_failed, Toast.LENGTH_SHORT).show();
|
|
|
+// }
|
|
|
+// });
|
|
|
+// //}
|
|
|
+// } else if (tcpModel.getAction() == TcpAction.VoiceAction.CANCEL || tcpModel.getAction() == TcpAction.VoiceAction.VOICE_OFF) {
|
|
|
+// if (curInteractionId == Constant.interactionId) {
|
|
|
+// handler.sendEmptyMessageDelayed(FINISH_CURRENT, 100);
|
|
|
+// runOnUiThread(new Runnable() {
|
|
|
+// @Override
|
|
|
+// public void run() {
|
|
|
+// Toast.makeText(SingleCallFragment.this.getContext(), R.string.str_cancel, Toast.LENGTH_SHORT).show();
|
|
|
+// }
|
|
|
+// });
|
|
|
+// }
|
|
|
+// }
|
|
|
+// } else if (code == 1) {
|
|
|
+// TcpModel tcpModel = (TcpModel) messageEvent.getMessage();
|
|
|
+// Log.i(TAG, "收到数据111: " + tcpModel.toJson());
|
|
|
+// if (isOutgoing && tcpModel.getAction() == TcpAction.VoiceAction.SUCCESS){ //服务器返回成功
|
|
|
+// callOutSuccess(tcpModel);
|
|
|
+// }
|
|
|
+// } else if (code == Constant.EVENT_HEADSET_HOOK) {
|
|
|
+// //收到耳机按键
|
|
|
+// handleHeadsetHook();
|
|
|
+// }
|
|
|
+// }
|
|
|
+}
|