This commit is contained in:
@ -24,7 +24,7 @@ public class GameViewHolder extends BaseRecyclerViewHolder {
|
||||
public TextView gameDownloadBtn;
|
||||
public TextView gameDes;
|
||||
public LinearLayout gameLabelList;
|
||||
public LinearLayout gameInfo;
|
||||
public View gameInfo;
|
||||
public ProgressBar gameProgressbar;
|
||||
@Nullable
|
||||
public View recommendContainer;
|
||||
|
||||
@ -94,12 +94,12 @@ class CategoryV2ListAdapter(context: Context,
|
||||
textSize = 13F
|
||||
}
|
||||
|
||||
gameDescContainer.layoutParams = (gameDescContainer.layoutParams as ViewGroup.MarginLayoutParams).apply {
|
||||
height = ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
gameDesSpace.layoutParams = (gameDesSpace.layoutParams as ViewGroup.LayoutParams).apply {
|
||||
height = 0
|
||||
}
|
||||
|
||||
gameProgressbar.layoutParams = (gameProgressbar.layoutParams as ViewGroup.MarginLayoutParams).apply {
|
||||
bottomMargin = 0F.dip2px()
|
||||
bottomMargin = 0
|
||||
}
|
||||
|
||||
labelList.layoutParams = (labelList.layoutParams as ViewGroup.MarginLayoutParams).apply {
|
||||
|
||||
@ -331,7 +331,10 @@ class GameFragmentAdapter(
|
||||
}
|
||||
|
||||
private fun bindRankCollection(holder: RankCollectionViewHolder, position: Int) {
|
||||
holder.itemView.setPadding(0, 0, 0, 16F.dip2px())
|
||||
holder.itemView.layoutParams =
|
||||
(holder.itemView.layoutParams as ViewGroup.MarginLayoutParams).apply {
|
||||
topMargin = 0
|
||||
}
|
||||
|
||||
val rankCollection = mItemDataList[position].rankCollection
|
||||
val rankCollectionAdapter = holder.bindRankCollection(rankCollection!!)
|
||||
|
||||
@ -8,17 +8,16 @@ import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.core.view.setPadding
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.common.AppExecutor
|
||||
import com.gh.common.exposure.ExposureEvent
|
||||
import com.gh.common.util.*
|
||||
import com.gh.gamecenter.GameDetailActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.adapter.viewholder.GameViewHolder
|
||||
import com.gh.gamecenter.databinding.GameItemBinding
|
||||
import com.gh.gamecenter.databinding.RankGameItemBinding
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.TagStyleEntity
|
||||
import com.gh.gamecenter.eventbus.EBDownloadStatus
|
||||
import com.gh.gamecenter.game.GameItemViewHolder
|
||||
import com.lightgame.adapter.BaseRecyclerAdapter
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import java.util.HashMap
|
||||
@ -29,7 +28,7 @@ class RankAdapter(
|
||||
private var columnName: String,
|
||||
private var exposureOffset: Int,
|
||||
private var exposureEventList: ArrayList<ExposureEvent>?,
|
||||
) : BaseRecyclerAdapter<GameItemViewHolder>(context) {
|
||||
) : BaseRecyclerAdapter<RankAdapter.RankGameItemViewHolder>(context) {
|
||||
|
||||
val positionAndPackageMap = HashMap<String, Int>()
|
||||
private var countAndKey: Pair<Int, String>? = null
|
||||
@ -55,39 +54,16 @@ class RankAdapter(
|
||||
|
||||
override fun getItemCount() = mList.size
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): GameItemViewHolder {
|
||||
return GameItemViewHolder(GameItemBinding.bind(mLayoutInflater.inflate(R.layout.game_item, parent, false)))
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RankGameItemViewHolder {
|
||||
return RankGameItemViewHolder(RankGameItemBinding.bind(mLayoutInflater.inflate(R.layout.rank_game_item, parent, false)))
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: GameItemViewHolder, position: Int) {
|
||||
override fun onBindViewHolder(holder: RankGameItemViewHolder, position: Int) {
|
||||
val gameEntity = mList[position]
|
||||
holder.binding.run {
|
||||
root.setPadding(0, 8F.dip2px(), 8F.dip2px(), 8F.dip2px())
|
||||
root.background = null
|
||||
labelList.visibility = View.GONE
|
||||
game = gameEntity
|
||||
holder.initServerType(gameEntity)
|
||||
executePendingBindings()
|
||||
|
||||
val isNeedAddView: Boolean
|
||||
val tagContainer: LinearLayout
|
||||
contentContainer.run {
|
||||
if (childCount > 0 && getChildAt(childCount - 1).tag == "tagContainer") {
|
||||
isNeedAddView = false
|
||||
tagContainer = getChildAt(childCount - 1) as LinearLayout
|
||||
} else {
|
||||
isNeedAddView = true
|
||||
tagContainer = LinearLayout(mContext).apply {
|
||||
tag = "tagContainer"
|
||||
orientation = LinearLayout.HORIZONTAL
|
||||
layoutParams = LinearLayout.LayoutParams(
|
||||
92F.dip2px(),
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
).apply { topMargin = 8F.dip2px() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImageUtils.display(gameIcon, gameEntity.icon)
|
||||
ImageUtils.display(gameIconDecoratorIv, gameEntity.iconSubscript)
|
||||
gameName.text = gameEntity.name
|
||||
tagContainer.run {
|
||||
for (i in 0 until childCount) {
|
||||
getChildAt(i).visibility = View.GONE
|
||||
@ -108,23 +84,6 @@ class RankAdapter(
|
||||
}
|
||||
}
|
||||
|
||||
if (isNeedAddView) contentContainer.addView(tagContainer)
|
||||
|
||||
gameIconView.layoutParams = gameIconView.layoutParams.apply {
|
||||
width = 40F.dip2px()
|
||||
height = 40F.dip2px()
|
||||
}
|
||||
|
||||
gameName.textSize = 13F
|
||||
gameDescContainer.visibility = View.GONE
|
||||
labelList.layoutParams = (labelList.layoutParams as ViewGroup.MarginLayoutParams).apply {
|
||||
topMargin = 10F.dip2px()
|
||||
}
|
||||
downloadBtn.layoutParams = downloadBtn.layoutParams.apply {
|
||||
width = 52F.dip2px()
|
||||
height = 26F.dip2px()
|
||||
}
|
||||
|
||||
gameOrder.run {
|
||||
visibility = View.VISIBLE
|
||||
text = (position + 1).toString()
|
||||
@ -138,7 +97,7 @@ class RankAdapter(
|
||||
layoutParams?.let {
|
||||
it.height = 16F.dip2px()
|
||||
it.width = 16F.dip2px()
|
||||
if (it is LinearLayout.LayoutParams) {
|
||||
if (it is ViewGroup.MarginLayoutParams) {
|
||||
it.leftMargin = 8F.dip2px()
|
||||
it.rightMargin = 8F.dip2px()
|
||||
}
|
||||
@ -152,7 +111,7 @@ class RankAdapter(
|
||||
layoutParams?.let {
|
||||
it.height = 16F.dip2px()
|
||||
it.width = 16F.dip2px()
|
||||
if (it is LinearLayout.LayoutParams) {
|
||||
if (it is ViewGroup.MarginLayoutParams) {
|
||||
it.leftMargin = 8F.dip2px()
|
||||
it.rightMargin = 8F.dip2px()
|
||||
}
|
||||
@ -166,7 +125,7 @@ class RankAdapter(
|
||||
layoutParams?.let {
|
||||
it.height = 16F.dip2px()
|
||||
it.width = 16F.dip2px()
|
||||
if (it is LinearLayout.LayoutParams) {
|
||||
if (it is ViewGroup.MarginLayoutParams) {
|
||||
it.leftMargin = 8F.dip2px()
|
||||
it.rightMargin = 8F.dip2px()
|
||||
}
|
||||
@ -179,7 +138,7 @@ class RankAdapter(
|
||||
layoutParams?.let {
|
||||
it.height = 24F.dip2px()
|
||||
it.width = 24F.dip2px()
|
||||
if (it is LinearLayout.LayoutParams) {
|
||||
if (it is ViewGroup.MarginLayoutParams) {
|
||||
it.leftMargin = 4F.dip2px()
|
||||
it.rightMargin = 4F.dip2px()
|
||||
} else throwExceptionInDebug()
|
||||
@ -217,7 +176,7 @@ class RankAdapter(
|
||||
"专题合集-排行榜-$columnName:${gameEntity.name}",
|
||||
exposureEvent)
|
||||
|
||||
DownloadItemUtils.updateItem(mContext, gameEntity, GameViewHolder(holder.binding), true)
|
||||
DownloadItemUtils.updateDownloadButton(mContext, downloadBtn, gameEntity, false)
|
||||
}
|
||||
}
|
||||
|
||||
@ -284,4 +243,6 @@ class RankAdapter(
|
||||
// 重新刷新数据标识
|
||||
countAndKey = Pair(update.size, dataIds)
|
||||
}
|
||||
|
||||
inner class RankGameItemViewHolder(val binding: RankGameItemBinding): RecyclerView.ViewHolder(binding.root)
|
||||
}
|
||||
@ -117,7 +117,9 @@ class RankCollectionAdapter(
|
||||
if (updateId != id) {
|
||||
notifyDataSetChanged()
|
||||
} else {
|
||||
notifyItemRangeChanged(0, itemCount)
|
||||
mSubAdapters.forEach { _, adapter ->
|
||||
adapter.notifyItemRangeChanged(0, itemCount)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -34,9 +34,6 @@ class GameAdapter(context: Context) : ListAdapter<GameEntity>(context) {
|
||||
layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT
|
||||
holder.binding.gameName.layoutParams = layoutParams
|
||||
|
||||
val containerLayoutParams = holder.binding.gameNameContainer.layoutParams
|
||||
containerLayoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT
|
||||
holder.binding.gameNameContainer.layoutParams = containerLayoutParams
|
||||
holder.itemView.setOnClickListener {
|
||||
if (mContext is Activity) {
|
||||
val intent = Intent()
|
||||
|
||||
@ -110,7 +110,7 @@ class SubjectAdapter(context: Context,
|
||||
holder.binding.gameOrder.layoutParams?.let {
|
||||
it.height = 24F.dip2px()
|
||||
it.width = 24F.dip2px()
|
||||
if (it is LinearLayout.LayoutParams) {
|
||||
if (it is ViewGroup.MarginLayoutParams) {
|
||||
it.leftMargin = 4F.dip2px()
|
||||
it.rightMargin = 4F.dip2px()
|
||||
} else throwExceptionInDebug()
|
||||
@ -125,7 +125,7 @@ class SubjectAdapter(context: Context,
|
||||
holder.binding.gameOrder.layoutParams?.let {
|
||||
it.height = 16F.dip2px()
|
||||
it.width = 16F.dip2px()
|
||||
if (it is LinearLayout.LayoutParams) {
|
||||
if (it is ViewGroup.MarginLayoutParams) {
|
||||
it.leftMargin = 8F.dip2px()
|
||||
it.rightMargin = 8F.dip2px()
|
||||
}
|
||||
@ -143,7 +143,7 @@ class SubjectAdapter(context: Context,
|
||||
holder.binding.gameOrder.layoutParams?.let {
|
||||
it.height = 16F.dip2px()
|
||||
it.width = 16F.dip2px()
|
||||
if (it is LinearLayout.LayoutParams) {
|
||||
if (it is ViewGroup.MarginLayoutParams) {
|
||||
it.leftMargin = 8F.dip2px()
|
||||
it.rightMargin = 8F.dip2px()
|
||||
}
|
||||
@ -161,7 +161,7 @@ class SubjectAdapter(context: Context,
|
||||
holder.binding.gameOrder.layoutParams?.let {
|
||||
it.height = 16F.dip2px()
|
||||
it.width = 16F.dip2px()
|
||||
if (it is LinearLayout.LayoutParams) {
|
||||
if (it is ViewGroup.MarginLayoutParams) {
|
||||
it.leftMargin = 8F.dip2px()
|
||||
it.rightMargin = 8F.dip2px()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user