|
@@ -8,6 +8,7 @@ import android.content.Intent
|
|
|
import android.content.IntentFilter
|
|
|
import android.graphics.Color
|
|
|
import android.net.ConnectivityManager
|
|
|
+import android.net.NetworkInfo
|
|
|
import android.net.Uri
|
|
|
import android.os.Build
|
|
|
import android.os.CountDownTimer
|
|
@@ -68,6 +69,7 @@ import kotlinx.android.synthetic.main.right_list.*
|
|
|
import org.greenrobot.eventbus.EventBus
|
|
|
import org.greenrobot.eventbus.Subscribe
|
|
|
import org.greenrobot.eventbus.ThreadMode
|
|
|
+import org.webrtc.NetworkMonitorAutoDetect.getConnectionType
|
|
|
|
|
|
/**
|
|
|
* 首页Activity
|
|
@@ -156,10 +158,7 @@ class NurseHomeActivity : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
|
|
|
|
|
|
// 添加登录回调
|
|
|
SocketManager.getInstance().addUserStateCallback(this)
|
|
|
- // 连接socket:登录
|
|
|
- if (!TextUtils.isEmpty(Constants.sip_id)) {
|
|
|
- SocketManager.getInstance().connect(Urls.WS, Constants.sip_id, 0)
|
|
|
- }
|
|
|
+ connectSocket()
|
|
|
|
|
|
//设置设置配置
|
|
|
setSettingConfiguration()
|
|
@@ -171,6 +170,13 @@ class NurseHomeActivity : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
|
|
|
SpeechUtil.getInstance().init(this)
|
|
|
}
|
|
|
|
|
|
+ private fun connectSocket() {
|
|
|
+ // 连接socket登录
|
|
|
+ if (!TextUtils.isEmpty(Constants.sip_id)) {
|
|
|
+ SocketManager.getInstance().connect(Urls.WS, Constants.sip_id, 0)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 时间变化监听
|
|
|
*/
|
|
@@ -180,6 +186,7 @@ class NurseHomeActivity : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
|
|
|
intentFilter.addAction(Intent.ACTION_TIME_TICK)
|
|
|
intentFilter.addAction(Intent.ACTION_TIMEZONE_CHANGED)
|
|
|
intentFilter.addAction(Intent.ACTION_TIME_CHANGED)
|
|
|
+ intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION)
|
|
|
//手柄状态监听
|
|
|
intentFilter.addAction(Constants.HOOK_OFF)
|
|
|
intentFilter.addAction(Constants.HOOK_ON)
|
|
@@ -613,6 +620,17 @@ fun call(tyte:Int){
|
|
|
VoiceUtil.acceptAudioCall(Integer.parseInt(Constants.ids), Constants.fromId, Constants.interactionId)
|
|
|
CallDialogHelper.dismissCallDialog()
|
|
|
}
|
|
|
+ } else if (intent.action == ConnectivityManager.CONNECTIVITY_ACTION) {
|
|
|
+ updateNetState()
|
|
|
+ if (NetHelper.getInstance().networkAvailable()) {
|
|
|
+ if (!Constants.tcp_connected) {
|
|
|
+ TcpClient.getInstance().doConnect()
|
|
|
+ }
|
|
|
+ if (SocketManager.getInstance().userState == 0) {
|
|
|
+ //如果socket断开了则重连
|
|
|
+ connectSocket()
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -678,6 +696,10 @@ fun call(tyte:Int){
|
|
|
private fun updateTcpState() {
|
|
|
if (Constants.tcp_connected) {
|
|
|
tcp_state_imagev.setImageResource(R.drawable.ic_tcp_success)
|
|
|
+ if (SocketManager.getInstance().userState == 0) {
|
|
|
+ //如果socket断开了则重连
|
|
|
+ connectSocket()
|
|
|
+ }
|
|
|
} else {
|
|
|
tcp_state_imagev.setImageResource(R.drawable.ic_tcp_fail)
|
|
|
}
|