|
@@ -79,6 +79,7 @@ import com.wdkl.ncs.android.middleware.tcp.TcpClient
|
|
|
import com.wdkl.ncs.android.middleware.tcp.channel.*
|
|
|
import com.wdkl.ncs.android.middleware.tcp.dto.TcpModel
|
|
|
import com.wdkl.ncs.android.middleware.tcp.enums.DeviceTypeEnum
|
|
|
+import com.wdkl.ncs.android.middleware.tcp.enums.RoleTypeEnum
|
|
|
import com.wdkl.ncs.android.middleware.tcp.enums.TcpAction
|
|
|
import com.wdkl.ncs.android.middleware.tcp.enums.TcpType
|
|
|
import com.wdkl.ncs.android.middleware.udp2.UdpHelper
|
|
@@ -713,6 +714,8 @@ class CallingbedActivity :BaseActivity<BedCallingbedActivityPresenter, Callingbe
|
|
|
private fun initDevice() {
|
|
|
if (!TextUtils.isEmpty(Constant.DEVICE_REGISTER_ID)) {
|
|
|
presenter.loadDeviceInfo(Constant.DEVICE_REGISTER_ID)
|
|
|
+
|
|
|
+ presenter.getRoleList()
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1363,7 +1366,8 @@ class CallingbedActivity :BaseActivity<BedCallingbedActivityPresenter, Callingbe
|
|
|
}
|
|
|
|
|
|
override fun loadRoles(roles: List<RoleDO>) {
|
|
|
-
|
|
|
+ //缓存角色列表
|
|
|
+ Constant.ROLES = roles
|
|
|
}
|
|
|
|
|
|
override fun loadCommunicateDevice(communicateDevice: List<BedCommunicateDeviceVO>) {
|
|
@@ -1637,11 +1641,13 @@ class CallingbedActivity :BaseActivity<BedCallingbedActivityPresenter, Callingbe
|
|
|
val decodedJson = StringEscapeUtils.unescapeHtml4(jsonWithEscapes)
|
|
|
val buttonListType = object : TypeToken<List<ButtonType>>() {}.type
|
|
|
val buttonList: List<ButtonType> = Gson().fromJson(Constant.device_button_function, buttonListType)
|
|
|
- val type = "KEY$status"
|
|
|
+ val key = "KEY$status"
|
|
|
val currentTime = System.currentTimeMillis()
|
|
|
|
|
|
for (button in buttonList) {
|
|
|
- if (type == button.key) {
|
|
|
+ val buttonKey = StringEscapeUtils.unescapeXml(button.key)
|
|
|
+ Log.e(TAG, "按键key为" + key + " buttonKey为" + buttonKey + ", buttonType为" + button.type)
|
|
|
+ if (key == buttonKey) {
|
|
|
when (button.type) {
|
|
|
"SOS" -> handleSOSButton(currentTime)
|
|
|
"VOICE" -> handleVoiceButton(button.value, currentTime)
|
|
@@ -1670,10 +1676,24 @@ class CallingbedActivity :BaseActivity<BedCallingbedActivityPresenter, Callingbe
|
|
|
private fun handleVoiceButton(value: Any?, currentTime: Long) {
|
|
|
if (currentTime - clickTime > 2000) {
|
|
|
if (Constant.TCP_CONNECTED) {
|
|
|
- when {
|
|
|
- TextUtils.isEmpty(Constant.SIP_ID) -> showMessage(R.string.no_custom)
|
|
|
- Constant.CALL_STATE == Constant.CALL_STANDBY -> startCallRoleName(value.toString())
|
|
|
- else -> showMessage(R.string.call_fail)
|
|
|
+ if (value == "CANCEL") {
|
|
|
+ //取消呼叫
|
|
|
+ if (Constant.CALL_STATE == Constant.CALL_CALLING) {
|
|
|
+ //通话中挂断
|
|
|
+ EventBus.getDefault().post(MessageEvent("handoff", Constant.EVENT_SERIAL_EVENT))
|
|
|
+ } else if (Constant.CALL_STATE == Constant.CALL_OUTGOING) {
|
|
|
+ //呼叫取消
|
|
|
+ EventBus.getDefault().post(MessageEvent("cancel", Constant.EVENT_SERIAL_EVENT))
|
|
|
+ } else if (Constant.CALL_STATE == Constant.CALL_INCOMING) {
|
|
|
+ //来电拒接
|
|
|
+ EventBus.getDefault().post(MessageEvent("reject", Constant.EVENT_SERIAL_EVENT))
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ when {
|
|
|
+ TextUtils.isEmpty(Constant.SIP_ID) -> showMessage(R.string.no_custom)
|
|
|
+ Constant.CALL_STATE == Constant.CALL_STANDBY -> startCallRoleName(value.toString())
|
|
|
+ else -> showMessage(R.string.call_fail)
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
SerialPortUtilLoar.getInstance().sendSOS(Constant.DEVICE_REGISTER_ID)
|
|
@@ -1687,8 +1707,13 @@ class CallingbedActivity :BaseActivity<BedCallingbedActivityPresenter, Callingbe
|
|
|
private fun handleEventButton(value: Any?, currentTime: Long) {
|
|
|
if (currentTime - clickTime > 2000) {
|
|
|
if (Constant.TCP_CONNECTED) {
|
|
|
- val tcpModel = EventUtil.eventKeyClick(Constant.DEVICE_ID, value as Int?)
|
|
|
- TcpClient.getInstance().sendMsg(tcpModel.toJson())
|
|
|
+ try {
|
|
|
+ val eventValue = value as Double?
|
|
|
+ val tcpModel = EventUtil.eventKeyClick(Constant.DEVICE_ID, eventValue?.toInt())
|
|
|
+ TcpClient.getInstance().sendMsg(tcpModel.toJson())
|
|
|
+ } catch (e: Exception) {
|
|
|
+ e.printStackTrace()
|
|
|
+ }
|
|
|
}
|
|
|
clickTime = currentTime
|
|
|
} else {
|
|
@@ -1697,27 +1722,35 @@ class CallingbedActivity :BaseActivity<BedCallingbedActivityPresenter, Callingbe
|
|
|
}
|
|
|
|
|
|
private fun handleReinforceButton(currentTime: Long) {
|
|
|
- if (currentTime - clickTime > 3000) {
|
|
|
- if (Constant.TCP_CONNECTED) {
|
|
|
- if (Constant.DEVICE_ID != -1) {
|
|
|
- OtherUtil.sendReinforce(Constant.DEVICE_ID)
|
|
|
- ReinforcementsDialogHelper.showDialog(activity, 1)
|
|
|
- SoundPoolManager.getInstance().playSound(4, 1.0f, 1.0f, 0)
|
|
|
+ runOnUiThread {
|
|
|
+ if (currentTime - clickTime > 3000) {
|
|
|
+ if (Constant.TCP_CONNECTED) {
|
|
|
+ if (Constant.DEVICE_ID != -1) {
|
|
|
+ OtherUtil.sendReinforce(Constant.DEVICE_ID)
|
|
|
+ ReinforcementsDialogHelper.showDialog(activity, 1)
|
|
|
+ SoundPoolManager.getInstance().playSound(4, 1.0f, 1.0f, 0)
|
|
|
+ } else {
|
|
|
+ showMessage("null device id!")
|
|
|
+ }
|
|
|
} else {
|
|
|
- showMessage("null device id!")
|
|
|
+ showMessage(R.string.net_error)
|
|
|
}
|
|
|
+ clickTime = currentTime
|
|
|
} else {
|
|
|
- showMessage(R.string.net_error)
|
|
|
+ showMessage(R.string.wait_moment)
|
|
|
}
|
|
|
- clickTime = currentTime
|
|
|
- } else {
|
|
|
- showMessage(R.string.wait_moment)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private fun handleNursingButton(currentTime: Long) {
|
|
|
if (currentTime - clickTime > 2000) {
|
|
|
- // YhUtil.sendReinforceResponsed(Constant.DEVICE_ID) // Uncomment if needed
|
|
|
+ if (!Constant.inNursing) {
|
|
|
+ runOnUiThread {
|
|
|
+ nursingInteId = SettingConfig.getNursingId(activity)
|
|
|
+ val huliTime = SettingConfig.getHuliTime(activity)
|
|
|
+ setHuli(huliTime, true)
|
|
|
+ }
|
|
|
+ }
|
|
|
clickTime = currentTime
|
|
|
} else {
|
|
|
showMessage(R.string.wait_moment)
|