游戏板块完成
This commit is contained in:
@ -14,6 +14,7 @@ import android.widget.LinearLayout
|
||||
import com.facebook.drawee.controller.BaseControllerListener
|
||||
import com.facebook.imagepipeline.image.ImageInfo
|
||||
import com.gh.base.OnViewClickListener
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.common.constant.ItemViewType
|
||||
import com.gh.common.util.*
|
||||
import com.gh.gamecenter.*
|
||||
@ -66,10 +67,10 @@ class GameFragmentAdapter(context: Context, model: GameViewModel) : BaseRecycler
|
||||
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
if (position == 0) return ItemViewType.GAME_SLIDE
|
||||
if (itemCount == position + 1) return ItemViewType.LOADING
|
||||
|
||||
val itemData = mItemDataList[position]
|
||||
if (itemData.slideList != null || itemData.subjectRecommend != null) return ItemViewType.GAME_SLIDE
|
||||
if (itemData.pluginList != null) return ItemViewType.GAME_PULGIN
|
||||
if (itemData.columnHead != null) return ItemViewType.COLUMN_HEADER
|
||||
if (itemData.game != null) return ItemViewType.GAME_NORMAL
|
||||
@ -155,6 +156,7 @@ class GameFragmentAdapter(context: Context, model: GameViewModel) : BaseRecycler
|
||||
val itemData = mItemDataList[position]
|
||||
val gameEntity = itemData.game
|
||||
val subjectData = gameEntity?.subjectData
|
||||
|
||||
holder.binding.game = gameEntity
|
||||
holder.binding.executePendingBindings()
|
||||
holder.binding.subjectTag = subjectData?.tag
|
||||
@ -193,28 +195,19 @@ class GameFragmentAdapter(context: Context, model: GameViewModel) : BaseRecycler
|
||||
if (holder is GameViewPagerViewHolder) {
|
||||
val subjectDigestList = mItemDataList[position].subjectRecommend
|
||||
val binding = holder.binding
|
||||
|
||||
binding.list = subjectDigestList
|
||||
binding.clickListener = OnViewClickListener { v, data ->
|
||||
if (data is Int) {
|
||||
when (data) {
|
||||
0, 1, 2, 3 -> {
|
||||
if (data < subjectDigestList?.size!!) {
|
||||
val entity = subjectDigestList[data]
|
||||
if (data < subjectDigestList?.size!!) {
|
||||
val entity = subjectDigestList[data]
|
||||
|
||||
if (entity.type == "block") {
|
||||
mContext.startActivity(BlockActivity.getIntent(mContext, entity))
|
||||
} else {
|
||||
SubjectActivity.startSubjectActivity(mContext, entity.columnId, entity.columnName, entity.order
|
||||
, StringUtils.buildString("(游戏-专题:", entity.name, "[1-", (data as Int + 1).toString(), "]", ")"))
|
||||
DataCollectionUtils.uploadPosition(mContext, "游戏", (data + 1).toString(), subjectDigestList?.get(data)?.name)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
4 -> {
|
||||
val intent = KaiFuActivity.getIntent(mContext, "(游戏-专题:开服表[1-4])")
|
||||
mContext.startActivity(intent)
|
||||
DataCollectionUtils.uploadPosition(mContext, "游戏", "4", "开服表")
|
||||
if (entity.type == "block") {
|
||||
mContext.startActivity(BlockActivity.getIntent(mContext, entity))
|
||||
} else {
|
||||
SubjectActivity.startSubjectActivity(mContext, entity.columnId, entity.columnName, entity.order
|
||||
, StringUtils.buildString("(游戏-专题:", entity.name, "[1-", (data + 1).toString(), "]", ")"))
|
||||
DataCollectionUtils.uploadPosition(mContext, "游戏", (data + 1).toString(), entity.name)
|
||||
}
|
||||
}
|
||||
} else if (v.id == R.id.home_subject_failure) {
|
||||
@ -224,6 +217,35 @@ class GameFragmentAdapter(context: Context, model: GameViewModel) : BaseRecycler
|
||||
}
|
||||
}
|
||||
|
||||
if (mViewModel.blockData != null) {
|
||||
if (subjectDigestList != null && subjectDigestList.size >= 5) {
|
||||
ImageUtils.display(binding.entranceIcon5, subjectDigestList[4].icon)
|
||||
binding.entranceName5.text = if (Config.isShowPlugin()) subjectDigestList[4].name else subjectDigestList[4].nameNormal
|
||||
}
|
||||
} else {
|
||||
ImageUtils.display(binding.entranceIcon5, R.drawable.home_entrance_kaifu)
|
||||
binding.entranceName5.text = "开服表"
|
||||
}
|
||||
|
||||
binding.entranceContainer5.setOnClickListener(View.OnClickListener {
|
||||
if (mViewModel.blockData != null) {
|
||||
if (subjectDigestList != null && subjectDigestList.size >= 5) {
|
||||
val entity = subjectDigestList[4]
|
||||
if (entity.type == "block") {
|
||||
mContext.startActivity(BlockActivity.getIntent(mContext, entity))
|
||||
} else {
|
||||
SubjectActivity.startSubjectActivity(mContext, entity.columnId, entity.columnName, entity.order
|
||||
, StringUtils.buildString("(游戏-专题:", entity.name, "[1-", (5).toString(), "]", ")"))
|
||||
DataCollectionUtils.uploadPosition(mContext, "游戏", (5).toString(), entity.name)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
val intent = KaiFuActivity.getIntent(mContext, "(游戏-专题:开服表[1-4])")
|
||||
mContext.startActivity(intent)
|
||||
DataCollectionUtils.uploadPosition(mContext, "游戏", "4", "开服表")
|
||||
}
|
||||
})
|
||||
|
||||
val slideList = mItemDataList[position].slideList
|
||||
if (slideList != null && slideList.isNotEmpty() && binding.viewPager.adapter == null) {
|
||||
binding.viewpagerLlHint.removeAllViews()
|
||||
@ -275,6 +297,11 @@ class GameFragmentAdapter(context: Context, model: GameViewModel) : BaseRecycler
|
||||
})
|
||||
}
|
||||
|
||||
if (mViewModel.blockData != null) {
|
||||
if (slideList!!.isEmpty()) binding.viewpagerContainer.visibility = View.GONE
|
||||
if (subjectDigestList!!.isEmpty()) binding.entranceContainer.visibility = View.GONE
|
||||
}
|
||||
|
||||
if (mIsAutoScroll) {
|
||||
binding.viewPager.startAutoScroll()
|
||||
} else {
|
||||
|
||||
@ -34,10 +34,10 @@ class GameViewModel(application: Application, blockData: SubjectRecommendEntity?
|
||||
|
||||
var blockData = blockData
|
||||
|
||||
var slideList: List<SlideEntity>? = null // 轮播图
|
||||
var slideList = ArrayList<SlideEntity>() // 轮播图
|
||||
var pluginList: List<GameEntity>? = null // 插件化
|
||||
var subjectList: MutableList<SubjectEntity> = ArrayList() // 专题
|
||||
var subjectDigestList: List<SubjectRecommendEntity>? = null // 专题入口
|
||||
var subjectDigestList = ArrayList<SubjectRecommendEntity>() // 专题入口
|
||||
|
||||
var itemDataList: MutableLiveData<List<ItemData>> = MutableLiveData()
|
||||
val loadStatus = MutableLiveData<LoadStatus>()
|
||||
@ -58,10 +58,10 @@ class GameViewModel(application: Application, blockData: SubjectRecommendEntity?
|
||||
}
|
||||
|
||||
fun initData() {
|
||||
slideList = null
|
||||
slideList.clear()
|
||||
pluginList = null
|
||||
subjectList.clear()
|
||||
subjectDigestList = null
|
||||
subjectDigestList.clear()
|
||||
itemDataListCache.clear()
|
||||
|
||||
loadStatus.postValue(LoadStatus.INIT_LOADING)
|
||||
@ -124,7 +124,7 @@ class GameViewModel(application: Application, blockData: SubjectRecommendEntity?
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<List<SlideEntity>>() {
|
||||
override fun onResponse(response: List<SlideEntity>) {
|
||||
slideList = response
|
||||
slideList.addAll(response)
|
||||
if (initData) getSubjectDigest(initData)
|
||||
}
|
||||
|
||||
@ -145,7 +145,7 @@ class GameViewModel(application: Application, blockData: SubjectRecommendEntity?
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<List<SubjectRecommendEntity>>() {
|
||||
override fun onResponse(response: List<SubjectRecommendEntity>) {
|
||||
subjectDigestList = response
|
||||
subjectDigestList.addAll(response)
|
||||
transformationItemData()
|
||||
if (initData) {
|
||||
initPlugin()
|
||||
|
||||
Reference in New Issue
Block a user