Merge branch 'fix/GHZS-2848' into 'dev'
fix: 游戏单功能优化-游戏单合集-前端部分—0704测试-客户端 https://jira.shanqu.cc/browse/GHZS-2848 See merge request halo/android/assistant-android!1184
This commit is contained in:
@ -1343,7 +1343,7 @@ class GameFragmentAdapter(
|
||||
mViewModel.blockData?.link ?: "",
|
||||
mViewModel.blockData?.name ?: ""
|
||||
) {
|
||||
mViewModel.changeGameCollectionRefresh(it.id)
|
||||
mViewModel.changeGameCollectionRefresh(it.id, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -598,17 +598,17 @@ class GameViewModel(application: Application, var blockData: SubjectRecommendEnt
|
||||
}
|
||||
}
|
||||
|
||||
fun changeGameCollectionRefresh(collectionId: String): Boolean {
|
||||
fun changeGameCollectionRefresh(collectionId: String, isRefreshClick: Boolean): Boolean {
|
||||
val page = (mRefreshGameCollectionPageMap[collectionId] ?: 1) + 1
|
||||
return if (page != 0) {
|
||||
getGameCollectionRefresh(collectionId, page)
|
||||
getGameCollectionRefresh(collectionId, page, isRefreshClick)
|
||||
true // 表示需要从接口获取数据
|
||||
} else {
|
||||
false // 表示已加载完毕
|
||||
}
|
||||
}
|
||||
|
||||
private fun getGameCollectionRefresh(collectionId: String, page: Int) {
|
||||
private fun getGameCollectionRefresh(collectionId: String, page: Int, isRefreshClick: Boolean) {
|
||||
mSensitiveApi.getGameCollectionRefresh(collectionId, "block", page, 1)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@ -622,6 +622,15 @@ class GameViewModel(application: Application, var blockData: SubjectRecommendEnt
|
||||
addAll(response)
|
||||
}
|
||||
}
|
||||
|
||||
// 手动点击刷新获取时,若游戏单内游戏被全部屏蔽会自动获取下一个游戏单
|
||||
if (isRefreshClick) {
|
||||
val filterGameList = RegionSettingHelper.filterGame(response[0].games)
|
||||
if (filterGameList.isEmpty()) {
|
||||
changeGameCollectionRefresh(collectionId, true)
|
||||
return
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// -1 表示加载完毕
|
||||
mRefreshGameCollectionPageMap[collectionId] = -1
|
||||
@ -707,6 +716,7 @@ class GameViewModel(application: Application, var blockData: SubjectRecommendEnt
|
||||
if (!(!isTopItemShown && index == 0)
|
||||
&& !shouldShowDivider
|
||||
&& !hideSubjectName
|
||||
&& !(subjectEntity.type == "game_list_collection" && subjectEntity.style == LegacyHomeFragmentAdapterAssistant.GAME_COLLECTION_VERTICAL_REFRESH_STYLE)
|
||||
) {
|
||||
mItemDataListCache.add(getBlankSpacingItem())
|
||||
}
|
||||
@ -1017,6 +1027,12 @@ class GameViewModel(application: Application, var blockData: SubjectRecommendEnt
|
||||
}
|
||||
}
|
||||
}
|
||||
if (itemDataList.isEmpty()) {
|
||||
if (subjectEntity.style?.contains("refresh") == true) {
|
||||
subjectEntity.id?.let { changeGameCollectionRefresh(it, false) }
|
||||
}
|
||||
continue
|
||||
}
|
||||
// 轮播图样式需要至少3个游戏单
|
||||
if ((subjectEntity.style == LegacyHomeFragmentAdapterAssistant.GAME_COLLECTION_CAROUSEL_STYLE && itemDataList.size >= 3) || subjectEntity.style != LegacyHomeFragmentAdapterAssistant.GAME_COLLECTION_CAROUSEL_STYLE) {
|
||||
if (subjectEntity.style?.contains("refresh") == false) {
|
||||
|
||||
@ -324,17 +324,18 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) {
|
||||
}
|
||||
}
|
||||
|
||||
fun changeGameCollectionRefresh(collectionId: String): Boolean {
|
||||
fun changeGameCollectionRefresh(collectionId: String, isRefreshClick: Boolean): Boolean {
|
||||
val page = (mRefreshGameCollectionPageMap[collectionId] ?: 1) + 1
|
||||
return if (page != 0) {
|
||||
getGameCollectionRefresh(collectionId, page)
|
||||
getGameCollectionRefresh(collectionId, page, isRefreshClick)
|
||||
true // 表示需要从接口获取数据
|
||||
} else {
|
||||
false // 表示已加载完毕
|
||||
}
|
||||
}
|
||||
|
||||
private fun getGameCollectionRefresh(collectionId: String, page: Int) {
|
||||
private fun getGameCollectionRefresh(collectionId: String, page: Int, isRefreshClick: Boolean) {
|
||||
// 每次获取一个游戏单
|
||||
mApi.getGameCollectionRefresh(collectionId, "home_content", page, 1)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@ -348,6 +349,15 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) {
|
||||
addAll(response)
|
||||
}
|
||||
}
|
||||
|
||||
// 手动点击刷新获取时,若游戏单内游戏被全部屏蔽会自动获取下一个游戏单
|
||||
if (isRefreshClick) {
|
||||
val filterGameList = RegionSettingHelper.filterGame(response[0].games)
|
||||
if (filterGameList.isEmpty()) {
|
||||
changeGameCollectionRefresh(collectionId, true)
|
||||
return
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// -1 表示加载完毕
|
||||
mRefreshGameCollectionPageMap[collectionId] = -1
|
||||
@ -888,6 +898,12 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (itemDataList.isEmpty()) {
|
||||
if (homeContent.style.contains("refresh")) {
|
||||
changeGameCollectionRefresh(homeContent.linkId, false)
|
||||
}
|
||||
continue
|
||||
}
|
||||
// 轮播图样式需要至少3个游戏单
|
||||
if ((homeContent.style == LegacyHomeFragmentAdapterAssistant.GAME_COLLECTION_CAROUSEL_STYLE && itemDataList.size >= 3) || homeContent.style != LegacyHomeFragmentAdapterAssistant.GAME_COLLECTION_CAROUSEL_STYLE) {
|
||||
if (!homeContent.style.contains("refresh")) {
|
||||
|
||||
@ -1097,7 +1097,7 @@ class LegacyHomeFragmentAdapterAssistant(
|
||||
item.gameCollection?.let {
|
||||
holder.bindGameCollectionRefresh(it, "首页内容列表") {
|
||||
if (mAdapter is HomeFragmentAdapter) {
|
||||
(mAdapter as HomeFragmentAdapter).viewModel.changeGameCollectionRefresh(it.id)
|
||||
(mAdapter as HomeFragmentAdapter).viewModel.changeGameCollectionRefresh(it.id, true)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ class HomeGameCollectionSlideAdapter(
|
||||
listOf(gameItem1, gameItem2, gameItem3).forEachIndexed { index, binding ->
|
||||
binding.root.goneIf(games.size < index + 1) {
|
||||
val gameEntity = games[index]
|
||||
holder.updateGameItem(binding, gameEntity, gameCollectionItemData)
|
||||
holder.updateGameItem(binding, gameEntity)
|
||||
}
|
||||
}
|
||||
|
||||
@ -158,7 +158,7 @@ class HomeGameCollectionSlideAdapter(
|
||||
mContext,
|
||||
gameEntity.id,
|
||||
BaseActivity.mergeEntranceAndPath(mEntrance, "游戏单合集"),
|
||||
gameCollectionItemData?.exposureEvent
|
||||
gameEntity.exposureEvent
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -289,9 +289,9 @@ class HomeGameCollectionSlideAdapter(
|
||||
(itemView as HomeGameCollectionBigSlideCardCell).binding?.run {
|
||||
|
||||
when (position) {
|
||||
0 -> updateGameItem(gameItem1, dataList[position], mGameCollectionListItemData)
|
||||
1 -> updateGameItem(gameItem2, dataList[position], mGameCollectionListItemData)
|
||||
2 -> updateGameItem(gameItem3, dataList[position], mGameCollectionListItemData)
|
||||
0 -> updateGameItem(gameItem1, dataList[position])
|
||||
1 -> updateGameItem(gameItem2, dataList[position])
|
||||
2 -> updateGameItem(gameItem3, dataList[position])
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -312,7 +312,7 @@ class HomeGameCollectionSlideAdapter(
|
||||
listOf(gameItem1, gameItem2, gameItem3).forEachIndexed { index, binding ->
|
||||
binding.root.goneIf(games.size < index + 1) {
|
||||
val gameEntity = games[index]
|
||||
updateGameItem(binding, gameEntity, mGameCollectionListItemData)
|
||||
updateGameItem(binding, gameEntity)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -323,8 +323,7 @@ class HomeGameCollectionSlideAdapter(
|
||||
|
||||
fun updateGameItem(
|
||||
binding: ItemHomeGameCollectionBigSlideCardGameBinding,
|
||||
gameEntity: GameEntity,
|
||||
itemData: GameCollectionListItemData? = null
|
||||
gameEntity: GameEntity
|
||||
) {
|
||||
binding.root.visibility = View.VISIBLE
|
||||
|
||||
@ -340,7 +339,7 @@ class HomeGameCollectionSlideAdapter(
|
||||
null,
|
||||
mEntrance,
|
||||
"游戏单合集",
|
||||
itemData?.exposureEvent,
|
||||
gameEntity.exposureEvent,
|
||||
clickCallback = null,
|
||||
refreshCallback = {
|
||||
DownloadItemUtils.updateItem(
|
||||
@ -381,7 +380,7 @@ class HomeGameCollectionSlideAdapter(
|
||||
mContext,
|
||||
gameEntity.id,
|
||||
BaseActivity.mergeEntranceAndPath(mEntrance, "游戏单合集"),
|
||||
itemData?.exposureEvent
|
||||
gameEntity.exposureEvent
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user