package com.gamedog.vididin.widget import android.animation.Animator import android.animation.AnimatorSet import android.animation.ObjectAnimator import android.content.Context import android.util.AttributeSet import android.view.LayoutInflater import android.widget.LinearLayout import androidx.core.view.isVisible import com.gamedog.vididin.databinding.LayoutDragIconViewBinding class HomeDragIconView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 ) : LinearLayout(context, attrs, defStyleAttr) { private var mBinding: LayoutDragIconViewBinding init { mBinding = LayoutDragIconViewBinding.inflate(LayoutInflater.from(context), this, true) mBinding.run { } } fun showRewardGoldAnim() { val animView = mBinding.llGoldRoot val alphaAnimator = ObjectAnimator.ofFloat( animView, "alpha", 0.5f, 1.0f ).apply { duration = 1500 } val scaleXAnimator = ObjectAnimator.ofFloat( animView, "scaleX", 0.5f, 1.1f, 1F ).apply { duration = 1500 } val scaleYAnimator = ObjectAnimator.ofFloat( animView, "scaleY", 0.5f, 1.1f, 1F ).apply { duration = 1500 } val animatorSet = AnimatorSet() animatorSet.playTogether(alphaAnimator, scaleXAnimator, scaleYAnimator) animatorSet.addListener(object : Animator.AnimatorListener { override fun onAnimationCancel(animation: Animator) { postDelayed({ animView.visibility = INVISIBLE }, 1000) } override fun onAnimationEnd(animation: Animator) { postDelayed({ animView.visibility = INVISIBLE }, 1000) } override fun onAnimationRepeat(animation: Animator) { } override fun onAnimationStart(animation: Animator) { animView.isVisible = true } }) animatorSet.start() } fun setProgress(progress: Long) { mBinding.progressBar.setProgress(progress.toInt()) } }