diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/camera/CameraListView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/camera/CameraListView.kt index 80133aa45c..a1b29a1409 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/camera/CameraListView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/camera/CameraListView.kt @@ -1,7 +1,6 @@ package com.mogo.eagle.core.function.hmi.ui.camera import android.animation.ValueAnimator -import android.annotation.SuppressLint import android.content.Context import android.graphics.Color import android.text.SpannableStringBuilder @@ -14,7 +13,6 @@ import android.widget.FrameLayout import androidx.recyclerview.widget.LinearLayoutManager import com.mogo.eagle.core.data.camera.Camera import com.mogo.eagle.core.function.hmi.R -import com.mogo.eagle.core.utilcode.util.ToastUtils import com.mogo.eagle.core.widget.media.video.SimpleVideoPlayer import com.shuyu.gsyvideoplayer.GSYVideoManager import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder @@ -43,6 +41,7 @@ class CameraListView : FrameLayout { SpannableStringBuilder("当前路口信号丢失,3S 后自动关闭") } private var isCloseStatus = true + private var isPlaySuccess = false private val valueAnimator by lazy { ValueAnimator.ofInt(3, 0) } @@ -65,6 +64,7 @@ class CameraListView : FrameLayout { rvCameraList.adapter = CameraListAdapter(context, cameraInfoList) { it.tag?.let { tag -> isCloseStatus = false + isPlaySuccess = false showLiveView() clickListener?.onShowLive(true) val flvUrl = tag as String @@ -76,11 +76,21 @@ class CameraListView : FrameLayout { } } ivCloseIcon.setOnClickListener { + isPlaySuccess = false when { isCloseStatus -> clickListener?.onClose(it) else -> { hideLiveView() isCloseStatus = true + // 无信号倒计时时点击返回 + if (ivSignalIcon.visibility == View.VISIBLE) { + hideNoSignalView() + } else { + stopLive() + } + if (valueAnimator.isRunning) { + valueAnimator.cancel() + } } } clickListener?.onShowLive(false) @@ -94,6 +104,8 @@ class CameraListView : FrameLayout { } SimpleVideoPlayer.PLAY_EVT_PLAY_BEGIN -> { progressBar.visibility = View.GONE + svpPlayer.visibility = View.VISIBLE + isPlaySuccess = true } else -> { showNoSignalView() @@ -119,14 +131,15 @@ class CameraListView : FrameLayout { valueAnimator.addUpdateListener { when (val currentValue = it.animatedValue as Int) { 0 -> { - if (cameraInfoList.isNullOrEmpty()) { + isPlaySuccess = false + if (isPlaySuccess) { clickListener?.onClose(ivSignalIcon) } else { hideNoSignalView() } } else -> { - if (cameraInfoList.isNullOrEmpty()) { + if (isPlaySuccess) { spannableStringBuilder2.replace(9, 10, currentValue.toString()) tvTipContent.text = spannableStringBuilder2 } else { @@ -139,12 +152,9 @@ class CameraListView : FrameLayout { } fun updateCameraData(cameraInfoList: List?) { - if (cameraInfoList.isNullOrEmpty()) { - showNoSignalView() - valueAnimator.start() - } else { + cameraInfoList?.let { this.cameraInfoList.clear() - this.cameraInfoList.addAll(cameraInfoList) + this.cameraInfoList.addAll(it) } } @@ -152,11 +162,6 @@ class CameraListView : FrameLayout { this.clickListener = clickListener } - @SuppressLint("NotifyDataSetChanged") - fun refreshCameraList() { - rvCameraList.adapter?.notifyDataSetChanged() - } - override fun onAttachedToWindow() { super.onAttachedToWindow() } @@ -164,11 +169,11 @@ class CameraListView : FrameLayout { override fun onDetachedFromWindow() { super.onDetachedFromWindow() stopLive() + svpPlayer.removeAllViews() valueAnimator.cancel() } private fun stopLive() { - svpPlayer.removeAllViews() try { GSYVideoManager.releaseAllVideos() } catch (e: Exception) { @@ -179,7 +184,6 @@ class CameraListView : FrameLayout { private fun showLiveView() { tvCameraTitle.visibility = View.GONE rvCameraList.visibility = View.GONE - svpPlayer.visibility = View.VISIBLE progressBar.visibility = View.VISIBLE ivCloseIcon.setBackgroundResource(R.drawable.icon_back) } @@ -189,7 +193,6 @@ class CameraListView : FrameLayout { rvCameraList.visibility = View.VISIBLE svpPlayer.visibility = View.GONE progressBar.visibility = View.GONE - stopLive() ivCloseIcon.setBackgroundResource(R.drawable.icon_close_nor) }