From 427e9813474735b712ed7fe4356178b42383ed2f Mon Sep 17 00:00:00 2001 From: chenfufeng Date: Thu, 4 Nov 2021 20:38:22 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=8C=E8=BD=A6=E8=B6=85=E8=A7=86=E8=B7=9D?= =?UTF-8?q?=E4=BA=A4=E4=BA=92=E6=96=B9=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenfufeng --- .../function/hmi/ui/camera/CameraListView.kt | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) 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) }