|
@@ -3,6 +3,7 @@ package com.wdkl.ncs.android.component.home.activity;
|
|
|
import android.app.Activity;
|
|
|
import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
+import android.os.CountDownTimer;
|
|
|
import android.util.Log;
|
|
|
import android.view.View;
|
|
|
import android.view.WindowManager;
|
|
@@ -19,6 +20,7 @@ import com.starrtc.demo.utils.IEventListener;
|
|
|
import com.starrtc.starrtcsdk.api.XHClient;
|
|
|
import com.starrtc.starrtcsdk.apiInterface.IXHResultCallback;
|
|
|
import com.wdkl.ncs.android.component.home.R;
|
|
|
+import com.wdkl.ncs.android.component.home.settingconfig.SettingConfig;
|
|
|
import com.wdkl.ncs.android.component.home.util.MediaPlayHelper;
|
|
|
import com.wdkl.ncs.android.component.nursehome.common.Constants;
|
|
|
import com.wdkl.ncs.android.lib.utils.ExtendMethodsKt;
|
|
@@ -37,16 +39,22 @@ import org.greenrobot.eventbus.ThreadMode;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
|
public class RTCVoipAudioRingingActivity extends Activity implements View.OnClickListener, IEventListener {
|
|
|
+ private String TAG = RTCVoipAudioRingingActivity.class.getSimpleName();
|
|
|
+
|
|
|
|
|
|
private String targetId;
|
|
|
private InteractionVO interactionVO = new InteractionVO();
|
|
|
private TcpModel tcpModel = new TcpModel();
|
|
|
private TextView bao_mother_name_tv;
|
|
|
+
|
|
|
+ private CountDownTimer countDownTimer;
|
|
|
+ private int countdownTime = 15;
|
|
|
+
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
- getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN ,
|
|
|
- WindowManager.LayoutParams. FLAG_FULLSCREEN);
|
|
|
+ getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
|
|
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
|
setContentView(R.layout.watch_activity_voice_calls);
|
|
|
|
|
|
//todo 设置为通话状态 有其他用户输入时 DeviceChannel设置返回通话中
|
|
@@ -56,17 +64,18 @@ public class RTCVoipAudioRingingActivity extends Activity implements View.OnClic
|
|
|
targetId = getIntent().getStringExtra("targetId");
|
|
|
tcpModel = (TcpModel) getIntent().getSerializableExtra("TcpModel");
|
|
|
bao_mother_name_tv = findViewById(R.id.bao_mother_name_tv);
|
|
|
- interactionVO = new Gson().fromJson(tcpModel.getData().toString(), InteractionVO.class);
|
|
|
+ interactionVO = new Gson().fromJson(tcpModel.getData().toString(), InteractionVO.class);
|
|
|
|
|
|
TextView eventText = (TextView) findViewById(R.id.event_text);
|
|
|
eventText.setText(interactionVO.getFromFrameFullName());
|
|
|
- if (Strings.isNullOrEmpty(targetId)){
|
|
|
+ if (Strings.isNullOrEmpty(targetId)) {
|
|
|
findViewById(R.id.hang_up_imagev).setVisibility(View.GONE);
|
|
|
findViewById(R.id.call_the_voice_imagev).setVisibility(View.GONE);
|
|
|
} else {
|
|
|
bao_mother_name_tv.setText(interactionVO.getFromMemberName());
|
|
|
findViewById(R.id.hang_up_imagev).setOnClickListener(this);
|
|
|
findViewById(R.id.call_the_voice_imagev).setOnClickListener(this);
|
|
|
+ findViewById(R.id.change_over_image).setOnClickListener(this);
|
|
|
}
|
|
|
// ((TextView)findViewById(R.id.targetid_text)).setText(targetId);
|
|
|
// ((ImageView)findViewById(R.id.head_img)).setImageResource(MLOC.getHeadImage(RTCVoipAudioRingingActivity.this,targetId));
|
|
@@ -80,30 +89,32 @@ public class RTCVoipAudioRingingActivity extends Activity implements View.OnClic
|
|
|
historyBean.setLastTime(new SimpleDateFormat("MM-dd HH:mm").format(new java.util.Date()));
|
|
|
historyBean.setConversationId(targetId);
|
|
|
historyBean.setNewMsgCount(1);
|
|
|
- MLOC.addHistory(historyBean,true);
|
|
|
+ MLOC.addHistory(historyBean, true);
|
|
|
|
|
|
+ initCountDownTimer();
|
|
|
+ countDownTimer.start();
|
|
|
MediaPlayHelper.getInstance().playResMusic(R.raw.incoming_call, 1.0f, true);
|
|
|
|
|
|
EventBus.getDefault().register(this);
|
|
|
}
|
|
|
|
|
|
- public void addListener(){
|
|
|
- AEvent.addListener(AEvent.AEVENT_VOIP_REV_HANGUP,this);
|
|
|
- AEvent.addListener(AEvent.AEVENT_VOIP_REV_ERROR,this);
|
|
|
+ public void addListener() {
|
|
|
+ AEvent.addListener(AEvent.AEVENT_VOIP_REV_HANGUP, this);
|
|
|
+ AEvent.addListener(AEvent.AEVENT_VOIP_REV_ERROR, this);
|
|
|
}
|
|
|
|
|
|
- public void removeListener(){
|
|
|
- AEvent.removeListener(AEvent.AEVENT_VOIP_REV_HANGUP,this);
|
|
|
- AEvent.removeListener(AEvent.AEVENT_VOIP_REV_ERROR,this);
|
|
|
+ public void removeListener() {
|
|
|
+ AEvent.removeListener(AEvent.AEVENT_VOIP_REV_HANGUP, this);
|
|
|
+ AEvent.removeListener(AEvent.AEVENT_VOIP_REV_ERROR, this);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void dispatchEvent(final String aEventID, boolean success, final Object eventObj) {
|
|
|
//super.dispatchEvent(aEventID,success,eventObj);
|
|
|
- switch (aEventID){
|
|
|
+ switch (aEventID) {
|
|
|
case AEvent.AEVENT_VOIP_REV_HANGUP:
|
|
|
- MLOC.d("","对方已挂断");
|
|
|
- MLOC.showMsg(RTCVoipAudioRingingActivity.this,"对方已挂断");
|
|
|
+ MLOC.d("", "对方已挂断");
|
|
|
+ MLOC.showMsg(RTCVoipAudioRingingActivity.this, "对方已挂断");
|
|
|
finish();
|
|
|
break;
|
|
|
case AEvent.AEVENT_VOIP_REV_ERROR:
|
|
@@ -114,13 +125,13 @@ public class RTCVoipAudioRingingActivity extends Activity implements View.OnClic
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onRestart(){
|
|
|
+ public void onRestart() {
|
|
|
super.onRestart();
|
|
|
addListener();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onStop(){
|
|
|
+ public void onStop() {
|
|
|
super.onStop();
|
|
|
//todo 状态设置为未在通话中
|
|
|
DeviceChannel.calling = false;
|
|
@@ -130,6 +141,9 @@ public class RTCVoipAudioRingingActivity extends Activity implements View.OnClic
|
|
|
@Override
|
|
|
protected void onDestroy() {
|
|
|
super.onDestroy();
|
|
|
+ if (countDownTimer != null){
|
|
|
+ countDownTimer.cancel();
|
|
|
+ }
|
|
|
EventBus.getDefault().unregister(this);
|
|
|
}
|
|
|
|
|
@@ -138,11 +152,12 @@ public class RTCVoipAudioRingingActivity extends Activity implements View.OnClic
|
|
|
int id = v.getId();
|
|
|
if (id == R.id.hang_up_imagev) {
|
|
|
MediaPlayHelper.getInstance().stopMusic();
|
|
|
+ countDownTimer.cancel();
|
|
|
//todo 给服务器发送拒接 tcp
|
|
|
// InteractionVO interactionVO = (InteractionVO) tcpModel.getData();
|
|
|
- InteractionVO interactionVO = new Gson().fromJson(tcpModel.getData().toString(), InteractionVO.class);
|
|
|
+ InteractionVO interactionVO = new Gson().fromJson(tcpModel.getData().toString(), InteractionVO.class);
|
|
|
TcpModel voiceUtilTcpModel = VoiceUtil.voiceReject(Integer.parseInt(Constants.Companion.getIds()), tcpModel.getFromId()
|
|
|
- ,interactionVO.getId());
|
|
|
+ , interactionVO.getId());
|
|
|
TcpClient.getInstance().sendMsg(voiceUtilTcpModel.toJson());
|
|
|
|
|
|
XHClient.getInstance().getVoipManager().refuse(new IXHResultCallback() {
|
|
@@ -156,13 +171,36 @@ public class RTCVoipAudioRingingActivity extends Activity implements View.OnClic
|
|
|
finish();
|
|
|
}
|
|
|
});
|
|
|
+ } else if (id == R.id.change_over_image) { //转接给护士主机
|
|
|
+ MediaPlayHelper.getInstance().stopMusic();
|
|
|
+ countDownTimer.cancel();
|
|
|
+ //todo 给服务器发送转接 tcp
|
|
|
+
|
|
|
+ InteractionVO interactionVO = new Gson().fromJson(tcpModel.getData().toString(), InteractionVO.class);
|
|
|
+ TcpModel voiceTransferTcpModel = VoiceUtil.voiceTransfer(Integer.parseInt(Constants.Companion.getIds()), tcpModel.getFromId()
|
|
|
+ , interactionVO);
|
|
|
+ TcpClient.getInstance().sendMsg(voiceTransferTcpModel.toJson());
|
|
|
+
|
|
|
+ XHClient.getInstance().getVoipManager().refuse(new IXHResultCallback() {
|
|
|
+ @Override
|
|
|
+ public void success(Object data) {
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void failed(String errMsg) {
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
} else if (id == R.id.call_the_voice_imagev) {
|
|
|
MediaPlayHelper.getInstance().stopMusic();
|
|
|
+ countDownTimer.cancel();
|
|
|
//todo 给服务器发送接听 tcp
|
|
|
// InteractionVO interactionVO = (InteractionVO) tcpModel.getData();
|
|
|
- InteractionVO interactionVO = new Gson().fromJson(tcpModel.getData().toString(), InteractionVO.class);
|
|
|
+ InteractionVO interactionVO = new Gson().fromJson(tcpModel.getData().toString(), InteractionVO.class);
|
|
|
TcpModel voiceUtilTcpModel = VoiceUtil.voiceAccept(Integer.parseInt(Constants.Companion.getIds()), tcpModel.getFromId()
|
|
|
- ,interactionVO.getId());
|
|
|
+ , interactionVO.getId());
|
|
|
TcpClient.getInstance().sendMsg(voiceUtilTcpModel.toJson());
|
|
|
|
|
|
Intent intent = new Intent(RTCVoipAudioRingingActivity.this, RTCVoipAudioActivity.class);
|
|
@@ -175,13 +213,50 @@ public class RTCVoipAudioRingingActivity extends Activity implements View.OnClic
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void initCountDownTimer() {
|
|
|
+
|
|
|
+ Log.e(TAG,"时间到 转发了");
|
|
|
+
|
|
|
+ countdownTime = SettingConfig.getCountdownTime(this);
|
|
|
+ countDownTimer = new CountDownTimer(countdownTime*1000, 1000) {
|
|
|
+ @Override
|
|
|
+ public void onTick(long l) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFinish() {
|
|
|
+ MediaPlayHelper.getInstance().stopMusic();
|
|
|
+ //todo 给服务器发送转接 tcp
|
|
|
+ InteractionVO interactionVO = new Gson().fromJson(tcpModel.getData().toString(), InteractionVO.class);
|
|
|
+ TcpModel voiceTransferTcpModel = VoiceUtil.voiceTransfer(Integer.parseInt(Constants.Companion.getIds()), tcpModel.getFromId()
|
|
|
+ , interactionVO);
|
|
|
+ TcpClient.getInstance().sendMsg(voiceTransferTcpModel.toJson());
|
|
|
+
|
|
|
+ XHClient.getInstance().getVoipManager().refuse(new IXHResultCallback() {
|
|
|
+ @Override
|
|
|
+ public void success(Object data) {
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void failed(String errMsg) {
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
public void onMoonEvent(MessageEvent messageEvent) {
|
|
|
- if (messageEvent.getTag() == 2){
|
|
|
+ if (messageEvent.getTag() == 2) {
|
|
|
TcpModel tcpModel = (TcpModel) messageEvent.getMessage();
|
|
|
|
|
|
- if (tcpModel.getAction() == TcpAction.VoiceAction.CANCEL || tcpModel.getAction() == TcpAction.VoiceAction.HANDOFF){
|
|
|
+ if (tcpModel.getAction() == TcpAction.VoiceAction.CANCEL || tcpModel.getAction() == TcpAction.VoiceAction.HANDOFF) {
|
|
|
//voiceStatus.setText("对方拒绝");
|
|
|
ExtendMethodsKt.showMessage("通话取消");
|
|
|
MediaPlayHelper.getInstance().stopMusic();
|