Browse Source

修复空指针异常问题

weizhengliang 3 years ago
parent
commit
b55c5f7db9

+ 14 - 19
home/src/main/code/com/wdkl/ncs/android/component/home/fragment/SkyCallFragment.kt

@@ -351,8 +351,11 @@ class SkyCallFragment: BaseCallFragment(), CallSessionCallback {
     fun onMoonEvent(messageEvent: MessageEvent) {
         if (messageEvent.tag == Constants.VIDEO_MSG){
             val tcpModel = messageEvent.getMessage() as TcpModel
-            val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
-            Log.e(TAG, "收到tcp消息" + tcpModel.getType() + " " + tcpModel.getAction() + ", data: " + tcpModel.data.toString())
+            var interactionVO: InteractionVO? = null
+            if (tcpModel.data != null) {
+                interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
+            }
+            Log.e(TAG, "收到tcp消息: " + tcpModel.getType() + " " + tcpModel.getAction())
             when (tcpModel.action){
                 TcpAction.VideoAction.CALLING->{
                     //我方呼出,对方通话中
@@ -376,7 +379,9 @@ class SkyCallFragment: BaseCallFragment(), CallSessionCallback {
                 TcpAction.VideoAction.SUCCESS->{
                     callSuccess = true
                     DeviceChannel.calling = true
-                    Constants.interactionId = interactionVO.id
+                    if (interactionVO != null) {
+                        Constants.interactionId = interactionVO.id
+                    }
                     Constants.visitHostId = tcpModel.fromId
                     Util.wakeUpAndUnlock(activity)
                     sky_voice_call_hangup.isEnabled = true
@@ -385,28 +390,18 @@ class SkyCallFragment: BaseCallFragment(), CallSessionCallback {
                 }
 
                 TcpAction.VideoAction.ACCEPT-> {
-                    /*Constants.fromId = tcpModel.fromId
-                    DeviceChannel.calling = true
-                    CallDialogHelper.dismissCallDialog()
-                    Constants.interactionId = interactionVO.id
-                    // 加入房间
-                    val roomId = "visit-room-" + Constants.interactionId
-                    CallMultiActivity.openActivity(activity, roomId, false)*/
+                   //
                 }
 
                 //主机接听
                 TcpAction.VideoAction.VIDEO_IN_CALL-> {
-                    Constants.hostSipId = interactionVO.toSipId
-                    /*Constants.fromId = tcpModel.fromId
-                    Constants.visitHostId = tcpModel.fromId
-                    DeviceChannel.calling = true
-                    Constants.interactionId = interactionVO.id*/
+                    if (interactionVO != null) {
+                        Constants.hostSipId = interactionVO.toSipId
+                    }
                 }
 
                 TcpAction.VideoAction.VIDEO_ON -> {
-                    /*Constants.fromId = tcpModel.fromId
-                    DeviceChannel.calling = true
-                    Constants.interactionId = interactionVO.id*/
+                    //
                 }
 
                 TcpAction.VideoAction.REJECT->{
@@ -419,7 +414,7 @@ class SkyCallFragment: BaseCallFragment(), CallSessionCallback {
                 }
 
                 TcpAction.VideoAction.HANDOFF -> {
-                    if (Constants.interactionId == interactionVO.id) {
+                    if (interactionVO != null && Constants.interactionId == interactionVO.id) {
                         callEnd(false)
                     }
                 }