Merge branch 'chen/202403/fix-custom-page-0312' into 'feat/GHZS-3956'

fix:GHZS-4857,GHZS-4720,GHZS-4856,GHZS-4890,GHZS-4892,GHZS-4891...

See merge request halo/android/assistant-android!1566
This commit is contained in:
张晨
2024-03-12 10:06:50 +08:00
17 changed files with 141 additions and 135 deletions

View File

@ -777,8 +777,8 @@ object DownloadItemUtils {
return
}
if (gameEntity.isReservable) {
if (!ReservationRepository.thisGameHasBeenReserved(gameEntity.id)) {
downloadBtn.setOnClickListener {
downloadBtn.setOnClickListener {
if (!ReservationRepository.thisGameHasBeenReserved(gameEntity.id)) {
SensorsBridge.trackEvent(
"AppointmentGame",
"game_name",
@ -803,9 +803,7 @@ object DownloadItemUtils {
refreshCallback?.onCallback()
}
}
}
} else {
downloadBtn.setOnClickListener {
} else {
allStateClickCallback?.onCallback()
clickCallback?.onCallback()
if ("download" == gameEntity.reserveStatus) {

View File

@ -89,9 +89,6 @@ class CustomPageFragment : LazyFragment(), ISmartRefreshContent, IScrollable {
private var bottomTabName = ""
private var tabIndex = -1
// 是否是下拉刷新
private var isPullToRefreshing = false
private lateinit var pageLocation: PageLocation
private var pullDownPushHandler: PullDownPushHandler? = null
@ -188,32 +185,36 @@ class CustomPageFragment : LazyFragment(), ISmartRefreshContent, IScrollable {
adapter.submitList(it)
}
loadStatus.observe(viewLifecycleOwner) {
loadStatus.observe(viewLifecycleOwner) { (status, isPullToRefresh) ->
binding.gameRefresh.isRefreshing = false
binding.gameRefresh.goneIf(it == LoadStatus.INIT_FAILED)
binding.gameList.goneIf(!isPullToRefreshing && it == LoadStatus.INIT_LOADING)
binding.reuseNoConnection.root.goneIf(it != LoadStatus.INIT_FAILED)
// 下拉刷新时不需要显示loading
if (isPullToRefreshing || it != LoadStatus.INIT_LOADING) {
binding.reuseLoading.root.goneIf(true)
binding.root.setBackgroundColor(Color.TRANSPARENT)
if (!isPullToRefresh) {
binding.gameList.goneIf(status == LoadStatus.INIT_LOADING || status == LoadStatus.INIT_FAILED || status == LoadStatus.INIT_EMPTY)
binding.reuseNoConnection.root.goneIf(status != LoadStatus.INIT_FAILED)
if (status == LoadStatus.INIT_LOADING) {
binding.reuseLoading.root.goneIf(false)
binding.root.setBackgroundColor(R.color.ui_surface.toColor(requireContext()))
} else {
binding.reuseLoading.root.goneIf(true)
binding.root.setBackgroundColor(Color.TRANSPARENT)
}
binding.reuseNoData.root.goneIf(status != LoadStatus.INIT_EMPTY)
} else {
binding.reuseLoading.root.goneIf(false)
binding.root.setBackgroundColor(R.color.ui_surface.toColor(requireContext()))
if (status == LoadStatus.INIT_LOADED) {
binding.gameList.visibleIf(true)
binding.reuseNoConnection.root.goneIf(true)
binding.reuseNoData.root.goneIf(true)
}
}
adapter.setLoadStatus(it)
if (it == LoadStatus.INIT_LOADED) {
adapter.setLoadStatus(status)
if (status == LoadStatus.INIT_LOADED) {
AppExecutor.uiExecutor.executeWithDelay({
scroll()
scrollCalculatorHelper.onScrollStateChanged(RecyclerView.SCROLL_STATE_IDLE)
}, 100)
(parentFragment as? ISmartRefresh)?.finishRefresh()
}
if (it == LoadStatus.INIT_LOADING) {
isPullToRefreshing = false
if (status != LoadStatus.INIT_LOADING) {
(parentFragment as? ISmartRefresh)?.finishRefresh()
}
}
@ -490,7 +491,7 @@ class CustomPageFragment : LazyFragment(), ISmartRefreshContent, IScrollable {
binding.gameList.addOnScrollListener(exposureListener)
binding.reuseNoConnection.connectionReloadTv.setOnClickListener {
viewModel.loadFirst()
viewModel.loadFirst(false)
}
binding.gameRefresh.setOnRefreshListener {
@ -683,9 +684,8 @@ class CustomPageFragment : LazyFragment(), ISmartRefreshContent, IScrollable {
}
override fun onRefresh() {
isPullToRefreshing = true
viewModel.onRefresh()
viewModel.loadFirst(true)
viewModel.loadFirst(true, true)
}
override fun setSwipeRefreshEnabled(isSwipeRefreshEnabled: Boolean) {

View File

@ -70,10 +70,8 @@ class CustomPageViewModel(
private val _dataList = MutableLiveData<List<CustomPageItem>>()
val dataList: LiveData<List<CustomPageItem>> = _dataList
private val _loadStatus = MutableLiveData<LoadStatus>()
val loadStatus: LiveData<LoadStatus> = _loadStatus
private var isLoading = false
private val _loadStatus = MutableLiveData<Pair<LoadStatus, Boolean>>()
val loadStatus: LiveData<Pair<LoadStatus, Boolean>> = _loadStatus
var refreshCount = 0
@ -118,7 +116,7 @@ class CustomPageViewModel(
fun loadData() {
loadFirst()
loadFirst(false)
loadSuspendedWindow()
}
@ -148,8 +146,8 @@ class CustomPageViewModel(
}).addDisposable()
}
fun loadFirst(forceLoad: Boolean = false) {
_loadStatus.value = LoadStatus.INIT_LOADING
fun loadFirst(isPullToRefresh: Boolean, forceLoad: Boolean = false) {
_loadStatus.value = LoadStatus.INIT_LOADING to isPullToRefresh
repository.loadFirstCustomPageData(pageConfigure.pageId, forceLoad)
.map { (custom, list) ->
Triple(custom, list, getPositionAndPackageMap(list))
@ -179,9 +177,9 @@ class CustomPageViewModel(
pageSwitchData.postValue(custom.pageSwitch)
_dataList.value = list
_loadStatus.value = if (list.isEmpty()) {
LoadStatus.INIT_EMPTY
LoadStatus.INIT_EMPTY to isPullToRefresh
} else {
LoadStatus.INIT_LOADED
LoadStatus.INIT_LOADED to isPullToRefresh
}
if (custom.pageSwitch.suspendedWindow) {
@ -191,7 +189,8 @@ class CustomPageViewModel(
override fun onFailure(exception: Exception) {
super.onFailure(exception)
_loadStatus.value = LoadStatus.INIT_FAILED
_loadStatus.value = LoadStatus.INIT_FAILED to isPullToRefresh
}
}).addDisposable()
@ -204,11 +203,11 @@ class CustomPageViewModel(
}
override fun onLoadMore() {
if (isLoading && loadStatus.value == LoadStatus.LIST_OVER) {
val status = loadStatus.value?.first ?: LoadStatus.INIT
if (status == LoadStatus.LIST_LOADING || status == LoadStatus.INIT_LOADING || status == LoadStatus.LIST_OVER) {
return
}
isLoading = true
_loadStatus.value = LoadStatus.LIST_LOADING
_loadStatus.value = LoadStatus.LIST_LOADING to false
repository.loadNextCustomPageData(pageConfigure.pageId)
.map {
it to getPositionAndPackageMap(it)
@ -220,25 +219,24 @@ class CustomPageViewModel(
override fun onSuccess(data: Pair<List<CustomPageItem>, HashMap<String, Int>>) {
val (list, gameWithPositionMap) = data
gamePositionAndPackageHelper.putAll(gameWithPositionMap)
isLoading = false
addData(list)
_loadStatus.value = if (list.isEmpty()) {
LoadStatus.LIST_OVER
LoadStatus.LIST_OVER to false
} else {
LoadStatus.LIST_LOADED
LoadStatus.LIST_LOADED to false
}
addData(list)
}
override fun onFailure(exception: Exception) {
super.onFailure(exception)
isLoading = false
_loadStatus.value = LoadStatus.LIST_FAILED to false
}
}).addDisposable()
}
override fun onRetry() {
onLoadMore()
loadFirst(false)
}
override fun onRotateRefresh(customSubjectCollectionItem: CustomSubjectCollectionItem) {

View File

@ -136,7 +136,7 @@ class CustomFoldSlideLargeImageItemAdapter(
)
binding.tvBubble.text = game.bubbleText
binding.gStar.goneIf(!data.data.showStar) {
binding.gStar.goneIf(!(data.data.showStar && game.commentCount > 3)) {
binding.tvStar.text = if (game.star == 10.0F) "10" else game.star.toString()
}
BindingAdapters.setGameTags(binding.llLabel, game)

View File

@ -2,8 +2,10 @@ package com.gh.gamecenter.home.custom.adapter
import android.content.Context
import android.graphics.drawable.Drawable
import android.os.Build
import android.view.ViewGroup
import android.view.ViewGroup.MarginLayoutParams
import androidx.core.content.ContextCompat
import androidx.core.view.marginBottom
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.ViewHolder
@ -146,18 +148,16 @@ class CustomGameVerticalAdapter(
BindingAdapters.setGameTags(gameTagContainer, gameEntity)
GameItemViewHolder.initServerType(gameNameTv, serverTypeTv, gameEntity)
val brief = if (briefStyle.contains("recommend") && gameEntity.columnRecommend != null) {
gameEntity.columnRecommend?.text ?: ""
val styleResId = R.style.CustomPageGameRating
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
gameRatingTv.setTextAppearance(styleResId)
} else {
val size = gameEntity.getApk().firstOrNull()?.size ?: ""
if (size.isBlank()) {
gameEntity.brief
} else {
"${size} ${gameEntity.brief}"
}
gameRatingTv.setTextAppearance(context, styleResId)
}
gameDesTv.text = brief
gameRatingTv.setPadding(0, 4f.dip2px(), 8f.dip2px(), 0)
gameRatingTv.setDrawableStart(R.drawable.game_horizontal_rating)
CustomViewExt.setGameRatting(gameRatingTv, briefStyle, gameEntity)
CustomViewExt.setDescription(gameDesTv, briefStyle, gameEntity)
GameItemViewHolder.initGameSubtitleAndAdLabel(
gameEntity,
gameSubtitleTv,
@ -167,26 +167,6 @@ class CustomGameVerticalAdapter(
adLabelTv
)
var gameRatingPaddingEnd = 0
var gameRatingDrawableStart: Drawable? = null
var gameRatingTextColor = R.color.primary_theme.toColor(context)
var gameRatingText = ""
gameRatingTv.textSize = if (gameEntity.commentCount > 3) 12F else 10F
if (gameEntity.commentCount > 3) {
gameRatingPaddingEnd = 8F.dip2px()
gameRatingDrawableStart = R.drawable.game_horizontal_rating.toDrawable()
gameRatingTextColor = R.color.text_theme.toColor(context)
gameRatingText =
if (gameEntity.star == 10.0F) "10" else gameEntity.star.toString()
}
gameRatingTv.setDrawableStart(gameRatingDrawableStart)
gameRatingTv.setPadding(0, 4f.dip2px(), gameRatingPaddingEnd, 0)
gameRatingTv.setTextColor(gameRatingTextColor)
gameRatingTv.text = gameRatingText
// 没错,产品就把这个通用样式叫推荐榜单专题
downloadTv.putWidgetBusinessName("推荐榜单专题")
@ -203,7 +183,6 @@ class CustomGameVerticalAdapter(
tempViewHolder.recommendTv = recommendTv
tempViewHolder.recommendContainer = recommendConstraintLayout
tempViewHolder.gameServerType = serverTypeTv
tempViewHolder.gameRating = gameRatingTv
DownloadItemUtils.updateItem(
context,

View File

@ -1,6 +1,7 @@
package com.gh.gamecenter.home.custom.adapter
import android.content.Context
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import com.gh.common.util.DownloadItemUtils
@ -72,15 +73,7 @@ class CustomIconMatrixAdapter(
gameName.maxLines = if (subject.showDownload) 1 else 2
}
holder.binding.gameRating.textSize = 12F
holder.binding.gameRating.goneIf(!subject.showStar) {
holder.binding.gameRating.setDrawableStart(if (item.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable() else null)
holder.binding.gameRating.text =
if (item.commentCount > 3) (if (item.star == 10.0f) "10" else item.star.toString()) else ""
}
CustomViewExt.setGameRattingWithSubject(holder.binding.gameRating, subject.showStar, item)
val entranceResult =
StringUtils.buildString("(游戏-专题:", subject.name, "-列表[", (position + 1).toString(), "])")
val locationResult = StringUtils.buildString("游戏-专题-", subject.name, ":", item.name)

View File

@ -0,0 +1,53 @@
package com.gh.gamecenter.home.custom.adapter
import android.widget.TextView
import com.gh.gamecenter.common.utils.goneIf
import com.gh.gamecenter.common.utils.visibleIf
import com.gh.gamecenter.feature.entity.GameEntity
object CustomViewExt {
fun setGameRatting(tvRatting: TextView, briefStyle: String, game: GameEntity) {
tvRatting.goneIf(!(game.commentCount > 3 && briefStyle == "star&brief")) {
tvRatting.text = if (game.star == 10.0f) {
"10"
} else {
"${game.star}"
}
}
}
fun setGameRattingWithSubject(tvRatting: TextView, showStar: Boolean, game: GameEntity) {
if (showStar) {
tvRatting.visibleIf(game.commentCount > 3) {
tvRatting.text = if (game.star == 10.0f) {
"10"
} else {
"${game.star}"
}
}
} else {
tvRatting.goneIf(true)
}
}
fun setDescription(tvDesc: TextView, briefStyle: String, game: GameEntity) {
fun getBriefWithSize(): String {
val size = game.getApk().firstOrNull()?.size ?: ""
return if (size.isNotBlank()) {
"$size ${game.brief ?: ""}"
} else {
game.brief ?: ""
}
}
val brief = when (briefStyle) {
"size&brief" -> getBriefWithSize()
"star&brief" -> game.brief
"recommend" -> game.columnRecommend?.text ?: getBriefWithSize()
else -> getBriefWithSize()
}
tvDesc.text = brief
}
}

View File

@ -332,6 +332,7 @@ class CustomPageRepository private constructor(
COMPONENTS_COLLECTION_STYLE_REFRESH_ICONS_4_2 -> {
val needGameCount = linkColumnCollection.styleSetting.rowsNum * 4
println("kayn -->name:${linkColumnCollection.name} --size:${it.games.size}")
it.games.size >= needGameCount
}

View File

@ -9,6 +9,7 @@ import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.databinding.GameHorizontalItemCustomBinding
import com.gh.gamecenter.entity.SubjectEntity
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.home.custom.adapter.CustomViewExt
class CustomGameHorizontalItemViewHolder(val binding: GameHorizontalItemCustomBinding) :
BaseRecyclerViewHolder<GameEntity>(binding.root) {
@ -19,12 +20,8 @@ class CustomGameHorizontalItemViewHolder(val binding: GameHorizontalItemCustomBi
isShowFirstLine: Boolean,
isShowSecondLine: Boolean
) {
binding.gameRating.textSize = 12f
binding.gameRating.goneIf("star" != subjectEntity.typeStyle, visibleCallback = {
binding.gameRating.setDrawableStart(if (gameEntity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable() else null)
binding.gameRating.text =
if (gameEntity.commentCount > 3) (if (gameEntity.star == 10.0f) "10" else gameEntity.star.toString()) else ""
})
CustomViewExt.setGameRattingWithSubject(binding.gameRating, subjectEntity.typeStyle == "star", gameEntity)
binding.firstRemark.text = gameEntity.assignRemark.firstLine
binding.firstRemark.setTextColor(
if (gameEntity.assignRemark.markedRed) Color.parseColor("#F10000") else R.color.text_primary.toColor(

View File

@ -22,6 +22,7 @@ import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.entity.PluginLocation
import com.gh.gamecenter.feature.provider.IBindingAdaptersProvider
import com.gh.gamecenter.home.custom.CustomPageViewModel
import com.gh.gamecenter.home.custom.adapter.CustomViewExt
import com.gh.gamecenter.home.custom.createExposureEvent
import com.gh.gamecenter.home.custom.eventlistener.SubjectEventHelper
import com.gh.gamecenter.home.custom.model.CustomPageItem
@ -79,27 +80,9 @@ class CustomGameItemViewHolder(
.navigation() as? IBindingAdaptersProvider
provider?.setGameName(gameName, entity, isShowPlatform)
provider?.setGameTags(labelList, entity)
gameRating.textSize = if (entity.commentCount > 3) 12F else 10F
gameRating.setDrawableStart(if (entity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable() else null)
gameRating.setPadding(0, 0, if (entity.commentCount > 3) 8F.dip2px() else 0, 0)
gameRating.text = if (entity.commentCount > 3) {
if (entity.star == 10.0F) "10" else entity.star.toString()
} else ""
gameRating.setTextColor(
if (entity.commentCount > 3) R.color.text_theme.toColor(root.context) else R.color.primary_theme.toColor(
root.context
)
)
gameRating.visibleIf(subject.briefStyle.contains("star&brief")) {
gameRating.text = "${entity.star}"
}
val brief = when (subject.briefStyle) {
"size&brief" -> entity.getApk().firstOrNull()?.size + " " + entity.brief
"star&brief" -> entity.brief
else -> "专题推荐文案"
}
gameDes.text = brief
CustomViewExt.setGameRatting(gameRating, subject.briefStyle, entity)
CustomViewExt.setDescription(gameDes, subject.briefStyle, entity)
recommendStar.rating = entity.recommendStar.toFloat()
initCustomGameSubtitleAndAdLabel(
entity,
@ -288,11 +271,10 @@ class CustomGameItemViewHolder(
}
}
class CustomGameViewHolder(private val binding: GameItemCustomBinding) : GameViewHolder(binding.root) {
class CustomGameViewHolder(binding: GameItemCustomBinding) : GameViewHolder(binding.root) {
init {
gameDownloadBtn = binding.downloadBtn
gameDes = binding.gameDes
gameRating = binding.gameRating
recommendContainer = binding.recommendContainer
recommendIv = binding.recommendIv
recommendTv = binding.recommendTv

View File

@ -211,7 +211,7 @@ class CustomHomeGameItemViewHolder(
)
binding.downloadBtn.putWidgetBusinessName("首页游戏大图样式")
binding.downloadBtn.goneIf(game.homeSetting.downloadBtnSwitch != "on")
binding.gameRating.goneIf(!(game.star >= 7 && game.homeSetting.downloadBtnSwitch == "on"))
binding.gameRating2.goneIf(!(game.star >= 7 && game.homeSetting.downloadBtnSwitch != "on"))
binding.gameRating.goneIf(!(game.commentCount > 3 && game.star >= 7 && game.homeSetting.downloadBtnSwitch == "on"))
binding.gameRating2.goneIf(!(game.commentCount > 3 && game.star >= 7 && game.homeSetting.downloadBtnSwitch != "on"))
}
}

View File

@ -376,7 +376,7 @@ public class LibaoDetailFragment extends ToolbarFragment implements LibaoDetailA
if (mLibaoEntity.getGame() == null) return;
String gameId = mLibaoEntity.getGame().getId();
if (RegionSettingHelper.shouldThisGameBeFiltered(gameId)) {
toast("网络异常,请稍后再试");
loadNotFound();
return;
}
RetrofitManager.getInstance().getApi().getGameNewsDigest(gameId)

View File

@ -43,6 +43,12 @@
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
<include
android:id="@+id/reuse_no_data"
layout="@layout/reuse_none_data"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.gh.gamecenter.home.custom.floatview.CustomFloatView
android:id="@+id/floating_view"
android:layout_width="wrap_content"

View File

@ -18,13 +18,9 @@
<TextView
android:id="@+id/game_rating"
style="@style/CustomPageGameRating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawablePadding="4dp"
android:includeFontPadding="false"
android:textColor="@color/primary_theme"
android:textSize="12sp"
android:textStyle="bold"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"

View File

@ -154,13 +154,11 @@
<TextView
android:id="@+id/game_rating"
style="@style/CustomPageGameRating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="10"
android:layout_marginTop="5dp"
android:drawablePadding="4dp"
android:includeFontPadding="false"
android:textStyle="bold"
android:visibility="gone"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintLeft_toLeftOf="@+id/gameDesSpace"
app:layout_constraintRight_toLeftOf="@+id/game_des"
@ -170,12 +168,12 @@
android:id="@+id/game_des"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:ellipsize="end"
android:includeFontPadding="false"
android:singleLine="true"
android:textColor="@color/text_tertiary"
android:textSize="10sp"
android:layout_marginTop="6dp"
app:layout_constraintLeft_toRightOf="@+id/game_rating"
app:layout_constraintRight_toRightOf="@+id/gameDesSpace"
app:layout_constraintTop_toTopOf="@+id/gameDesSpace"

View File

@ -9,15 +9,10 @@
<TextView
android:id="@+id/game_rating"
style="@style/CustomPageGameRating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:drawablePadding="4dp"
android:includeFontPadding="false"
android:textColor="@color/primary_theme"
android:textSize="12sp"
android:textStyle="bold"
app:drawableStartCompat="@drawable/game_horizontal_rating"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"

View File

@ -281,4 +281,14 @@
<item name="android:textSize">12sp</item>
<item name="android:textAlignment">center</item>
</style>
<style name="CustomPageGameRating">
<item name="android:textSize">12sp</item>
<item name="android:drawableStart">@drawable/game_horizontal_rating</item>
<item name="android:textColor">@color/text_theme</item>
<item name="android:paddingRight">8dp</item>
<item name="android:textStyle">bold</item>
<item name="android:drawablePadding">4dp</item>
<item name="android:includeFontPadding">false</item>
</style>
</resources>