|
@@ -1375,30 +1375,10 @@ class NurseHomeActivity : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
|
|
|
private fun startScheduledExecutor() {
|
|
|
val timerTask: TimerTask = object : TimerTask() {
|
|
|
override fun run() {
|
|
|
- //当前不在通话中且laterRestart=true则重启app
|
|
|
- if (Constants.laterRestart && !DeviceChannel.calling) {
|
|
|
- AppUpdateHelper.restartApp(activity)
|
|
|
- } else {
|
|
|
- updateTime(false)
|
|
|
- runOnUiThread {
|
|
|
- updateNetState()
|
|
|
- updateTcpState()
|
|
|
- }
|
|
|
-
|
|
|
- if (!"YUNPAI_H6".equals(Build.MODEL)) {
|
|
|
- //同步点阵屏时间
|
|
|
- val calendar = Calendar.getInstance()
|
|
|
- val hour = calendar[Calendar.HOUR_OF_DAY]
|
|
|
- val time = System.currentTimeMillis()
|
|
|
-
|
|
|
- if (time - checkTime >= 24*60*60*1000 && hour == 23) {
|
|
|
- checkTime = time
|
|
|
+ try {
|
|
|
+ scheduleTask()
|
|
|
+ } catch (e: Exception) {
|
|
|
|
|
|
- if (Constants.LED_EXIST) {
|
|
|
- LedManagerUtils.getInstance().syncTime()
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1407,133 +1387,182 @@ class NurseHomeActivity : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
|
|
|
executor!!.scheduleAtFixedRate(timerTask, 100, 90, TimeUnit.SECONDS)
|
|
|
}
|
|
|
|
|
|
+ private fun scheduleTask() {
|
|
|
+ //当前不在通话中且laterRestart=true则重启app
|
|
|
+ if (Constants.laterRestart && !DeviceChannel.calling) {
|
|
|
+ AppUpdateHelper.restartApp(activity)
|
|
|
+ } else {
|
|
|
+ updateTime(false)
|
|
|
+ runOnUiThread {
|
|
|
+ updateNetState()
|
|
|
+ updateTcpState()
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!"YUNPAI_H6".equals(Build.MODEL)) {
|
|
|
+ //同步点阵屏时间
|
|
|
+ val calendar = Calendar.getInstance()
|
|
|
+ val hour = calendar[Calendar.HOUR_OF_DAY]
|
|
|
+ val time = System.currentTimeMillis()
|
|
|
+
|
|
|
+ if (time - checkTime >= 24*60*60*1000 && hour == 23) {
|
|
|
+ checkTime = time
|
|
|
+
|
|
|
+ if (Constants.LED_EXIST) {
|
|
|
+ LedManagerUtils.getInstance().syncTime()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private fun startTransferScheduledExecutor() {
|
|
|
val timerTask: TimerTask = object : TimerTask() {
|
|
|
override fun run() {
|
|
|
- if (!SettingConfiguration.getInstance().transferCall) {
|
|
|
- return
|
|
|
- }
|
|
|
- if (SettingConfiguration.getInstance().hostTransferDuration <= 0) {
|
|
|
- SettingConfiguration.getInstance().hostTransferDuration = 30
|
|
|
+ try {
|
|
|
+ transferCallTask()
|
|
|
+ } catch (e: Exception) {
|
|
|
+
|
|
|
}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ val executor = Executors.newSingleThreadScheduledExecutor()
|
|
|
+ executor.scheduleAtFixedRate(timerTask, 20, 5, TimeUnit.SECONDS)
|
|
|
+ }
|
|
|
|
|
|
- //紧急呼叫转移
|
|
|
- if (sosItemList.size > 0) {
|
|
|
- val iterator = sosItemList.iterator()
|
|
|
- while (iterator.hasNext()) {
|
|
|
- val it = iterator.next()
|
|
|
- if (System.currentTimeMillis() - it.startTime >= SettingConfiguration.getInstance().hostTransferDuration*1000L) {
|
|
|
- Log.d(TAG, "紧急呼叫转移...")
|
|
|
- if (it.interactionVO != null) {
|
|
|
- runOnUiThread {
|
|
|
- showMessage(R.string.call_sos_forwarding)
|
|
|
- declineSosItem(it.interactionVO)
|
|
|
- }
|
|
|
- OtherUtil.sendSosTransfer(Constants.ids, it.interactionVO.fromDeviceId, it.interactionVO)
|
|
|
- iterator.remove()
|
|
|
- }
|
|
|
- break
|
|
|
+ private fun transferCallTask() {
|
|
|
+ Log.e(TAG, "transfer schedule executor..."
|
|
|
+ + SettingConfiguration.getInstance().transferCall
|
|
|
+ + ", sos: " + sosItemList.size
|
|
|
+ + ", call: " + callingList.size)
|
|
|
+
|
|
|
+ if (!SettingConfiguration.getInstance().transferCall) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (SettingConfiguration.getInstance().hostTransferDuration <= 0) {
|
|
|
+ SettingConfiguration.getInstance().hostTransferDuration = 30
|
|
|
+ }
|
|
|
+
|
|
|
+ //紧急呼叫转移
|
|
|
+ if (sosItemList.size > 0) {
|
|
|
+ val iterator = sosItemList.iterator()
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ val it = iterator.next()
|
|
|
+ if (System.currentTimeMillis() - it.startTime >= SettingConfiguration.getInstance().hostTransferDuration*1000L) {
|
|
|
+ Log.d(TAG, "紧急呼叫转移...")
|
|
|
+ if (it.interactionVO != null) {
|
|
|
+ runOnUiThread {
|
|
|
+ showMessage(R.string.call_sos_forwarding)
|
|
|
+ declineSosItem(it.interactionVO)
|
|
|
}
|
|
|
+ OtherUtil.sendSosTransfer(Constants.ids, it.interactionVO.fromDeviceId, it.interactionVO)
|
|
|
+ iterator.remove()
|
|
|
}
|
|
|
+ break
|
|
|
}
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- //语音呼叫转移
|
|
|
- if (callingList.size > 0) {
|
|
|
- val iterator2 = callingList.iterator()
|
|
|
- while (iterator2.hasNext()) {
|
|
|
- val item = iterator2.next()
|
|
|
- if (System.currentTimeMillis() - item.startTime >= SettingConfiguration.getInstance().hostTransferDuration*1000L) {
|
|
|
- Log.d(TAG, "语音呼叫转移...")
|
|
|
- if (item.interactionVO != null) {
|
|
|
- runOnUiThread {
|
|
|
- showMessage(R.string.call_voice_forwarding)
|
|
|
- }
|
|
|
- if (SettingConfig.getTtsMode(activity) == SettingConfig.TTS_ON) {
|
|
|
- var frameName: String? = ""
|
|
|
- if (DeviceTypeEnum.DOCTOR_HOST.value() == item.interactionVO.fromDeviceType
|
|
|
- || DeviceTypeEnum.NURSE_HOST.value() == item.interactionVO.fromDeviceType
|
|
|
- || DeviceTypeEnum.OTHER_HOST.value() == item.interactionVO.fromDeviceType) {
|
|
|
- //医生机,护士主机,其他主机,总控主机等
|
|
|
- frameName = item.interactionVO.fromDeviceName
|
|
|
- } else if (DeviceTypeEnum.NURSE_WATCH.value() == item.interactionVO.fromDeviceType) {
|
|
|
- //移动设备
|
|
|
- frameName = item.interactionVO.fromMemberName
|
|
|
- } else {
|
|
|
- //其他
|
|
|
- if (Locale.CHINESE.getLanguage().equals(language)) {
|
|
|
- frameName = Util.appendSpace(item.interactionVO.fromFrameFullName.replace("-", ","))
|
|
|
- } else {
|
|
|
- frameName = item.interactionVO.fromFrameFullName.replace("-", "")
|
|
|
- }
|
|
|
- }
|
|
|
- val text = BaseApplication.appContext.getString(R.string.voice_call_speech, frameName)
|
|
|
- SpeechUtil.getInstance().removeSpeak(text)
|
|
|
+ //语音呼叫转移
|
|
|
+ if (callingList.size > 0) {
|
|
|
+ val iterator2 = callingList.iterator()
|
|
|
+ while (iterator2.hasNext()) {
|
|
|
+ val item = iterator2.next()
|
|
|
+ if (System.currentTimeMillis() - item.startTime >= SettingConfiguration.getInstance().hostTransferDuration*1000L) {
|
|
|
+ Log.d(TAG, "语音呼叫转移...")
|
|
|
+ if (item.interactionVO != null) {
|
|
|
+ runOnUiThread {
|
|
|
+ showMessage(R.string.call_voice_forwarding)
|
|
|
+ }
|
|
|
+ if (SettingConfig.getTtsMode(activity) == SettingConfig.TTS_ON) {
|
|
|
+ var frameName: String? = ""
|
|
|
+ if (DeviceTypeEnum.DOCTOR_HOST.value() == item.interactionVO.fromDeviceType
|
|
|
+ || DeviceTypeEnum.NURSE_HOST.value() == item.interactionVO.fromDeviceType
|
|
|
+ || DeviceTypeEnum.OTHER_HOST.value() == item.interactionVO.fromDeviceType) {
|
|
|
+ //医生机,护士主机,其他主机,总控主机等
|
|
|
+ frameName = item.interactionVO.fromDeviceName
|
|
|
+ } else if (DeviceTypeEnum.NURSE_WATCH.value() == item.interactionVO.fromDeviceType) {
|
|
|
+ //移动设备
|
|
|
+ frameName = item.interactionVO.fromMemberName
|
|
|
+ } else {
|
|
|
+ //其他
|
|
|
+ if (Locale.CHINESE.getLanguage().equals(language)) {
|
|
|
+ frameName = Util.appendSpace(item.interactionVO.fromFrameFullName.replace("-", ","))
|
|
|
} else {
|
|
|
- //如果呼叫列表只有一个呼叫了,说明删除这个之后就清空了,此时关闭铃声或音乐
|
|
|
- if (callingList.size == 1) {
|
|
|
- RingPlayHelper.stopRingTone()
|
|
|
- }
|
|
|
+ frameName = item.interactionVO.fromFrameFullName.replace("-", "")
|
|
|
}
|
|
|
- VoiceUtil.transferAudioCall(Constants.ids, item.interactionVO.fromDeviceId, item.interactionVO)
|
|
|
- EventBus.getDefault().post(MessageEvent(item.interactionVO, Constants.EVENT_TRANSFER_CALL))
|
|
|
- iterator2.remove()
|
|
|
}
|
|
|
- break
|
|
|
+ val text = BaseApplication.appContext.getString(R.string.voice_call_speech, frameName)
|
|
|
+ SpeechUtil.getInstance().removeSpeak(text)
|
|
|
+ } else {
|
|
|
+ //如果呼叫列表只有一个呼叫了,说明删除这个之后就清空了,此时关闭铃声或音乐
|
|
|
+ if (callingList.size == 1) {
|
|
|
+ RingPlayHelper.stopRingTone()
|
|
|
+ }
|
|
|
}
|
|
|
+ VoiceUtil.transferAudioCall(Constants.ids, item.interactionVO.fromDeviceId, item.interactionVO)
|
|
|
+ EventBus.getDefault().post(MessageEvent(item.interactionVO, Constants.EVENT_TRANSFER_CALL))
|
|
|
+ iterator2.remove()
|
|
|
}
|
|
|
+ break
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- val executor = Executors.newSingleThreadScheduledExecutor()
|
|
|
- executor.scheduleAtFixedRate(timerTask, 20, 5, TimeUnit.SECONDS)
|
|
|
}
|
|
|
|
|
|
private fun startRemoveCallScheduledExecutor() {
|
|
|
val timeIndex = SettingConfig.getCallStayTime(activity)
|
|
|
if (timeIndex > 0) {
|
|
|
- val time = timeIndex * 60 * 1000
|
|
|
+ val time = timeIndex * 60 * 1000L
|
|
|
val timerTask: TimerTask = object : TimerTask() {
|
|
|
override fun run() {
|
|
|
- if (Constants.CALL_STATE == Constants.CALL_CALLING
|
|
|
- || Constants.CALL_STATE == Constants.CALL_OUTGOING
|
|
|
- || Constants.CALL_STATE == Constants.CALL_VISITING
|
|
|
- || Constants.CALL_STATE == Constants.CALL_V_INCOMING
|
|
|
- ) {
|
|
|
- return
|
|
|
+ try {
|
|
|
+ removeCallTask(time)
|
|
|
+ } catch (e: Exception) {
|
|
|
+
|
|
|
}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ val executor = Executors.newSingleThreadScheduledExecutor()
|
|
|
+ executor.scheduleAtFixedRate(timerTask, 120, 30, TimeUnit.SECONDS)
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- //语音呼叫超时清除
|
|
|
- if (callingList.size > 0) {
|
|
|
- val iterator = callingList.iterator()
|
|
|
- while (iterator.hasNext()) {
|
|
|
- val item = iterator.next()
|
|
|
- if (System.currentTimeMillis() - item.startTime >= time) {
|
|
|
- if (item.interactionVO != null) {
|
|
|
- if (SettingConfig.getTtsMode(activity) == SettingConfig.TTS_ON) {
|
|
|
- var frameName: String
|
|
|
- if (Locale.CHINESE.getLanguage().equals(language)) {
|
|
|
- frameName = Util.appendSpace(item.interactionVO.fromFrameFullName.replace("-", ","))
|
|
|
- } else {
|
|
|
- frameName = item.interactionVO.fromFrameFullName.replace("-", "")
|
|
|
- }
|
|
|
- val text = BaseApplication.appContext.getString(R.string.voice_call_speech, frameName)
|
|
|
- SpeechUtil.getInstance().removeSpeak(text)
|
|
|
- } else {
|
|
|
- //如果呼叫列表只有一个呼叫了,说明删除这个之后就清空了,此时关闭铃声或音乐
|
|
|
- if (callingList.size == 1) {
|
|
|
- RingPlayHelper.stopRingTone()
|
|
|
- }
|
|
|
- }
|
|
|
- EventBus.getDefault().post(MessageEvent(item.interactionVO, Constants.EVENT_REMOVE_CALL))
|
|
|
- }
|
|
|
- break
|
|
|
+ private fun removeCallTask(time: Long) {
|
|
|
+ if (Constants.CALL_STATE == Constants.CALL_CALLING
|
|
|
+ || Constants.CALL_STATE == Constants.CALL_OUTGOING
|
|
|
+ || Constants.CALL_STATE == Constants.CALL_VISITING
|
|
|
+ || Constants.CALL_STATE == Constants.CALL_V_INCOMING
|
|
|
+ ) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //语音呼叫超时清除
|
|
|
+ if (callingList.size > 0) {
|
|
|
+ val iterator = callingList.iterator()
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ val item = iterator.next()
|
|
|
+ if (System.currentTimeMillis() - item.startTime >= time) {
|
|
|
+ if (item.interactionVO != null) {
|
|
|
+ if (SettingConfig.getTtsMode(activity) == SettingConfig.TTS_ON) {
|
|
|
+ var frameName: String
|
|
|
+ if (Locale.CHINESE.getLanguage().equals(language)) {
|
|
|
+ frameName = Util.appendSpace(item.interactionVO.fromFrameFullName.replace("-", ","))
|
|
|
+ } else {
|
|
|
+ frameName = item.interactionVO.fromFrameFullName.replace("-", "")
|
|
|
+ }
|
|
|
+ val text = BaseApplication.appContext.getString(R.string.voice_call_speech, frameName)
|
|
|
+ SpeechUtil.getInstance().removeSpeak(text)
|
|
|
+ } else {
|
|
|
+ //如果呼叫列表只有一个呼叫了,说明删除这个之后就清空了,此时关闭铃声或音乐
|
|
|
+ if (callingList.size == 1) {
|
|
|
+ RingPlayHelper.stopRingTone()
|
|
|
}
|
|
|
}
|
|
|
+ EventBus.getDefault().post(MessageEvent(item.interactionVO, Constants.EVENT_REMOVE_CALL))
|
|
|
}
|
|
|
+ break
|
|
|
}
|
|
|
}
|
|
|
- val executor = Executors.newSingleThreadScheduledExecutor()
|
|
|
- executor.scheduleAtFixedRate(timerTask, 120, 30, TimeUnit.SECONDS)
|
|
|
}
|
|
|
}
|
|
|
|