Compare commits

...

6 Commits

11 changed files with 168 additions and 12 deletions

View File

@ -363,7 +363,7 @@ class CommonContentHomeSlideWithCardsUi(
homeSlideCardItemBinding.cardIv.visibility = View.VISIBLE
// 防止重复加载图片导致闪烁
if (homeSubSlide.image != cardIv.getTag(R.string.tag_img_url_id)) {
ImageUtils.display(cardIv, homeSubSlide.image, false, AlphaGradientProcess())
ImageUtils.display(cardIv, homeSubSlide.image, true, AlphaGradientProcess())
cardIv.setTag(R.string.tag_img_url_id, homeSubSlide.image)
}
ConstraintSet().apply {
@ -398,7 +398,7 @@ class CommonContentHomeSlideWithCardsUi(
descTv.text = homeSubSlide.cardDesc
// 防止重复加载图片导致闪烁
if (homeSubSlide.image != cardIv.getTag(R.string.tag_img_url_id)) {
ImageUtils.display(cardIv, homeSubSlide.image, false, AlphaGradientProcess())
ImageUtils.display(cardIv, homeSubSlide.image, true, AlphaGradientProcess())
cardIv.setTag(R.string.tag_img_url_id, homeSubSlide.image)
}
ConstraintSet().apply {

View File

@ -109,7 +109,9 @@ class CustomHomeGameItemViewHolder(
item.linkColumn?.id ?: ""
)
}
binding.gameBrief.text = game.recommendText
binding.gameBrief.goneIf(game.recommendText.isEmpty()) {
binding.gameBrief.text = game.recommendText
}
binding.gameImage.visibleIf(game.showImage) {
if (game.isWechatMiniGame()) {
ImageUtils.display(binding.gameImage, game.banner)

View File

@ -41,6 +41,8 @@ class AutomaticVideoView @JvmOverloads constructor(context: Context, attrs: Attr
var thumbImage: SimpleDraweeView = findViewById(R.id.thumbImage)
var containerView: RadiusCardView = findViewById(R.id.container)
var detailBtn: TextView? = null
var isMute = true
private var mIsFirstPlay = true
private var mMuteDisposable: Disposable? = null
private var mMaskDisposable: Disposable? = null
private val mUUID = UUID.randomUUID().toString()
@ -89,10 +91,11 @@ class AutomaticVideoView @JvmOverloads constructor(context: Context, attrs: Attr
mVideoAllCallBack.onClickStartThumb(mOriginUrl, mTitle, this)
}
prepareVideo()
val topVideoVoiceStatus = SPUtils.getBoolean(Constants.SP_VIDEO_PLAY_MUTE, true)
if (topVideoVoiceStatus) {
violenceUpdateMuteStatus()
if (mIsFirstPlay) {
isMute = SPUtils.getBoolean(Constants.SP_VIDEO_PLAY_MUTE, true)
mIsFirstPlay = false
}
violenceUpdateMuteStatus()
resetDetailMask()
}
@ -106,15 +109,21 @@ class AutomaticVideoView @JvmOverloads constructor(context: Context, attrs: Attr
mMuteDisposable?.dispose()
mMuteDisposable = null
}
mute()
if (isMute) {
mute()
} else {
unMute()
}
}
}
fun mute() {
isMute = true
CustomManager.getCustomManager(getKey()).isNeedMute = true
}
fun unMute() {
isMute = false
CustomManager.getCustomManager(getKey()).isNeedMute = false
}

View File

@ -43,6 +43,8 @@ import com.gh.gamecenter.common.entity.LinkEntity
import com.gh.gamecenter.common.eventbus.EBReuse
import com.gh.gamecenter.common.exposure.ExposureSource
import com.gh.gamecenter.common.json.json
import com.gh.gamecenter.common.observer.MuteCallback
import com.gh.gamecenter.common.observer.VolumeObserver
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.common.view.TabIndicatorView
import com.gh.gamecenter.core.iinterface.IScrollable
@ -163,6 +165,20 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar
private val twoLinesTabToolbarHeight = 48F.dip2px()
private var autoVideoView: AutomaticVideoView? = null
private val volumeObserver by lazy {
VolumeObserver(object : MuteCallback {
override fun onMute(isMute: Boolean) {
if (::binding.isInitialized) {
binding.muteIv.setImageResource(if (isMute) R.drawable.ic_basic_offsound else R.drawable.ic_basic_onsound)
}
if (isMute) {
autoVideoView?.mute()
} else {
autoVideoView?.unMute()
}
}
})
}
private var searchStyle: BottomTab.SearchStyle? = null
set(value) {
@ -1018,6 +1034,7 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar
ImageUtils.display(gameImageIv, imgUrl)
}
autoVideoView?.onVideoReset()
muteIv.isVisible = video != null
autoVideoView?.goneIf(video == null) {
if (autoVideoView?.isInPlayingState == false) {
GSYVideoOptionBuilder()
@ -1036,6 +1053,17 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar
headerContainer.performClick()
}
}
var videoVoiceStatus = SPUtils.getBoolean(Constants.SP_VIDEO_PLAY_MUTE, true)
muteIv.setImageResource(if (videoVoiceStatus) R.drawable.ic_basic_offsound else R.drawable.ic_basic_onsound)
muteIv.setDebouncedClickListener {
videoVoiceStatus = !videoVoiceStatus
muteIv.setImageResource(if (videoVoiceStatus) R.drawable.ic_basic_offsound else R.drawable.ic_basic_onsound)
if (videoVoiceStatus) {
autoVideoView?.mute()
} else {
autoVideoView?.unMute()
}
}
}
}
}
@ -1050,6 +1078,19 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar
pullDownPushHandler?.doPreProcess(this as? ISmartRefresh, popupPush)
}
private fun observeVolume() {
context?.applicationContext?.contentResolver?.registerContentObserver(
android.provider.Settings.System.CONTENT_URI,
true,
volumeObserver
)
}
private fun unObserveVolume() {
context?.applicationContext?.contentResolver?.unregisterContentObserver(volumeObserver)
}
private fun updateRefreshHeaderStyle(force: Boolean = false) {
if (lightRefreshHeaderStyle == isDisplayingLightContent && !force) return
lightRefreshHeaderStyle = isDisplayingLightContent
@ -1094,6 +1135,7 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar
} else {
resumePullDownPushVideo()
}
observeVolume()
}
}
}
@ -1107,6 +1149,7 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar
if (!videoUrl.isNullOrEmpty()) {
ScrollCalculatorHelper.savePlaySchedule(MD5Utils.getContentMD5(videoUrl), currentPosition)
}
unObserveVolume()
}
}
}
@ -1122,8 +1165,7 @@ class SearchToolbarTabWrapperFragment : BaseTabWrapperFragment(), ISearchToolbar
if (position != 0L) {
autoVideoView?.seekTo(position)
autoVideoView?.onVideoResume(false)
val topVideoVoiceStatus = SPUtils.getBoolean(Constants.SP_VIDEO_PLAY_MUTE, true)
if (topVideoVoiceStatus) {
if (autoVideoView?.isMute == true) {
autoVideoView?.mute()
} else {
autoVideoView?.unMute()

View File

@ -41,6 +41,8 @@ import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.eventbus.EBReuse
import com.gh.gamecenter.common.exposure.ExposureSource
import com.gh.gamecenter.common.json.json
import com.gh.gamecenter.common.observer.MuteCallback
import com.gh.gamecenter.common.observer.VolumeObserver
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.core.utils.DisplayUtils
import com.gh.gamecenter.core.utils.MD5Utils
@ -108,6 +110,20 @@ class ToolbarWrapperFragment : LazyFragment(), ToolbarController, ISmartRefresh,
private var mLightToolbar = false
private var mAutoFinishTwoLevelHandler: Handler? = null
private var mAutoFinishTwoLevelCallback: (() -> Unit)? = null
private val mVolumeObserver by lazy {
VolumeObserver(object : MuteCallback {
override fun onMute(isMute: Boolean) {
if (::mBinding.isInitialized) {
mBinding.muteIv.setImageResource(if (isMute) R.drawable.ic_basic_offsound else R.drawable.ic_basic_onsound)
if (isMute) {
mBinding.autoVideoView.mute()
} else {
mBinding.autoVideoView.unMute()
}
}
}
})
}
private lateinit var mElapsedHelper: TimeElapsedHelper
@ -227,6 +243,7 @@ class ToolbarWrapperFragment : LazyFragment(), ToolbarController, ISmartRefresh,
gameImageIv.goneIf(video != null) {
ImageUtils.display(gameImageIv, imgUrl)
}
muteIv.isVisible = video != null
autoVideoView.goneIf(video == null) {
if (!autoVideoView.isInPlayingState) {
GSYVideoOptionBuilder()
@ -258,6 +275,17 @@ class ToolbarWrapperFragment : LazyFragment(), ToolbarController, ISmartRefresh,
headerContainer.performClick()
}
}
var videoVoiceStatus = SPUtils.getBoolean(Constants.SP_VIDEO_PLAY_MUTE, true)
muteIv.setImageResource(if (videoVoiceStatus) R.drawable.ic_basic_offsound else R.drawable.ic_basic_onsound)
muteIv.setDebouncedClickListener {
videoVoiceStatus = !videoVoiceStatus
muteIv.setImageResource(if (videoVoiceStatus) R.drawable.ic_basic_offsound else R.drawable.ic_basic_onsound)
if (videoVoiceStatus) {
autoVideoView.mute()
} else {
autoVideoView.unMute()
}
}
}
}
}
@ -271,6 +299,18 @@ class ToolbarWrapperFragment : LazyFragment(), ToolbarController, ISmartRefresh,
pullDownPushHandler?.doPreProcess(this as? ISmartRefresh, popupPush)
}
private fun observeVolume() {
context?.applicationContext?.contentResolver?.registerContentObserver(
android.provider.Settings.System.CONTENT_URI,
true,
mVolumeObserver
)
}
private fun unObserveVolume() {
context?.applicationContext?.contentResolver?.unregisterContentObserver(mVolumeObserver)
}
override fun onFragmentPause() {
super.onFragmentPause()
DownloadManager.getInstance().removeObserver(mDataWatcher)
@ -738,6 +778,7 @@ class ToolbarWrapperFragment : LazyFragment(), ToolbarController, ISmartRefresh,
} else {
resumePullDownPushVideo()
}
observeVolume()
}
}
}
@ -751,6 +792,7 @@ class ToolbarWrapperFragment : LazyFragment(), ToolbarController, ISmartRefresh,
if (videoUrl.isNotEmpty()) {
ScrollCalculatorHelper.savePlaySchedule(MD5Utils.getContentMD5(videoUrl), currentPosition)
}
unObserveVolume()
}
}
}
@ -766,8 +808,7 @@ class ToolbarWrapperFragment : LazyFragment(), ToolbarController, ISmartRefresh,
if (position != 0L) {
autoVideoView.seekTo(position)
autoVideoView.onVideoResume(false)
val topVideoVoiceStatus = SPUtils.getBoolean(Constants.SP_VIDEO_PLAY_MUTE, true)
if (topVideoVoiceStatus) {
if (autoVideoView.isMute) {
autoVideoView.mute()
} else {
autoVideoView.unMute()

View File

@ -0,0 +1,19 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M11.183,5.778C11.51,5.511 12,5.744 12,6.165V8.909C12,9.461 12.448,9.909 13,9.909C13.552,9.909 14,9.461 14,8.909V6.165C14,4.056 11.549,2.895 9.917,4.23L8.756,5.181C8.328,5.53 8.265,6.16 8.615,6.588C8.965,7.015 9.595,7.078 10.022,6.728L11.183,5.778Z"
android:fillColor="#000000"/>
<path
android:pathData="M20.66,7C20.384,6.522 19.772,6.358 19.294,6.634C18.816,6.91 18.652,7.522 18.928,8C19.63,9.216 20,10.596 20,12C20,12.92 19.841,13.83 19.534,14.69C19.349,15.21 19.62,15.782 20.14,15.968C20.66,16.153 21.232,15.882 21.418,15.362C21.802,14.287 22,13.15 22,12C22,10.245 21.538,8.52 20.66,7Z"
android:fillColor="#000000"/>
<path
android:pathData="M17.796,10.447C17.653,9.914 17.104,9.597 16.571,9.74C16.037,9.883 15.721,10.431 15.864,10.965C15.967,11.35 16.012,11.748 15.998,12.143C15.978,12.695 16.409,13.159 16.961,13.179C17.513,13.198 17.976,12.767 17.996,12.215C18.017,11.622 17.951,11.026 17.796,10.447Z"
android:fillColor="#000000"/>
<path
android:pathData="M2.224,4.869C2.572,4.441 3.202,4.376 3.631,4.724L19.631,17.724C20.059,18.072 20.124,18.702 19.776,19.131C19.428,19.559 18.798,19.624 18.369,19.276L14,15.726V17.835C14,19.944 11.549,21.105 9.917,19.77L7.143,17.5H5C3.343,17.5 2,16.157 2,14.5V9.5C2,8.476 2.513,7.571 3.297,7.03L2.369,6.276C1.941,5.928 1.876,5.298 2.224,4.869ZM5.106,8.5L12,14.101V17.835C12,18.256 11.51,18.489 11.183,18.222L8.133,15.726C7.955,15.58 7.731,15.5 7.5,15.5H5C4.448,15.5 4,15.052 4,14.5V9.5C4,8.948 4.448,8.5 5,8.5H5.106Z"
android:fillColor="#000000"
android:fillType="evenOdd"/>
</vector>

View File

@ -0,0 +1,16 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M9.917,4.23C11.549,2.895 14,4.056 14,6.165V17.835C14,19.944 11.549,21.105 9.917,19.77L7.143,17.5H5C3.343,17.5 2,16.157 2,14.5V9.5C2,7.843 3.343,6.5 5,6.5H7.143L9.917,4.23ZM12,6.165C12,5.744 11.51,5.511 11.183,5.778L8.133,8.274C7.955,8.42 7.731,8.5 7.5,8.5H5C4.448,8.5 4,8.948 4,9.5V14.5C4,15.052 4.448,15.5 5,15.5H7.5C7.731,15.5 7.955,15.58 8.133,15.726L11.183,18.222C11.51,18.489 12,18.257 12,17.835V6.165Z"
android:fillColor="#000000"
android:fillType="evenOdd"/>
<path
android:pathData="M16.571,9.74C17.104,9.597 17.653,9.914 17.796,10.447C18.068,11.464 18.068,12.536 17.796,13.553C17.653,14.086 17.104,14.403 16.571,14.26C16.037,14.117 15.721,13.569 15.864,13.035C16.045,12.357 16.045,11.643 15.864,10.965C15.721,10.431 16.037,9.883 16.571,9.74Z"
android:fillColor="#000000"/>
<path
android:pathData="M20.66,7C20.384,6.522 19.772,6.358 19.294,6.634C18.816,6.91 18.652,7.522 18.928,8C19.63,9.216 20,10.596 20,12C20,13.404 19.63,14.784 18.928,16C18.652,16.478 18.816,17.09 19.294,17.366C19.772,17.642 20.384,17.478 20.66,17C21.538,15.48 22,13.755 22,12C22,10.245 21.538,8.52 20.66,7Z"
android:fillColor="#000000"/>
</vector>

View File

@ -164,6 +164,19 @@
app:lottie_loop="true"
app:lottie_repeatMode="restart" />
<ImageView
android:id="@+id/muteIv"
android:layout_width="28dp"
android:layout_height="28dp"
android:layout_marginEnd="12dp"
android:layout_marginBottom="24dp"
android:padding="4dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:srcCompat="@drawable/ic_basic_offsound"
app:tint="@color/text_instance" />
<FrameLayout
android:id="@+id/headerBackground"
android:layout_width="0dp"

View File

@ -169,6 +169,19 @@
app:lottie_loop="true"
app:lottie_repeatMode="restart" />
<ImageView
android:id="@+id/muteIv"
android:layout_width="28dp"
android:layout_height="28dp"
android:layout_marginEnd="12dp"
android:layout_marginBottom="24dp"
android:padding="4dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:srcCompat="@drawable/ic_basic_offsound"
app:tint="@color/text_instance" />
<View
android:id="@+id/headerBackground"
android:layout_width="0dp"

View File

@ -10,6 +10,7 @@
android:id="@+id/cv_banner_container"
android:layout_width="0dp"
android:layout_height="0dp"
app:cardBackgroundColor="@color/transparent"
app:cardCornerRadius="8dp"
app:cardElevation="0dp"
app:layout_constraintDimensionRatio="41:11"

View File

@ -1072,7 +1072,7 @@ data class GameEntity(
val showImage: Boolean
get() {
if (!DISPLAY_CONTENT_IMAGE.equals(displayContent, true)) {
if (!DISPLAY_CONTENT_IMAGE.equals(displayContent, true) && topVideo != null) {
return false
}
return (isWechatMiniGame() && banner.isNotBlank()) || homeSetting.image.isNotBlank()