光环助手V4.7.0-外部应用跳转光环助手功能优化(UI测试问题) https://git.ghzs.com/pm/halo-app-issues/-/issues/1130

This commit is contained in:
张玉久
2021-01-28 16:47:38 +08:00
parent 7f60a575a4
commit 34d5e2cc29
4 changed files with 85 additions and 20 deletions

View File

@ -1,14 +1,15 @@
package com.gh.gamecenter.home.skip
import android.content.Context
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import com.gh.common.util.DownloadItemUtils
import com.gh.common.util.EmptyCallback
import com.gh.common.util.LogUtils
import com.gh.common.util.StringUtils
import com.gh.common.constant.ItemViewType
import com.gh.common.util.*
import com.gh.gamecenter.GameDetailActivity
import com.gh.gamecenter.R
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder
import com.gh.gamecenter.adapter.viewholder.GameViewHolder
import com.gh.gamecenter.databinding.GameItemBinding
import com.gh.gamecenter.entity.GameEntity
@ -18,10 +19,24 @@ import com.lightgame.adapter.BaseRecyclerAdapter
class PackageSkipAdapter(val context: Context, val games: ArrayList<GameEntity>, private val itemClickCallback: () -> Unit) : BaseRecyclerAdapter<RecyclerView.ViewHolder>(context) {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
return GameItemViewHolder(GameItemBinding.bind(mLayoutInflater.inflate(R.layout.game_item, parent, false)))
return if (viewType == ItemViewType.ITEM_BODY) {
GameItemViewHolder(GameItemBinding.bind(mLayoutInflater.inflate(R.layout.game_item, parent, false)))
} else {
FooterViewHolder(mLayoutInflater.inflate(R.layout.refresh_footerview, parent, false))
}
}
override fun getItemCount(): Int = games.size
override fun getItemViewType(position: Int): Int {
return if (position == itemCount - 1) {
ItemViewType.ITEM_FOOTER
} else {
ItemViewType.ITEM_BODY
}
}
override fun getItemCount(): Int = games.size + 1
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
if (holder is GameItemViewHolder) {
@ -31,23 +46,57 @@ class PackageSkipAdapter(val context: Context, val games: ArrayList<GameEntity>,
val subjectData = gameEntity.subjectData
holder.binding.isShowSuffix = subjectData?.isShowSuffix
holder.binding.briefStyle = subjectData?.briefStyle
holder.binding.executePendingBindings()
if (games.size == 1) {
holder.itemView.background = ContextCompat.getDrawable(context, R.drawable.background_shape_white_radius_8)
} else if (games.size == 2) {
if (position == 0) {
holder.itemView.setPadding(16f.dip2px(), 16f.dip2px(), 16f.dip2px(), 8f.dip2px())
holder.itemView.background = ContextCompat.getDrawable(context, R.drawable.background_shape_white_radius_8_top_only)
} else {
holder.itemView.setPadding(16f.dip2px(), 8f.dip2px(), 16f.dip2px(), 16f.dip2px())
holder.itemView.background = ContextCompat.getDrawable(context, R.drawable.background_shape_white_radius_8_bottom_only)
}
} else {
when (position) {
0 -> {
holder.itemView.setPadding(16f.dip2px(), 16f.dip2px(), 16f.dip2px(), 8f.dip2px())
holder.itemView.background = ContextCompat.getDrawable(context, R.drawable.background_shape_white_radius_8_top_only)
}
itemCount - 2 -> {
holder.itemView.setPadding(16f.dip2px(), 8f.dip2px(), 16f.dip2px(), 16f.dip2px())
holder.itemView.background = ContextCompat.getDrawable(context, R.drawable.background_shape_white_radius_8_bottom_only)
}
else -> {
holder.itemView.setPadding(16f.dip2px(), 8f.dip2px(), 16f.dip2px(), 8f.dip2px())
holder.itemView.background = ContextCompat.getDrawable(context, R.drawable.background_shape_white)
}
}
}
DownloadItemUtils.setOnClickListener(mContext, holder.binding.downloadBtn, gameEntity, position,
this,
StringUtils.buildString("应用跳转:", subjectData?.name, "-列表[", (position + 1).toString(), "])"),
StringUtils.buildString("应用跳转-", subjectData?.name, ":", gameEntity.name), null,
object : EmptyCallback {
override fun onCallback() {
LogUtils.uploadPackageSkip("external_show","下载游戏", gameEntity.id, gameEntity.name)
LogUtils.uploadPackageSkip("external_show", "下载游戏", gameEntity.id, gameEntity.name)
}
})
DownloadItemUtils.updateItem(mContext, gameEntity, GameViewHolder(holder.binding), !gameEntity.isPluggable, subjectData?.briefStyle)
holder.itemView.setOnClickListener {
LogUtils.uploadPackageSkip("external_show","点击游戏", gameEntity.id, gameEntity.name)
LogUtils.uploadPackageSkip("external_show", "点击游戏", gameEntity.id, gameEntity.name)
GameDetailActivity.startGameDetailActivity(context, gameEntity, "应用跳转")
itemClickCallback.invoke()
}
} else if (holder is FooterViewHolder) {
holder.initFooterViewHolder(false, false, true, R.string.ask_loadover_hint)
holder.hint.setTextColor(ContextCompat.getColor(context, R.color.text_999999))
holder.hint.textSize = 12f
holder.lineLeft.visibility = View.GONE
holder.lineRight.visibility = View.GONE
holder.itemView.setPadding(0, 14f.dip2px(), 0, 14f.dip2px())
}
}
}