From 9dabe9fa033ef62383ebf8d4ba270d5ab5ac4775 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=99=A8?= Date: Wed, 3 Apr 2024 17:01:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E3=80=90=E5=85=89=E7=8E=AF=E5=8A=A9?= =?UTF-8?q?=E6=89=8B=E3=80=91=E8=A7=86=E9=A2=91=E6=A8=AA=E5=B1=8F=E6=BB=91?= =?UTF-8?q?=E5=8A=A8=E4=B8=93=E9=A2=98=E7=9A=84=E6=98=BE=E7=A4=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20https://jira.shanqu.cc/browse/GHZS-5117?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../home/video/ScrollCalculatorHelper.kt | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/src/main/java/com/gh/gamecenter/home/video/ScrollCalculatorHelper.kt b/app/src/main/java/com/gh/gamecenter/home/video/ScrollCalculatorHelper.kt index 1433a12c13..614adac834 100644 --- a/app/src/main/java/com/gh/gamecenter/home/video/ScrollCalculatorHelper.kt +++ b/app/src/main/java/com/gh/gamecenter/home/video/ScrollCalculatorHelper.kt @@ -4,6 +4,8 @@ import android.graphics.Rect import android.os.Handler import android.os.Looper import android.view.View +import android.view.ViewGroup +import androidx.core.view.forEach import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.gh.gamecenter.common.constant.Constants @@ -88,6 +90,12 @@ class ScrollCalculatorHelper(val mListRv: RecyclerView, private val mPlayId: Int if (child is RecyclerView && child.layoutManager is LinearLayoutManager) { val hasChildVideoPlaying = playChildVideo(child) if (hasChildVideoPlaying) break + } else if (child is ViewGroup) { + val childList = findRecyclerView(child) + if (childList != null) { + val hasChildVideoPlaying = playChildVideo(childList) + if (hasChildVideoPlaying) break + } } val player: View? = child?.findViewById(mPlayId) @@ -163,6 +171,20 @@ class ScrollCalculatorHelper(val mListRv: RecyclerView, private val mPlayId: Int return false } + /** + * 如果布局层次结构复杂,这里递归可能过深,为避免此情况,这里暂时只考虑一层的情况 + */ + private fun findRecyclerView(container: ViewGroup): RecyclerView? { + val childCount = container.childCount + for (index in 0 until childCount) { + val child = container.getChildAt(index) + if (child is RecyclerView && child.layoutManager is LinearLayoutManager) { + return child + } + } + return null + } + private inner class PlayRunnable(var videoView: AutomaticVideoView?) : Runnable { override fun run() { if (videoView != null && !videoView!!.isInPlayingState) {