From 8e907f5221111bcb24ae3020f0be8d184ca03d37 Mon Sep 17 00:00:00 2001 From: Jack <1484288157@qq.com> Date: Wed, 4 Mar 2020 18:19:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=81=A2=E5=A4=8D=E9=A1=B6=E9=83=A8=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E9=9D=9Ewifi=E4=B8=8D=E8=87=AA=E5=8A=A8=E6=92=AD?= =?UTF-8?q?=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gamedetail/GameDetailFragment.kt | 6 ++--- .../gamedetail/video/TopVideoView.kt | 23 ++++++++++--------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailFragment.kt b/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailFragment.kt index 027f0abd4a..956713ade6 100644 --- a/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailFragment.kt @@ -673,13 +673,11 @@ class GameDetailFragment : NormalFragment() { mTopVideoView.video = topVideo mTopVideoView.updateThumb(topVideo.poster) - val trafficVideo = PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SettingsFragment.TRAFFIC_VIDEO_SP_KEY, false) - if (NetworkUtils.isWifiConnected(requireContext()) || !trafficVideo) { + //val trafficVideo = PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SettingsFragment.TRAFFIC_VIDEO_SP_KEY, false) + if (NetworkUtils.isWifiConnected(requireContext()) /*|| !trafficVideo*/) { if (mViewModel.isTopVideoPartlyCached(topVideo.url)) { - mBaseHandler.postDelayed({ mTopVideoView.updateMuteStatus() }, 500) mTopVideoView.startPlayLogic(isAutoPlay = true) } else { - mBaseHandler.postDelayed({ mTopVideoView.updateMuteStatus() }, INITIAL_DELAY + 500) // 未有缓存时,为避免影响页面加载,延迟自动播放视频 postDelayedRunnable({ if (activity != null && activity?.isFinishing != true) { diff --git a/app/src/main/java/com/gh/gamecenter/gamedetail/video/TopVideoView.kt b/app/src/main/java/com/gh/gamecenter/gamedetail/video/TopVideoView.kt index 880e370194..4becd40f3f 100644 --- a/app/src/main/java/com/gh/gamecenter/gamedetail/video/TopVideoView.kt +++ b/app/src/main/java/com/gh/gamecenter/gamedetail/video/TopVideoView.kt @@ -119,6 +119,7 @@ class TopVideoView @JvmOverloads constructor(context: Context, attrs: AttributeS } fun startPlayLogic(isAutoPlay: Boolean) { + postDelayed({ updateMuteStatus() }, 500) DownloadManager.getInstance(context).updateSpeedLimitationReleaseDelay(5) if (isAutoPlay) { MtaHelper.onEvent("游戏详情_顶部视频", "视频播放方式", "自动播放") @@ -194,17 +195,17 @@ class TopVideoView @JvmOverloads constructor(context: Context, attrs: AttributeS // 不需要弹弹窗,直接播放 override fun showWifiDialog() { startPlayLogic(false) - val trafficVideo = PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SettingsFragment.TRAFFIC_VIDEO_SP_KEY, false) + //val trafficVideo = PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SettingsFragment.TRAFFIC_VIDEO_SP_KEY, false) + //if (trafficVideo) { // 不延迟的话 isCacheFile 可能直接返回 false - if (trafficVideo) { - postDelayed({ - if (!NetworkUtils.isAvailable(mContext) && !GSYVideoManager.instance().isCacheFile) { - Utils.toast(context, "网络异常,请检查手机网络状态") - } else if (!NetworkUtils.isWifiConnected(mContext) && !GSYVideoManager.instance().isCacheFile) { - Utils.toast(context, "当前为非Wi-Fi环境,请注意流量消耗") - } - }, 100) - } + postDelayed({ + if (!NetworkUtils.isAvailable(mContext) && !GSYVideoManager.instance().isCacheFile) { + Utils.toast(context, "网络异常,请检查手机网络状态") + } else if (!NetworkUtils.isWifiConnected(mContext) && !GSYVideoManager.instance().isCacheFile) { + Utils.toast(context, "当前为非Wi-Fi环境,请注意流量消耗") + } + }, 100) + // } } @@ -256,7 +257,7 @@ class TopVideoView @JvmOverloads constructor(context: Context, attrs: AttributeS replayIv.setOnClickListener { MtaHelper.onEvent("游戏详情_顶部视频", "${getMtaKeyPrefix()}-点击重新播放", combinedTitleAndId) startButton.performClick() - postDelayed({updateMuteStatus()},500) + postDelayed({ updateMuteStatus() }, 500) } updateThumb(video!!.poster) } else {