package com.gh.gamecenter.home.test_v2

import android.view.View
import com.ethanhua.skeleton.Skeleton
import com.ethanhua.skeleton.ViewSkeletonScreen
import com.gh.gamecenter.R
import com.gh.gamecenter.common.base.BaseRecyclerViewHolder
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.databinding.ItemHomeGameTestV2PlaceHolderBinding

/**
 * @author : liujiarui
 * date : 2023/3/6
 * description : 新游开测，游戏列表 item space holder
 */
class HomeGameTestV2GameListPlaceHolderViewHolder(
    private val mBinding: ItemHomeGameTestV2PlaceHolderBinding
) : BaseRecyclerViewHolder<Any>(mBinding.root) {

    private var mSkeletonView: ViewSkeletonScreen? = null
    fun bind() {
        showSkeletonView(mBinding.llContainer)
    }

    private fun showSkeletonView(view: View) {
        if (mSkeletonView != null) {
            mSkeletonView?.hide()
            mSkeletonView = null
        }
        mSkeletonView = Skeleton.bind(view)
            .shimmer(true)
            .angle(Constants.SHIMMER_ANGLE)
            .color(com.gh.gamecenter.common.R.color.ui_skeleton_highlight)
            .duration(Constants.SHIMMER_DURATION)
            .maskWidth(Constants.MASK_WIDTH)
            .gradientCenterColorWidth(Constants.GRADIENT_CENTER_COLOR_WIDTH)
            .apply {
                load(R.layout.item_skeleton_home_game_test_v2_place_holder)
            }
            .show()
    }
}