Compare commits
1 Commits
dev
...
feat/dsp-o
| Author | SHA1 | Date | |
|---|---|---|---|
| cfde1e1e62 |
@ -246,10 +246,9 @@ class CustomPageFragment : LazyFragment(), ISmartRefreshContent, IScrollable, IB
|
|||||||
setNavigationTitle(it.title)
|
setNavigationTitle(it.title)
|
||||||
})
|
})
|
||||||
|
|
||||||
dataList.observe(viewLifecycleOwner) {
|
dataList.observe(viewLifecycleOwner) { (shouldScrollToTop, data) ->
|
||||||
adapter.submitList(it) {
|
adapter.submitList(data) {
|
||||||
if (shouldScrollToTop) {
|
if (shouldScrollToTop) {
|
||||||
shouldScrollToTop = false
|
|
||||||
binding.gameList.scrollToPosition(0)
|
binding.gameList.scrollToPosition(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -29,7 +29,7 @@ interface OnCustomPageEventListener {
|
|||||||
/**
|
/**
|
||||||
* 换一批
|
* 换一批
|
||||||
*/
|
*/
|
||||||
fun onChangeABatch(subjectEntity: SubjectEntity)
|
fun onChangeABatch(componentId: String, subjectEntity: SubjectEntity)
|
||||||
|
|
||||||
fun onChangeAppBarColor(color: Int)
|
fun onChangeAppBarColor(color: Int)
|
||||||
|
|
||||||
@ -56,7 +56,10 @@ interface OnCustomPageEventListener {
|
|||||||
/**
|
/**
|
||||||
* 点击进入专题详情
|
* 点击进入专题详情
|
||||||
*/
|
*/
|
||||||
fun navigateSubjectDetailPage(item: CustomSubjectCollectionItem, subject: CustomPageData.LinkColumnCollection.CustomSubjectEntity)
|
fun navigateSubjectDetailPage(
|
||||||
|
item: CustomSubjectCollectionItem,
|
||||||
|
subject: CustomPageData.LinkColumnCollection.CustomSubjectEntity
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -35,9 +35,11 @@ class SubjectEventHelper(viewModel: CustomPageViewModel) : CustomPageItemChildEv
|
|||||||
gameEntity.tempDspLogMap = map.toMap() // Return an immutable copy
|
gameEntity.tempDspLogMap = map.toMap() // Return an immutable copy
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gameEntity.isMiniGame() -> {
|
gameEntity.isMiniGame() -> {
|
||||||
tracker.trackMiniGameClick(_item, gameEntity)
|
tracker.trackMiniGameClick(_item, gameEntity)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
tracker.trackColumnClick(_item, gameEntity, "游戏")
|
tracker.trackColumnClick(_item, gameEntity, "游戏")
|
||||||
}
|
}
|
||||||
@ -51,9 +53,11 @@ class SubjectEventHelper(viewModel: CustomPageViewModel) : CustomPageItemChildEv
|
|||||||
gameEntity.isDspGame -> {
|
gameEntity.isDspGame -> {
|
||||||
tracker.trackDspGameClick(_item, gameEntity, "按钮", "自定义页面")
|
tracker.trackDspGameClick(_item, gameEntity, "按钮", "自定义页面")
|
||||||
}
|
}
|
||||||
|
|
||||||
gameEntity.isMiniGame() -> {
|
gameEntity.isMiniGame() -> {
|
||||||
tracker.trackMiniGameClick(_item, gameEntity)
|
tracker.trackMiniGameClick(_item, gameEntity)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
tracker.trackColumnClick(_item, gameEntity, "按钮")
|
tracker.trackColumnClick(_item, gameEntity, "按钮")
|
||||||
}
|
}
|
||||||
@ -67,9 +71,9 @@ class SubjectEventHelper(viewModel: CustomPageViewModel) : CustomPageItemChildEv
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onChangeABatch(subject: SubjectEntity) {
|
fun onChangeABatch(componentId: String, subject: SubjectEntity) {
|
||||||
tracker.trackColumnClick(_item, null, "右上角", "换一批")
|
tracker.trackColumnClick(_item, null, "右上角", "换一批")
|
||||||
viewModel.onChangeABatch(subject)
|
viewModel.onChangeABatch(componentId,subject)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onMoreClick(link: LinkEntity) {
|
fun onMoreClick(link: LinkEntity) {
|
||||||
|
|||||||
@ -0,0 +1,185 @@
|
|||||||
|
package com.gh.gamecenter.home.custom.model
|
||||||
|
|
||||||
|
import com.gh.gamecenter.common.entity.LinkEntity
|
||||||
|
import com.gh.gamecenter.common.entity.PKEntity
|
||||||
|
import com.gh.gamecenter.entity.AmwayCommentEntity
|
||||||
|
import com.gh.gamecenter.entity.DiscoveryCardEntity
|
||||||
|
import com.gh.gamecenter.entity.HomeItemTestV2Entity
|
||||||
|
import com.gh.gamecenter.entity.SubjectEntity
|
||||||
|
import com.gh.gamecenter.feature.entity.AcctRecord
|
||||||
|
import com.gh.gamecenter.feature.entity.GameEntity
|
||||||
|
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.CUSTOM_LINK_TYPE_COLUMN_COLLECTION
|
||||||
|
import com.gh.vspace.VGameItemData
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接口返回的原始数据模型,最终需要转化成 CustomPageItem 在ui层呈现
|
||||||
|
*/
|
||||||
|
sealed class CustomItemDTO(
|
||||||
|
val componentId: String, // 当前组件的唯一标识,用于后续更新单个数据时,快速找到目标数据
|
||||||
|
val link: LinkEntity
|
||||||
|
)
|
||||||
|
|
||||||
|
// 游戏专题:展开大图样式专用
|
||||||
|
class GameItemDTO(
|
||||||
|
private val _componentId: String,
|
||||||
|
private val _link: LinkEntity,
|
||||||
|
val data: GameEntity,
|
||||||
|
val linkColumn: SubjectEntity?,
|
||||||
|
) : CustomItemDTO(_componentId, _link)
|
||||||
|
|
||||||
|
//游戏专题
|
||||||
|
data class SubjectItemDTO(
|
||||||
|
private val _componentId: String,
|
||||||
|
private val _link: LinkEntity,
|
||||||
|
var data: SubjectEntity
|
||||||
|
) : CustomItemDTO(_componentId, _link) {
|
||||||
|
|
||||||
|
val scrollState = ScrollState()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 专题合集/游戏单合集
|
||||||
|
class CollectionItemDTO(
|
||||||
|
private val _componentId: String,
|
||||||
|
private val _link: LinkEntity,
|
||||||
|
val data: CustomPageData.LinkColumnCollection
|
||||||
|
) : CustomItemDTO(_componentId, _link) {
|
||||||
|
|
||||||
|
val isSubjectCollection: Boolean // 是否是专题合集(还有可能是游戏单合集)
|
||||||
|
get() = link.type == CUSTOM_LINK_TYPE_COLUMN_COLLECTION
|
||||||
|
|
||||||
|
var showPage: Int = 0
|
||||||
|
var loadPage: Int = 1
|
||||||
|
var isLoadedEnd: Boolean = false
|
||||||
|
|
||||||
|
val uiState = UIState()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存ui层状态
|
||||||
|
*/
|
||||||
|
data class UIState(
|
||||||
|
var isBackToStart: Boolean = false
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 最近在玩
|
||||||
|
data class RecentGamesItemDTO(
|
||||||
|
private val _componentId: String,
|
||||||
|
private val _link: LinkEntity,
|
||||||
|
var data: List<VGameItemData>
|
||||||
|
) : CustomItemDTO(_componentId, _link)
|
||||||
|
|
||||||
|
// 微信小游戏-最近在玩
|
||||||
|
data class RecentWechatMiniGamesItemDTO(
|
||||||
|
private val _componentId: String,
|
||||||
|
private val _link: LinkEntity,
|
||||||
|
var data: List<GameEntity>
|
||||||
|
) : CustomItemDTO(_componentId, _link)
|
||||||
|
|
||||||
|
// qq小游戏-最近在玩
|
||||||
|
data class RecentQqMiniGamesItemDTO(
|
||||||
|
private val _componentId: String,
|
||||||
|
private val _link: LinkEntity,
|
||||||
|
var data: List<GameEntity>,
|
||||||
|
val linkQqGameRecentlyPlayed: CustomPageData.LinkRecentlyPlayed
|
||||||
|
) : CustomItemDTO(_componentId, _link)
|
||||||
|
|
||||||
|
// 加速游戏最近在玩
|
||||||
|
data class RecentAcceleratorGamesItemDTO(
|
||||||
|
private val _componentId: String,
|
||||||
|
private val _link: LinkEntity,
|
||||||
|
var data: List<AcctRecord>,
|
||||||
|
val moreLink: LinkEntity?
|
||||||
|
) : CustomItemDTO(_componentId, _link)
|
||||||
|
|
||||||
|
// qq小游戏专题
|
||||||
|
data class QqMiniGamesItemDTO(
|
||||||
|
private val _componentId: String,
|
||||||
|
private val _link: LinkEntity,
|
||||||
|
val data: SubjectEntity
|
||||||
|
) : CustomItemDTO(_componentId, _link) {
|
||||||
|
|
||||||
|
val scrollState = ScrollState()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 微信小游戏专题
|
||||||
|
data class WechatMiniGamesItemDTO(
|
||||||
|
private val _componentId: String,
|
||||||
|
private val _link: LinkEntity,
|
||||||
|
val data: SubjectEntity
|
||||||
|
) : CustomItemDTO(_componentId, _link) {
|
||||||
|
|
||||||
|
val scrollState = ScrollState()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 微信小游戏CPM专题组件
|
||||||
|
data class WeChatMiniGamesCPMSubjectItemDTO(
|
||||||
|
private val _componentId: String,
|
||||||
|
private val _link: LinkEntity,
|
||||||
|
var data: SubjectEntity
|
||||||
|
) : CustomItemDTO(_componentId, _link){
|
||||||
|
|
||||||
|
val scrollState = ScrollState()
|
||||||
|
}
|
||||||
|
|
||||||
|
// DSP专题组件
|
||||||
|
data class DSPItemDTO(
|
||||||
|
private val _componentId: String,
|
||||||
|
private val _link: LinkEntity,
|
||||||
|
var data: SubjectEntity
|
||||||
|
) : CustomItemDTO(_componentId, _link){
|
||||||
|
|
||||||
|
val scrollState = ScrollState()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 插件化区域
|
||||||
|
data class PluginItemDTO(
|
||||||
|
private val _componentId: String,
|
||||||
|
private val _link: LinkEntity,
|
||||||
|
var data: List<GameEntity>
|
||||||
|
) : CustomItemDTO(_componentId, _link)
|
||||||
|
|
||||||
|
// 新游开测
|
||||||
|
data class GameTestV2ItemDTO(
|
||||||
|
private val _componentId: String,
|
||||||
|
private val _link: LinkEntity,
|
||||||
|
val data: HomeItemTestV2Entity
|
||||||
|
) : CustomItemDTO(_componentId, _link)
|
||||||
|
|
||||||
|
// 光环推荐
|
||||||
|
data class DiscoverCardItemDTO(
|
||||||
|
private val _componentId: String,
|
||||||
|
private val _link: LinkEntity,
|
||||||
|
var data: DiscoveryCardEntity?
|
||||||
|
) : CustomItemDTO(_componentId, _link)
|
||||||
|
|
||||||
|
// 安利墙
|
||||||
|
data class AmwayItemDTO(
|
||||||
|
private val _componentId: String,
|
||||||
|
private val _link: LinkEntity,
|
||||||
|
val data: List<AmwayCommentEntity>
|
||||||
|
) : CustomItemDTO(_componentId, _link)
|
||||||
|
|
||||||
|
// 内容卡片
|
||||||
|
data class ContentCardItemDTO(
|
||||||
|
private val _componentId: String,
|
||||||
|
private val _link: LinkEntity,
|
||||||
|
val data: CustomPageData.ContentCard
|
||||||
|
) : CustomItemDTO(_componentId, _link)
|
||||||
|
|
||||||
|
// 通用内容合集
|
||||||
|
data class CommonContentCollectionItemDTO(
|
||||||
|
private val _componentId: String,
|
||||||
|
private val _link: LinkEntity,
|
||||||
|
val data: CustomPageData.CommonContentCollection
|
||||||
|
) : CustomItemDTO(_componentId, _link)
|
||||||
|
|
||||||
|
// PK
|
||||||
|
data class PKItemDTO(
|
||||||
|
private val _componentId: String,
|
||||||
|
private val _link: LinkEntity,
|
||||||
|
var data: PKEntity?
|
||||||
|
) : CustomItemDTO(_componentId, _link)
|
||||||
|
|
||||||
|
class ScrollState(
|
||||||
|
var scrolledOffset: Int = 0
|
||||||
|
)
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
package com.gh.gamecenter.home.custom.model
|
||||||
|
|
||||||
|
import android.util.LruCache
|
||||||
|
import com.gh.gamecenter.feature.entity.GameEntity
|
||||||
|
import io.reactivex.Observable
|
||||||
|
import io.reactivex.Single
|
||||||
|
|
||||||
|
class CustomPageCacheDataSource {
|
||||||
|
|
||||||
|
// 计算内存缓存大小,这里取应用最大可用内存的1/8(单位:KB)
|
||||||
|
private fun calculateMemoryCacheSize(): Int {
|
||||||
|
val maxMemory = (Runtime.getRuntime().maxMemory() / 1024).toInt()
|
||||||
|
return maxMemory / 8
|
||||||
|
}
|
||||||
|
|
||||||
|
private val memoryCache: LruCache<String, List<GameEntity>> =
|
||||||
|
object : LruCache<String, List<GameEntity>>(calculateMemoryCacheSize()) {
|
||||||
|
override fun sizeOf(key: String, value: List<GameEntity>): Int {
|
||||||
|
return value.toTypedArray().size / 1024 // 单位:KB
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getGameList(subjectId: String) = Observable.create {
|
||||||
|
val gameList = memoryCache.get(subjectId)
|
||||||
|
if (gameList.isNullOrEmpty()) {
|
||||||
|
it.onComplete()
|
||||||
|
} else {
|
||||||
|
it.onNext(gameList)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun putGameList(subjectId: String?, data: List<GameEntity>) {
|
||||||
|
if (!subjectId.isNullOrBlank()) {
|
||||||
|
memoryCache.put(subjectId, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onClear() {
|
||||||
|
memoryCache.evictAll()
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -15,10 +15,10 @@ import com.gh.gamecenter.feature.exposure.ExposureEvent
|
|||||||
import com.gh.vspace.VGameItemData
|
import com.gh.vspace.VGameItemData
|
||||||
|
|
||||||
abstract class CustomPageItem(
|
abstract class CustomPageItem(
|
||||||
// 当前模块在数据列表中的位置(注意:非ui页面的位置,而是数据列表中的位置,因为某条数据可能会拆分成多个item)
|
|
||||||
val link: LinkEntity,
|
val link: LinkEntity,
|
||||||
var position: Int,
|
var position: Int,// 当前模块在数据列表中的位置(注意:非ui页面的位置,而是数据列表中的位置,因为某条数据可能会拆分成多个item)
|
||||||
val componentPosition: Int
|
val componentPosition: Int,
|
||||||
|
val componentId: String,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
abstract val itemType: Int
|
abstract val itemType: Int
|
||||||
@ -362,9 +362,11 @@ abstract class CustomPageItem(
|
|||||||
data class CustomSubjectItem(
|
data class CustomSubjectItem(
|
||||||
private val _link: LinkEntity,
|
private val _link: LinkEntity,
|
||||||
val data: SubjectEntity,
|
val data: SubjectEntity,
|
||||||
|
private val scrollState: ScrollState,
|
||||||
private val _position: Int,
|
private val _position: Int,
|
||||||
private val _componentPosition: Int
|
private val _componentPosition: Int,
|
||||||
) : CustomPageItem(_link, _position, _componentPosition) {
|
private val _componentId: String,
|
||||||
|
) : CustomPageItem(_link, _position, _componentPosition, _componentId) {
|
||||||
|
|
||||||
override val itemType: Int
|
override val itemType: Int
|
||||||
get() = subjectTypeMap[data.type] ?: CUSTOM_PAGE_ITEM_TYPE_INVALID
|
get() = subjectTypeMap[data.type] ?: CUSTOM_PAGE_ITEM_TYPE_INVALID
|
||||||
@ -379,7 +381,11 @@ data class CustomSubjectItem(
|
|||||||
get() = data.data ?: emptyList()
|
get() = data.data ?: emptyList()
|
||||||
|
|
||||||
// 临时变量,记录横向列表滚动的距离
|
// 临时变量,记录横向列表滚动的距离
|
||||||
var scrolledOffset: Int = 0
|
var scrolledOffset: Int
|
||||||
|
get() = scrollState.scrolledOffset
|
||||||
|
set(value) {
|
||||||
|
scrollState.scrolledOffset = value
|
||||||
|
}
|
||||||
|
|
||||||
val exposureSource: List<ExposureSource>
|
val exposureSource: List<ExposureSource>
|
||||||
get() = listOf(ExposureSource("专题", "${data.name ?: ""}+$componentStyle+${data.id}"))
|
get() = listOf(ExposureSource("专题", "${data.name ?: ""}+$componentStyle+${data.id}"))
|
||||||
@ -420,7 +426,7 @@ data class CustomSubjectItem(
|
|||||||
if (latestDayBeforeTodayPair.first >= testDayOffset) {
|
if (latestDayBeforeTodayPair.first >= testDayOffset) {
|
||||||
latestDayBeforeTodayPair = Pair(testDayOffset, index)
|
latestDayBeforeTodayPair = Pair(testDayOffset, index)
|
||||||
}
|
}
|
||||||
} else if (testDayOffset > 0) {
|
} else {
|
||||||
if (testDayOffset <= latestDayAfterTodayPair.first) {
|
if (testDayOffset <= latestDayAfterTodayPair.first) {
|
||||||
latestDayAfterTodayPair = Pair(testDayOffset, index)
|
latestDayAfterTodayPair = Pair(testDayOffset, index)
|
||||||
}
|
}
|
||||||
@ -440,11 +446,12 @@ data class CustomSubjectItem(
|
|||||||
data class CustomSplitSubjectItem(
|
data class CustomSplitSubjectItem(
|
||||||
private val _link: LinkEntity,
|
private val _link: LinkEntity,
|
||||||
var data: SubjectEntity,
|
var data: SubjectEntity,
|
||||||
|
val step: Int,
|
||||||
|
val startChildPosition: Int,
|
||||||
private val _position: Int,
|
private val _position: Int,
|
||||||
private val _componentPosition: Int,
|
private val _componentPosition: Int,
|
||||||
val step: Int,
|
private val _componentId: String,
|
||||||
val startChildPosition: Int
|
) : CustomPageItem(_link, _position, _componentPosition, _componentId) {
|
||||||
) : CustomPageItem(_link, _position, _componentPosition) {
|
|
||||||
|
|
||||||
var splitItemCount: Int = -1 // 游戏专题拆分出来的子项数量
|
var splitItemCount: Int = -1 // 游戏专题拆分出来的子项数量
|
||||||
|
|
||||||
@ -509,8 +516,9 @@ data class CustomGameItem(
|
|||||||
val linkColumn: SubjectEntity?,
|
val linkColumn: SubjectEntity?,
|
||||||
val childPosition: Int,
|
val childPosition: Int,
|
||||||
private val _position: Int, // 当前 item 在 ui 中的位置
|
private val _position: Int, // 当前 item 在 ui 中的位置
|
||||||
private val _componentPosition: Int // 当前组件的位置
|
private val _componentPosition: Int, // 当前组件的位置
|
||||||
) : CustomPageItem(_link, _position, _componentPosition) {
|
private val _componentId: String
|
||||||
|
) : CustomPageItem(_link, _position, _componentPosition, _componentId) {
|
||||||
|
|
||||||
override val itemType: Int
|
override val itemType: Int
|
||||||
get() = CUSTOM_PAGE_ITEM_TYPE_GAME_HOME_GAME_ITEM
|
get() = CUSTOM_PAGE_ITEM_TYPE_GAME_HOME_GAME_ITEM
|
||||||
@ -546,9 +554,11 @@ data class CustomGameItem(
|
|||||||
data class CustomSubjectCollectionItem(
|
data class CustomSubjectCollectionItem(
|
||||||
private val _link: LinkEntity,
|
private val _link: LinkEntity,
|
||||||
val data: CustomPageData.LinkColumnCollection,
|
val data: CustomPageData.LinkColumnCollection,
|
||||||
|
val uiState: CollectionItemDTO.UIState,
|
||||||
private val _position: Int,
|
private val _position: Int,
|
||||||
private val _componentPosition: Int
|
private val _componentPosition: Int,
|
||||||
) : CustomPageItem(_link, _position, _componentPosition) {
|
private val _componentId: String
|
||||||
|
) : CustomPageItem(_link, _position, _componentPosition, _componentId) {
|
||||||
|
|
||||||
val isSubjectCollection: Boolean // 是否是专题合集(还有可能是游戏单合集)
|
val isSubjectCollection: Boolean // 是否是专题合集(还有可能是游戏单合集)
|
||||||
get() = link.type == CUSTOM_LINK_TYPE_COLUMN_COLLECTION
|
get() = link.type == CUSTOM_LINK_TYPE_COLUMN_COLLECTION
|
||||||
@ -572,19 +582,14 @@ data class CustomSubjectCollectionItem(
|
|||||||
emptyList()
|
emptyList()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 临时变量:记录合集中,轮换刷新时当前显示的页码
|
//当前显示的页码
|
||||||
var showPage: Int = 0
|
var showPage: Int = 0
|
||||||
|
|
||||||
// 临时变量:记录合集中,轮换刷新时当前加载的页码
|
var isBackToStart: Boolean
|
||||||
var loadPage: Int = 1
|
get() = uiState.isBackToStart
|
||||||
|
set(value) {
|
||||||
// 临时变量,记录点击轮换刷新时,是否正在loading
|
uiState.isBackToStart = value
|
||||||
var isLoading: Boolean = false
|
}
|
||||||
|
|
||||||
// 临时变量,数据是否已全部加载完毕
|
|
||||||
var isLoadedEnd: Boolean = false
|
|
||||||
|
|
||||||
var isBackToStart = true
|
|
||||||
|
|
||||||
val showSubject: CustomPageData.LinkColumnCollection.CustomSubjectEntity?
|
val showSubject: CustomPageData.LinkColumnCollection.CustomSubjectEntity?
|
||||||
get() = data.data.getOrNull(showPage % data.data.size)
|
get() = data.data.getOrNull(showPage % data.data.size)
|
||||||
@ -592,14 +597,12 @@ data class CustomSubjectCollectionItem(
|
|||||||
override fun doAreItemsTheSame(other: CustomPageItem): Boolean {
|
override fun doAreItemsTheSame(other: CustomPageItem): Boolean {
|
||||||
return other is CustomSubjectCollectionItem
|
return other is CustomSubjectCollectionItem
|
||||||
&& data.id == other.data.id
|
&& data.id == other.data.id
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun doAreContentsTheSames(other: CustomPageItem): Boolean {
|
override fun doAreContentsTheSames(other: CustomPageItem): Boolean {
|
||||||
return other is CustomSubjectCollectionItem
|
return other is CustomSubjectCollectionItem
|
||||||
&& showPage == other.showPage
|
&& showPage == other.showPage
|
||||||
&& isLoading == other.isLoading
|
|
||||||
&& isLoadedEnd == other.isLoadedEnd
|
|
||||||
&& showSubject == other.showSubject
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -608,8 +611,9 @@ data class CustomRecentGamesItem(
|
|||||||
private val _link: LinkEntity,
|
private val _link: LinkEntity,
|
||||||
val data: List<VGameItemData>,
|
val data: List<VGameItemData>,
|
||||||
private val _position: Int,
|
private val _position: Int,
|
||||||
private val _componentPosition: Int
|
private val _componentPosition: Int,
|
||||||
) : CustomPageItem(_link, _position, _componentPosition) {
|
private val _componentId: String
|
||||||
|
) : CustomPageItem(_link, _position, _componentPosition, _componentId) {
|
||||||
|
|
||||||
override val itemType: Int
|
override val itemType: Int
|
||||||
get() = CUSTOM_PAGE_ITEM_TYPE_RECENT_PLAY
|
get() = CUSTOM_PAGE_ITEM_TYPE_RECENT_PLAY
|
||||||
@ -628,8 +632,9 @@ data class CustomRecentWeChatMiniGamesItem(
|
|||||||
private val _link: LinkEntity,
|
private val _link: LinkEntity,
|
||||||
val data: List<GameEntity>,
|
val data: List<GameEntity>,
|
||||||
private val _position: Int,
|
private val _position: Int,
|
||||||
private val _componentPosition: Int
|
private val _componentPosition: Int,
|
||||||
) : CustomPageItem(_link, _position, _componentPosition) {
|
private val _componentId: String
|
||||||
|
) : CustomPageItem(_link, _position, _componentPosition, _componentId) {
|
||||||
|
|
||||||
override val itemType: Int
|
override val itemType: Int
|
||||||
get() = CUSTOM_PAGE_ITEM_TYPE_MINI_GAME_RECENT_PLAY
|
get() = CUSTOM_PAGE_ITEM_TYPE_MINI_GAME_RECENT_PLAY
|
||||||
@ -647,8 +652,9 @@ data class CustomWeChatMiniGamesCPMSubjectItem(
|
|||||||
private val _link: LinkEntity,
|
private val _link: LinkEntity,
|
||||||
val data: SubjectEntity,
|
val data: SubjectEntity,
|
||||||
private val _position: Int,
|
private val _position: Int,
|
||||||
private val _componentPosition: Int
|
private val _componentPosition: Int,
|
||||||
) : CustomPageItem(_link, _position, _componentPosition) {
|
private val _componentId: String
|
||||||
|
) : CustomPageItem(_link, _position, _componentPosition, _componentId) {
|
||||||
|
|
||||||
override val itemType: Int
|
override val itemType: Int
|
||||||
get() = CUSTOM_PAGE_ITEM_TYPE_MINI_GAME_RECENT_PLAY
|
get() = CUSTOM_PAGE_ITEM_TYPE_MINI_GAME_RECENT_PLAY
|
||||||
@ -667,8 +673,9 @@ data class CustomRecentQqMiniGamesItem(
|
|||||||
val data: List<GameEntity>,
|
val data: List<GameEntity>,
|
||||||
val linkQqGameRecentlyPlayed: CustomPageData.LinkRecentlyPlayed,
|
val linkQqGameRecentlyPlayed: CustomPageData.LinkRecentlyPlayed,
|
||||||
private val _position: Int,
|
private val _position: Int,
|
||||||
private val _componentPosition: Int
|
private val _componentPosition: Int,
|
||||||
) : CustomPageItem(_link, _position, _componentPosition) {
|
private val _componentId: String
|
||||||
|
) : CustomPageItem(_link, _position, _componentPosition, _componentId) {
|
||||||
|
|
||||||
override val itemType: Int
|
override val itemType: Int
|
||||||
get() = CUSTOM_PAGE_ITEM_TYPE_MINI_GAME_RECENT_PLAY
|
get() = CUSTOM_PAGE_ITEM_TYPE_MINI_GAME_RECENT_PLAY
|
||||||
@ -690,8 +697,9 @@ data class CustomRecentAcceleratorItem(
|
|||||||
val data: List<AcctRecord>,
|
val data: List<AcctRecord>,
|
||||||
val moreLink: LinkEntity?,
|
val moreLink: LinkEntity?,
|
||||||
private val _position: Int,
|
private val _position: Int,
|
||||||
private val _componentPosition: Int
|
private val _componentPosition: Int,
|
||||||
) : CustomPageItem(_link, _position, _componentPosition) {
|
private val _componentId: String
|
||||||
|
) : CustomPageItem(_link, _position, _componentPosition, _componentId) {
|
||||||
|
|
||||||
override val itemType: Int
|
override val itemType: Int
|
||||||
get() = CUSTOM_PAGE_ITEM_TYPE_ACCELERATOR_RECENT_PLAYED
|
get() = CUSTOM_PAGE_ITEM_TYPE_ACCELERATOR_RECENT_PLAYED
|
||||||
@ -713,8 +721,9 @@ data class CustomPluginItem(
|
|||||||
private val _link: LinkEntity,
|
private val _link: LinkEntity,
|
||||||
val data: List<GameEntity>,
|
val data: List<GameEntity>,
|
||||||
private val _position: Int,
|
private val _position: Int,
|
||||||
private val _componentPosition: Int
|
private val _componentPosition: Int,
|
||||||
) : CustomPageItem(_link, _position, _componentPosition) {
|
private val _componentId: String
|
||||||
|
) : CustomPageItem(_link, _position, _componentPosition, _componentId) {
|
||||||
|
|
||||||
override val itemType: Int
|
override val itemType: Int
|
||||||
get() = CUSTOM_PAGE_ITEM_TYPE_PLUGIN
|
get() = CUSTOM_PAGE_ITEM_TYPE_PLUGIN
|
||||||
@ -735,8 +744,9 @@ data class CustomGameTestV2Item(
|
|||||||
private val _link: LinkEntity,
|
private val _link: LinkEntity,
|
||||||
val data: HomeItemTestV2Entity,
|
val data: HomeItemTestV2Entity,
|
||||||
private val _position: Int,
|
private val _position: Int,
|
||||||
private val _componentPosition: Int
|
private val _componentPosition: Int,
|
||||||
) : CustomPageItem(_link, _position, _componentPosition) {
|
private val _componentId: String
|
||||||
|
) : CustomPageItem(_link, _position, _componentPosition, _componentId) {
|
||||||
|
|
||||||
override val itemType: Int
|
override val itemType: Int
|
||||||
get() = CUSTOM_PAGE_ITEM_TYPE_NEW_GAME_TEST
|
get() = CUSTOM_PAGE_ITEM_TYPE_NEW_GAME_TEST
|
||||||
@ -754,8 +764,9 @@ data class CustomDiscoverCardItem(
|
|||||||
private val _link: LinkEntity,
|
private val _link: LinkEntity,
|
||||||
val data: DiscoveryCardEntity?,
|
val data: DiscoveryCardEntity?,
|
||||||
private val _position: Int,
|
private val _position: Int,
|
||||||
private val _componentPosition: Int
|
private val _componentPosition: Int,
|
||||||
) : CustomPageItem(_link, _position, _componentPosition) {
|
private val _componentId: String
|
||||||
|
) : CustomPageItem(_link, _position, _componentPosition, _componentId) {
|
||||||
|
|
||||||
val spanCount = 3
|
val spanCount = 3
|
||||||
|
|
||||||
@ -781,8 +792,9 @@ data class CustomAmwayItem(
|
|||||||
private val _link: LinkEntity,
|
private val _link: LinkEntity,
|
||||||
val data: List<AmwayCommentEntity>,
|
val data: List<AmwayCommentEntity>,
|
||||||
private val _position: Int,
|
private val _position: Int,
|
||||||
private val _componentPosition: Int
|
private val _componentPosition: Int,
|
||||||
) : CustomPageItem(_link, _position, _componentPosition) {
|
private val _componentId: String
|
||||||
|
) : CustomPageItem(_link, _position, _componentPosition, _componentId) {
|
||||||
|
|
||||||
override val itemType: Int
|
override val itemType: Int
|
||||||
get() = CUSTOM_PAGE_ITEM_TYPE_AMWAY_WALL
|
get() = CUSTOM_PAGE_ITEM_TYPE_AMWAY_WALL
|
||||||
@ -800,8 +812,9 @@ data class CustomContentCardItem(
|
|||||||
private val _link: LinkEntity,
|
private val _link: LinkEntity,
|
||||||
val data: CustomPageData.ContentCard,
|
val data: CustomPageData.ContentCard,
|
||||||
private val _position: Int,
|
private val _position: Int,
|
||||||
private val _componentPosition: Int
|
private val _componentPosition: Int,
|
||||||
) : CustomPageItem(_link, _position, _componentPosition) {
|
private val _componentId: String
|
||||||
|
) : CustomPageItem(_link, _position, _componentPosition, _componentId) {
|
||||||
|
|
||||||
override val itemType: Int
|
override val itemType: Int
|
||||||
get() = CUSTOM_PAGE_ITEM_TYPE_CONTENT_CARD
|
get() = CUSTOM_PAGE_ITEM_TYPE_CONTENT_CARD
|
||||||
@ -822,8 +835,9 @@ data class CustomCommonContentCollectionItem(
|
|||||||
private val _link: LinkEntity,
|
private val _link: LinkEntity,
|
||||||
val data: CustomPageData.CommonContentCollection,
|
val data: CustomPageData.CommonContentCollection,
|
||||||
private val _position: Int,
|
private val _position: Int,
|
||||||
private val _componentPosition: Int
|
private val _componentPosition: Int,
|
||||||
) : CustomPageItem(_link, _position, _componentPosition) {
|
private val _componentId: String
|
||||||
|
) : CustomPageItem(_link, _position, _componentPosition, _componentId) {
|
||||||
|
|
||||||
override val itemType: Int
|
override val itemType: Int
|
||||||
get() = if (data.layout == COMMON_CONTENT_COLLECTION_LAYOUT_BANNER) {
|
get() = if (data.layout == COMMON_CONTENT_COLLECTION_LAYOUT_BANNER) {
|
||||||
@ -861,10 +875,11 @@ data class CustomCommonContentCollectionItem(
|
|||||||
data class CustomSplitCommonContentCollectionItem(
|
data class CustomSplitCommonContentCollectionItem(
|
||||||
private val _link: LinkEntity,
|
private val _link: LinkEntity,
|
||||||
val data: CustomPageData.CommonContentCollection,
|
val data: CustomPageData.CommonContentCollection,
|
||||||
|
val leftPosition: Int,
|
||||||
private val _position: Int,
|
private val _position: Int,
|
||||||
private val _componentPosition: Int,
|
private val _componentPosition: Int,
|
||||||
val leftPosition: Int,
|
private val _componentId: String
|
||||||
) : CustomPageItem(_link, _position, _componentPosition) {
|
) : CustomPageItem(_link, _position, _componentPosition, _componentId) {
|
||||||
|
|
||||||
override val itemType
|
override val itemType
|
||||||
get() = commonContentCollection[data.layout] ?: CUSTOM_PAGE_ITEM_TYPE_INVALID
|
get() = commonContentCollection[data.layout] ?: CUSTOM_PAGE_ITEM_TYPE_INVALID
|
||||||
@ -897,8 +912,9 @@ data class CustomPKItem(
|
|||||||
private val _link: LinkEntity,
|
private val _link: LinkEntity,
|
||||||
val data: PKEntity?,
|
val data: PKEntity?,
|
||||||
private val _position: Int,
|
private val _position: Int,
|
||||||
private val _componentPosition: Int
|
private val _componentPosition: Int,
|
||||||
) : CustomPageItem(_link, _position, _componentPosition) {
|
private val _componentId: String
|
||||||
|
) : CustomPageItem(_link, _position, _componentPosition, _componentId) {
|
||||||
|
|
||||||
override val itemType: Int
|
override val itemType: Int
|
||||||
get() = CUSTOM_PAGE_ITEM_TYPE_PK
|
get() = CUSTOM_PAGE_ITEM_TYPE_PK
|
||||||
@ -916,8 +932,9 @@ data class CustomDspPlaceholderItem(
|
|||||||
private val _link: LinkEntity,
|
private val _link: LinkEntity,
|
||||||
val data: SubjectEntity,
|
val data: SubjectEntity,
|
||||||
private val _position: Int,
|
private val _position: Int,
|
||||||
private val _componentPosition: Int
|
private val _componentPosition: Int,
|
||||||
) : CustomPageItem(_link, _position, _componentPosition) {
|
private val _componentId: String
|
||||||
|
) : CustomPageItem(_link, _position, _componentPosition, _componentId) {
|
||||||
|
|
||||||
override val itemType: Int
|
override val itemType: Int
|
||||||
get() = CUSTOM_PAGE_ITEM_TYPE_MINI_GAME_RECENT_PLAY
|
get() = CUSTOM_PAGE_ITEM_TYPE_MINI_GAME_RECENT_PLAY
|
||||||
@ -930,14 +947,9 @@ data class CustomDspPlaceholderItem(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object CustomFooterItem : CustomPageItem(LinkEntity(), -1, -1) {
|
object CustomFooterItem : CustomPageItem(LinkEntity(), -1, -1, "") {
|
||||||
override val itemType: Int
|
override val itemType: Int
|
||||||
get() = CUSTOM_PAGE_ITEM_TYPE_FOOTER
|
get() = CUSTOM_PAGE_ITEM_TYPE_FOOTER
|
||||||
}
|
}
|
||||||
|
|
||||||
object CustomInvalidItem : CustomPageItem(LinkEntity(), -2, -2) {
|
|
||||||
override val itemType: Int
|
|
||||||
get() = CUSTOM_PAGE_ITEM_TYPE_INVALID
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
package com.gh.gamecenter.home.custom.model
|
package com.gh.gamecenter.home.custom.model
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.util.LruCache
|
||||||
import com.gh.gamecenter.core.utils.SPUtils
|
import com.gh.gamecenter.core.utils.SPUtils
|
||||||
import com.gh.gamecenter.feature.entity.FloatingWindowEntity
|
import com.gh.gamecenter.feature.entity.FloatingWindowEntity
|
||||||
|
import com.gh.gamecenter.feature.entity.GameEntity
|
||||||
import com.halo.assistant.HaloApp
|
import com.halo.assistant.HaloApp
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|||||||
@ -56,12 +56,17 @@ class CustomPageRemoteDataSource(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun loadCollectionContent(item: CustomSubjectCollectionItem): Single<List<CustomPageData.LinkColumnCollection.CustomSubjectEntity>> =
|
fun loadColumnsCollectionContents(
|
||||||
if (item.isSubjectCollection) {
|
collectionId: String,
|
||||||
newApi.getColumnsCollectionContents(item.data.id, "component", item.loadPage + 1, 1)
|
page: Int
|
||||||
} else {
|
): Single<MutableList<CustomPageData.LinkColumnCollection.CustomSubjectEntity>> =
|
||||||
newApi.getGameCollectionContents(item.data.id, "component", item.loadPage + 1, 1)
|
newApi.getColumnsCollectionContents(collectionId, "component", page, 1)
|
||||||
}
|
|
||||||
|
fun loadGameCollectionContents(
|
||||||
|
collectionId: String,
|
||||||
|
page: Int
|
||||||
|
): Single<MutableList<CustomPageData.LinkColumnCollection.CustomSubjectEntity>> =
|
||||||
|
newApi.getGameCollectionContents(collectionId, "component", page, 1)
|
||||||
|
|
||||||
fun loadChangeSubjectGame(subjectEntity: SubjectEntity): Observable<List<GameEntity>> =
|
fun loadChangeSubjectGame(subjectEntity: SubjectEntity): Observable<List<GameEntity>> =
|
||||||
if (subjectEntity.isQQColumn) {
|
if (subjectEntity.isQQColumn) {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -2,10 +2,13 @@ package com.gh.gamecenter.home.custom.model
|
|||||||
|
|
||||||
import androidx.annotation.MainThread
|
import androidx.annotation.MainThread
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.lifecycle.MediatorLiveData
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.asLiveData
|
import androidx.lifecycle.asLiveData
|
||||||
import com.gh.common.filter.RegionSettingHelper
|
import com.gh.common.filter.RegionSettingHelper
|
||||||
|
import com.gh.common.util.HomePluggableHelper
|
||||||
import com.gh.common.util.PackageUtils
|
import com.gh.common.util.PackageUtils
|
||||||
|
import com.gh.download.DownloadManager
|
||||||
import com.gh.gamecenter.common.constant.Constants
|
import com.gh.gamecenter.common.constant.Constants
|
||||||
import com.gh.gamecenter.common.constant.Constants.SP_HIDDEN_NOTIFICATIONS
|
import com.gh.gamecenter.common.constant.Constants.SP_HIDDEN_NOTIFICATIONS
|
||||||
import com.gh.gamecenter.common.utils.observableToMain
|
import com.gh.gamecenter.common.utils.observableToMain
|
||||||
@ -17,7 +20,9 @@ import com.gh.gamecenter.entity.DiscoveryGameCardEntity
|
|||||||
import com.gh.gamecenter.entity.DiscoveryGameCardLabel
|
import com.gh.gamecenter.entity.DiscoveryGameCardLabel
|
||||||
import com.gh.gamecenter.feature.entity.AcctRecord
|
import com.gh.gamecenter.feature.entity.AcctRecord
|
||||||
import com.gh.gamecenter.feature.entity.GameEntity
|
import com.gh.gamecenter.feature.entity.GameEntity
|
||||||
|
import com.gh.gamecenter.feature.entity.PluginLocation
|
||||||
import com.gh.gamecenter.gamedetail.accelerator.AccelerationDataBase
|
import com.gh.gamecenter.gamedetail.accelerator.AccelerationDataBase
|
||||||
|
import com.gh.gamecenter.packagehelper.PackageRepository
|
||||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import com.google.gson.reflect.TypeToken
|
import com.google.gson.reflect.TypeToken
|
||||||
@ -34,6 +39,30 @@ class CustomPageShareRepository private constructor() {
|
|||||||
|
|
||||||
private val compositeDisposable = CompositeDisposable()
|
private val compositeDisposable = CompositeDisposable()
|
||||||
|
|
||||||
|
private val _pluginGames = MediatorLiveData<List<GameEntity>>().apply {
|
||||||
|
addSource(PackageRepository.gameUpdateLiveData) { updateList ->
|
||||||
|
val gameList = arrayListOf<GameEntity>()
|
||||||
|
updateList.forEach {
|
||||||
|
if (it.isPluggable && it.indexPlugin == "open" && it.isShowPlugin(PluginLocation.only_index)) {
|
||||||
|
val game = it.transformGameEntity()
|
||||||
|
if (HomePluggableHelper.showHomePluggable(game)) {
|
||||||
|
game.setEntryMap(DownloadManager.getInstance().getEntryMap(game.name))
|
||||||
|
gameList.add(game)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 下载七天排序
|
||||||
|
gameList.sortWith { o1, o2 -> o2.download - o1.download }
|
||||||
|
value = gameList
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val pluginGames: LiveData<List<GameEntity>> = _pluginGames
|
||||||
|
fun temporarilyBlockGameInPluginItem(gameId: String) {
|
||||||
|
val gameList = _pluginGames.value ?: return
|
||||||
|
_pluginGames.value = gameList.filterNot { it.id == gameId }
|
||||||
|
}
|
||||||
|
|
||||||
private val _discoverData = MutableLiveData<DiscoveryCardEntity>()
|
private val _discoverData = MutableLiveData<DiscoveryCardEntity>()
|
||||||
val discoverData: LiveData<DiscoveryCardEntity> = _discoverData
|
val discoverData: LiveData<DiscoveryCardEntity> = _discoverData
|
||||||
|
|
||||||
|
|||||||
@ -26,10 +26,7 @@ import com.gh.gamecenter.home.custom.createExposureEvent
|
|||||||
import com.gh.gamecenter.home.custom.eventlistener.CustomPageItemChildEventHelper
|
import com.gh.gamecenter.home.custom.eventlistener.CustomPageItemChildEventHelper
|
||||||
import com.gh.gamecenter.home.custom.eventlistener.GameSubjectCollectionEventHelper
|
import com.gh.gamecenter.home.custom.eventlistener.GameSubjectCollectionEventHelper
|
||||||
import com.gh.gamecenter.home.custom.eventlistener.SubjectEventHelper
|
import com.gh.gamecenter.home.custom.eventlistener.SubjectEventHelper
|
||||||
import com.gh.gamecenter.home.custom.model.CustomPageItem
|
import com.gh.gamecenter.home.custom.model.*
|
||||||
import com.gh.gamecenter.home.custom.model.CustomSplitSubjectItem
|
|
||||||
import com.gh.gamecenter.home.custom.model.CustomSubjectCollectionItem
|
|
||||||
import com.gh.gamecenter.home.custom.model.CustomSubjectItem
|
|
||||||
import com.lightgame.download.DownloadEntity
|
import com.lightgame.download.DownloadEntity
|
||||||
|
|
||||||
abstract class BaseCustomViewHolder(
|
abstract class BaseCustomViewHolder(
|
||||||
@ -98,7 +95,14 @@ abstract class BaseCustomViewHolder(
|
|||||||
titleBinding.root.goneIf(false)
|
titleBinding.root.goneIf(false)
|
||||||
setSubjectTitle(
|
setSubjectTitle(
|
||||||
titleBinding,
|
titleBinding,
|
||||||
CustomSubjectItem(item.link, item.data, item.position, item.componentPosition),
|
CustomSubjectItem(
|
||||||
|
item.link,
|
||||||
|
item.data,
|
||||||
|
ScrollState(),
|
||||||
|
item.position,
|
||||||
|
item.componentPosition,
|
||||||
|
item.componentId
|
||||||
|
),
|
||||||
eventHelper,
|
eventHelper,
|
||||||
titleType
|
titleType
|
||||||
)
|
)
|
||||||
@ -189,7 +193,7 @@ abstract class BaseCustomViewHolder(
|
|||||||
when (subject.home) {
|
when (subject.home) {
|
||||||
HOME_CHANGE -> {
|
HOME_CHANGE -> {
|
||||||
// 点击换一批
|
// 点击换一批
|
||||||
eventHelper.onChangeABatch(subject)
|
eventHelper.onChangeABatch(item.componentId, subject)
|
||||||
}
|
}
|
||||||
|
|
||||||
HOME_MORE -> {
|
HOME_MORE -> {
|
||||||
|
|||||||
@ -88,7 +88,7 @@ class CustomRefreshIconViewHolder(
|
|||||||
} else {
|
} else {
|
||||||
_subjectEntity = subjectEntity
|
_subjectEntity = subjectEntity
|
||||||
}
|
}
|
||||||
|
println("kayn -->isBackToStart:${item.isBackToStart}")
|
||||||
// 如果游戏全部被屏蔽,自动加载下一页
|
// 如果游戏全部被屏蔽,自动加载下一页
|
||||||
if (subjectEntity.games.isEmpty()) {
|
if (subjectEntity.games.isEmpty()) {
|
||||||
childEventHelper.onRotateRefresh()
|
childEventHelper.onRotateRefresh()
|
||||||
|
|||||||
@ -38,19 +38,12 @@ object MiniGameRecentlyPlayUseCase {
|
|||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(object : BiResponse<List<GameEntity>>() {
|
.subscribe(object : BiResponse<List<GameEntity>>() {
|
||||||
override fun onSuccess(data: List<GameEntity>) {
|
override fun onSuccess(data: List<GameEntity>) {
|
||||||
if (gameType == Constants.QQ_MINI_GAME) {
|
if (data.isNotEmpty()) {
|
||||||
_qqRecentGamesItemLiveData.value = data
|
if (gameType == Constants.QQ_MINI_GAME) {
|
||||||
} else {
|
_qqRecentGamesItemLiveData.value = data
|
||||||
_wechatRecentGamesItemLiveData.value = data
|
} else {
|
||||||
}
|
_wechatRecentGamesItemLiveData.value = data
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFailure(exception: Exception) {
|
|
||||||
super.onFailure(exception)
|
|
||||||
if (gameType == Constants.QQ_MINI_GAME) {
|
|
||||||
_qqRecentGamesItemLiveData.value = emptyList()
|
|
||||||
} else {
|
|
||||||
_wechatRecentGamesItemLiveData.value = emptyList()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -90,10 +83,7 @@ object MiniGameRecentlyPlayUseCase {
|
|||||||
_qqRecentGamesItemLiveData.value
|
_qqRecentGamesItemLiveData.value
|
||||||
} else {
|
} else {
|
||||||
_wechatRecentGamesItemLiveData.value
|
_wechatRecentGamesItemLiveData.value
|
||||||
} ?: let {
|
} ?: emptyList()
|
||||||
loadRecentlyPlayedMiniGameList(gameType)// 最近在玩数据为空时,则调用接口获取数据
|
|
||||||
emptyList()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun clearRecentlyPlayedMiniGameList(gameType: String = "") {
|
fun clearRecentlyPlayedMiniGameList(gameType: String = "") {
|
||||||
when (gameType) {
|
when (gameType) {
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import com.gh.gamecenter.common.livedata.NonStickyMutableLiveData
|
|||||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||||
import com.gh.gamecenter.feature.entity.GameEntity
|
import com.gh.gamecenter.feature.entity.GameEntity
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -14,11 +15,7 @@ import io.reactivex.schedulers.Schedulers
|
|||||||
class WGameSubjectCPMListUseCase(
|
class WGameSubjectCPMListUseCase(
|
||||||
private val repository: WGameSubjectCPMListRepository = WGameSubjectCPMListRepository()
|
private val repository: WGameSubjectCPMListRepository = WGameSubjectCPMListRepository()
|
||||||
) {
|
) {
|
||||||
|
private val compositeDisposable = CompositeDisposable()
|
||||||
/**
|
|
||||||
* 微信专题CPM请求记录,用于避免重复请求,以专题ID作为Key
|
|
||||||
*/
|
|
||||||
private val requestKeyList = mutableListOf<String>()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信小游戏CPM列表,这里的LiveData充当类似于EventBus的角色,因此使用NonStickyMutableLiveData
|
* 微信小游戏CPM列表,这里的LiveData充当类似于EventBus的角色,因此使用NonStickyMutableLiveData
|
||||||
@ -26,21 +23,18 @@ class WGameSubjectCPMListUseCase(
|
|||||||
private val _wechatMiniGameCPMListLiveData = NonStickyMutableLiveData<Pair<String, List<GameEntity>>>()
|
private val _wechatMiniGameCPMListLiveData = NonStickyMutableLiveData<Pair<String, List<GameEntity>>>()
|
||||||
val wechatMiniGameCPMListLiveData: LiveData<Pair<String, List<GameEntity>>> = _wechatMiniGameCPMListLiveData
|
val wechatMiniGameCPMListLiveData: LiveData<Pair<String, List<GameEntity>>> = _wechatMiniGameCPMListLiveData
|
||||||
|
|
||||||
@SuppressLint("CheckResult")
|
fun getWechatMiniGameCPMList(componentId: String, minimumSize: Int, onlyFee: Boolean) {
|
||||||
fun getWechatMiniGameCPMList(subjectId: String?, minimumSize: Int, onlyFee: Boolean) {
|
|
||||||
if (subjectId.isNullOrEmpty() || requestKeyList.contains(subjectId)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
requestKeyList.add(subjectId)
|
|
||||||
repository.getColumn(null, 1, null, null, null, null, minimumSize, onlyFee)
|
repository.getColumn(null, 1, null, null, null, null, minimumSize, onlyFee)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(object : BiResponse<List<GameEntity>>() {
|
.subscribe(object : BiResponse<List<GameEntity>>() {
|
||||||
override fun onSuccess(data: List<GameEntity>) {
|
override fun onSuccess(data: List<GameEntity>) {
|
||||||
requestKeyList.remove(subjectId)
|
_wechatMiniGameCPMListLiveData.value = componentId to data
|
||||||
_wechatMiniGameCPMListLiveData.value = subjectId to data
|
|
||||||
}
|
}
|
||||||
})
|
}).let(compositeDisposable::add)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onClear() {
|
||||||
|
compositeDisposable.clear()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user