|
@@ -9,6 +9,7 @@ import android.content.pm.PackageManager
|
|
import android.graphics.Color
|
|
import android.graphics.Color
|
|
import android.net.ConnectivityManager
|
|
import android.net.ConnectivityManager
|
|
import android.os.Bundle
|
|
import android.os.Bundle
|
|
|
|
+import android.os.CountDownTimer
|
|
import android.provider.Settings
|
|
import android.provider.Settings
|
|
import android.support.v4.app.ActivityCompat
|
|
import android.support.v4.app.ActivityCompat
|
|
import android.support.v4.app.Fragment
|
|
import android.support.v4.app.Fragment
|
|
@@ -92,6 +93,9 @@ class HomeActivity : BaseActivity<HomeActivityPresenter, ActivityHomeBinding>(),
|
|
|
|
|
|
private lateinit var receiver: TimeReceiver
|
|
private lateinit var receiver: TimeReceiver
|
|
|
|
|
|
|
|
+ //呼叫倒计时
|
|
|
|
+ lateinit var countDownTimer: CountDownTimer
|
|
|
|
+
|
|
override fun getLayId(): Int {
|
|
override fun getLayId(): Int {
|
|
return R.layout.activity_home
|
|
return R.layout.activity_home
|
|
}
|
|
}
|
|
@@ -181,6 +185,8 @@ class HomeActivity : BaseActivity<HomeActivityPresenter, ActivityHomeBinding>(),
|
|
|
|
|
|
//注册广播
|
|
//注册广播
|
|
regReceiver()
|
|
regReceiver()
|
|
|
|
+
|
|
|
|
+ initCountDownTimer()
|
|
}
|
|
}
|
|
|
|
|
|
private fun regReceiver() {
|
|
private fun regReceiver() {
|
|
@@ -194,6 +200,22 @@ class HomeActivity : BaseActivity<HomeActivityPresenter, ActivityHomeBinding>(),
|
|
unregisterReceiver(receiver)
|
|
unregisterReceiver(receiver)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ fun initCountDownTimer() {
|
|
|
|
+ countDownTimer = object: CountDownTimer(30000, 1000) {
|
|
|
|
+ override fun onTick(millisUntilFinished: Long) {
|
|
|
|
+ //
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun onFinish() {
|
|
|
|
+ //呼叫超时,返回到主界面
|
|
|
|
+ showMessage("无人应答...")
|
|
|
|
+ DeviceChannel.calling = false
|
|
|
|
+ VideoUtil.cancelVideoCall(Constants.deviceId, Constants.interactionId)
|
|
|
|
+ CallDialogHelper.dismissCallDialog()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 返回的tcp信息
|
|
* 返回的tcp信息
|
|
*/
|
|
*/
|
|
@@ -348,6 +370,7 @@ class HomeActivity : BaseActivity<HomeActivityPresenter, ActivityHomeBinding>(),
|
|
SocketManager.getInstance().unConnect()
|
|
SocketManager.getInstance().unConnect()
|
|
|
|
|
|
releaseReceiver()
|
|
releaseReceiver()
|
|
|
|
+ countDownTimer.cancel()
|
|
}
|
|
}
|
|
|
|
|
|
override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean {
|
|
override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean {
|
|
@@ -373,26 +396,29 @@ class HomeActivity : BaseActivity<HomeActivityPresenter, ActivityHomeBinding>(),
|
|
TcpAction.VideoAction.CALLING->{
|
|
TcpAction.VideoAction.CALLING->{
|
|
DeviceChannel.calling = false
|
|
DeviceChannel.calling = false
|
|
CallDialogHelper.dismissCallDialog()
|
|
CallDialogHelper.dismissCallDialog()
|
|
|
|
+ countDownTimer.cancel()
|
|
showMessage("对方忙线中")
|
|
showMessage("对方忙线中")
|
|
}
|
|
}
|
|
|
|
|
|
TcpAction.VideoAction.FAILED->{
|
|
TcpAction.VideoAction.FAILED->{
|
|
DeviceChannel.calling = false
|
|
DeviceChannel.calling = false
|
|
showMessage("呼叫失败,请稍候重试")
|
|
showMessage("呼叫失败,请稍候重试")
|
|
|
|
+ countDownTimer.cancel()
|
|
}
|
|
}
|
|
|
|
|
|
TcpAction.VideoAction.SUCCESS->{
|
|
TcpAction.VideoAction.SUCCESS->{
|
|
DeviceChannel.calling = true
|
|
DeviceChannel.calling = true
|
|
- Constants.fromId = tcpModel.fromId
|
|
|
|
Constants.interactionId = interactionVO.id
|
|
Constants.interactionId = interactionVO.id
|
|
Util.wakeUpAndUnlock(this)
|
|
Util.wakeUpAndUnlock(this)
|
|
|
|
+ countDownTimer.start()
|
|
|
|
|
|
CallDialogHelper.dismissCallDialog()
|
|
CallDialogHelper.dismissCallDialog()
|
|
CallDialogHelper.showCallDialog(this@HomeActivity, 0, "探视请求已发送,请等待...", View.OnClickListener {
|
|
CallDialogHelper.showCallDialog(this@HomeActivity, 0, "探视请求已发送,请等待...", View.OnClickListener {
|
|
//呼出取消
|
|
//呼出取消
|
|
DeviceChannel.calling = false
|
|
DeviceChannel.calling = false
|
|
- VideoUtil.cancelVideoCall(Constants.deviceId, Constants.fromId, Constants.interactionId)
|
|
|
|
|
|
+ VideoUtil.cancelVideoCall(Constants.deviceId, Constants.interactionId)
|
|
CallDialogHelper.dismissCallDialog()
|
|
CallDialogHelper.dismissCallDialog()
|
|
|
|
+ countDownTimer.cancel()
|
|
}, View.OnClickListener {
|
|
}, View.OnClickListener {
|
|
//来电接听
|
|
//来电接听
|
|
}, View.OnClickListener {
|
|
}, View.OnClickListener {
|
|
@@ -416,6 +442,7 @@ class HomeActivity : BaseActivity<HomeActivityPresenter, ActivityHomeBinding>(),
|
|
DeviceChannel.calling = true
|
|
DeviceChannel.calling = true
|
|
Constants.interactionId = interactionVO.id
|
|
Constants.interactionId = interactionVO.id
|
|
CallDialogHelper.dismissCallDialog()
|
|
CallDialogHelper.dismissCallDialog()
|
|
|
|
+ countDownTimer.cancel()
|
|
|
|
|
|
//先和主机视频请求探视,得到允许后方可和分机视频
|
|
//先和主机视频请求探视,得到允许后方可和分机视频
|
|
/*currentFragment = VisitFragment()
|
|
/*currentFragment = VisitFragment()
|
|
@@ -453,6 +480,7 @@ class HomeActivity : BaseActivity<HomeActivityPresenter, ActivityHomeBinding>(),
|
|
showMessage("对方拒绝")
|
|
showMessage("对方拒绝")
|
|
DeviceChannel.calling = false
|
|
DeviceChannel.calling = false
|
|
CallDialogHelper.dismissCallDialog()
|
|
CallDialogHelper.dismissCallDialog()
|
|
|
|
+ countDownTimer.cancel()
|
|
}
|
|
}
|
|
|
|
|
|
TcpAction.VideoAction.HANDOFF -> {
|
|
TcpAction.VideoAction.HANDOFF -> {
|