|
@@ -76,7 +76,10 @@ import java.io.IOException
|
|
import java.io.PrintWriter
|
|
import java.io.PrintWriter
|
|
import java.lang.Process
|
|
import java.lang.Process
|
|
import java.lang.ref.WeakReference
|
|
import java.lang.ref.WeakReference
|
|
|
|
+import java.util.*
|
|
|
|
+import java.util.concurrent.Executors
|
|
import java.util.concurrent.TimeUnit
|
|
import java.util.concurrent.TimeUnit
|
|
|
|
+import kotlin.collections.ArrayList
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -152,20 +155,12 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
}
|
|
}
|
|
|
|
|
|
override fun init() {
|
|
override fun init() {
|
|
- //开始ping网络,30秒ping一次
|
|
|
|
- //NetHelper.startNetCheck()
|
|
|
|
-
|
|
|
|
//启动sip服务
|
|
//启动sip服务
|
|
startService(Intent().setClass(this, WdklSipService::class.java))
|
|
startService(Intent().setClass(this, WdklSipService::class.java))
|
|
|
|
|
|
//获取mac地址
|
|
//获取mac地址
|
|
Constant.LOCAL_MAC = NetHelper.getInstance().macAddress
|
|
Constant.LOCAL_MAC = NetHelper.getInstance().macAddress
|
|
|
|
|
|
- //presenter.loadTcpServerHost()
|
|
|
|
-
|
|
|
|
- //sip初始化
|
|
|
|
- //initSip()
|
|
|
|
-
|
|
|
|
//注册广播
|
|
//注册广播
|
|
regReceiver()
|
|
regReceiver()
|
|
//串口监听
|
|
//串口监听
|
|
@@ -200,6 +195,8 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
//打开网络调试
|
|
//打开网络调试
|
|
AppTool.Time.delay(60000) {
|
|
AppTool.Time.delay(60000) {
|
|
openNetworkDebug()
|
|
openNetworkDebug()
|
|
|
|
+
|
|
|
|
+ checkAppVersion()
|
|
}
|
|
}
|
|
|
|
|
|
//卸载原来二代系统床头分机apk
|
|
//卸载原来二代系统床头分机apk
|
|
@@ -445,31 +442,7 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
}
|
|
}
|
|
|
|
|
|
override fun setTcpServerHost(tcpSeverDTO: TcpSeverDTO) {
|
|
override fun setTcpServerHost(tcpSeverDTO: TcpSeverDTO) {
|
|
- /*if (loaded) {
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- loaded = true
|
|
|
|
-
|
|
|
|
- Constant.TCP_SERVER_URL = tcpSeverDTO.localIp
|
|
|
|
- Constant.TCP_PORT = tcpSeverDTO.tcpPort
|
|
|
|
- Constant.TCP_HEART_BEAT = tcpSeverDTO.readerIdleTime
|
|
|
|
-
|
|
|
|
- //开启TCP连接
|
|
|
|
- startTcp()
|
|
|
|
- showMessage("tcp开始连接...host: " + Constant.TCP_SERVER_URL + ", port: " + Constant.TCP_PORT)
|
|
|
|
|
|
|
|
- Thread(Runnable {
|
|
|
|
- while (!initialized) {
|
|
|
|
- runOnUiThread(Runnable {
|
|
|
|
- initDevice()
|
|
|
|
- })
|
|
|
|
- try {
|
|
|
|
- Thread.sleep(15000)
|
|
|
|
- } catch (e: Exception) {
|
|
|
|
- //
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }).start()*/
|
|
|
|
}
|
|
}
|
|
|
|
|
|
override fun setServerInfo(data: ServerInfo) {
|
|
override fun setServerInfo(data: ServerInfo) {
|
|
@@ -490,6 +463,10 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
startTcp()
|
|
startTcp()
|
|
showMessage("tcp开始连接...host: " + Constant.TCP_SERVER_URL + ", port: " + Constant.TCP_PORT)
|
|
showMessage("tcp开始连接...host: " + Constant.TCP_SERVER_URL + ", port: " + Constant.TCP_PORT)
|
|
|
|
|
|
|
|
+ //网络恢复正常,重置网络计数,取消提醒
|
|
|
|
+ SettingConfig.setNetErrResetCount(this, 0)
|
|
|
|
+ WarningDialogHelper.dismiss()
|
|
|
|
+
|
|
Thread(Runnable {
|
|
Thread(Runnable {
|
|
while (!initialized) {
|
|
while (!initialized) {
|
|
runOnUiThread(Runnable {
|
|
runOnUiThread(Runnable {
|
|
@@ -502,6 +479,20 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}).start()
|
|
}).start()
|
|
|
|
+
|
|
|
|
+ startTimingRefreshData()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private fun startTimingRefreshData() {
|
|
|
|
+ val timerTask: TimerTask = object : TimerTask() {
|
|
|
|
+ override fun run() {
|
|
|
|
+ if (Constant.TCP_CONNECTED) {
|
|
|
|
+ initDevice()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ val executor = Executors.newSingleThreadScheduledExecutor()
|
|
|
|
+ executor.scheduleAtFixedRate(timerTask, 15, 40, TimeUnit.MINUTES)
|
|
}
|
|
}
|
|
|
|
|
|
//显示设备信息
|
|
//显示设备信息
|
|
@@ -614,9 +605,6 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
}
|
|
}
|
|
|
|
|
|
updateSettings(true)
|
|
updateSettings(true)
|
|
-
|
|
|
|
- //检查升级
|
|
|
|
- checkAppVersion()
|
|
|
|
}
|
|
}
|
|
|
|
|
|
override fun updateNurseConfig(list: List<NurseConfigDto>) {
|
|
override fun updateNurseConfig(list: List<NurseConfigDto>) {
|
|
@@ -665,7 +653,7 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
//切换fragment
|
|
//切换fragment
|
|
private fun switchToFragment(layId: Int, fragment: Fragment, tag: String) {
|
|
private fun switchToFragment(layId: Int, fragment: Fragment, tag: String) {
|
|
supportFragmentManager.beginTransaction()
|
|
supportFragmentManager.beginTransaction()
|
|
- .setCustomAnimations(R.anim.push_left_in, R.anim.push_left_out)
|
|
|
|
|
|
+ //.setCustomAnimations(R.anim.push_left_in, R.anim.push_left_out)
|
|
.replace(layId, fragment, tag)
|
|
.replace(layId, fragment, tag)
|
|
.commit()
|
|
.commit()
|
|
curFragment = tag
|
|
curFragment = tag
|
|
@@ -1301,12 +1289,9 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
view_title_layout_iv_wifi.visibility = View.GONE
|
|
view_title_layout_iv_wifi.visibility = View.GONE
|
|
}
|
|
}
|
|
|
|
|
|
- /*if (NetHelper.isBTConnected()) {
|
|
|
|
- view_title_layout_iv_bt.visibility = View.VISIBLE
|
|
|
|
- view_title_layout_iv_bt.setImageResource(R.mipmap.ic_bt_success)
|
|
|
|
- } else {
|
|
|
|
- view_title_layout_iv_bt.visibility = View.GONE
|
|
|
|
- }*/
|
|
|
|
|
|
+ val calendar = Calendar.getInstance()
|
|
|
|
+ val hour = calendar[Calendar.HOUR_OF_DAY]
|
|
|
|
+ val minute = calendar[Calendar.MINUTE]
|
|
|
|
|
|
/*
|
|
/*
|
|
* 检查网络情况,若tcp断开连接多次且IP也是空的则网络异常,重启设备
|
|
* 检查网络情况,若tcp断开连接多次且IP也是空的则网络异常,重启设备
|
|
@@ -1322,6 +1307,7 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
if (count > 0) {
|
|
if (count > 0) {
|
|
count = 0
|
|
count = 0
|
|
SettingConfig.setNetErrResetCount(this, count)
|
|
SettingConfig.setNetErrResetCount(this, count)
|
|
|
|
+ WarningDialogHelper.dismiss()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1335,6 +1321,14 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
}, 5000)
|
|
}, 5000)
|
|
} else {
|
|
} else {
|
|
WarningDialogHelper.showDialog(activity)
|
|
WarningDialogHelper.showDialog(activity)
|
|
|
|
+
|
|
|
|
+ //隔2个小时再重启
|
|
|
|
+ Log.e(TAG, "show net error dialog --> hour: $hour, minute: $minute")
|
|
|
|
+ if (hour%2 == 0 && minute == 0) {
|
|
|
|
+ handler.postDelayed({
|
|
|
|
+ AppUpdateHelper.reboot(activity)
|
|
|
|
+ }, 5000)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|