|
@@ -25,27 +25,27 @@ import com.swago.room.databinding.ViewItemGiftBinding
|
|
|
class GiftDanDaoView : FrameLayout {
|
|
|
|
|
|
var isBusy = false
|
|
|
- private var binding : ViewItemGiftBinding? = null
|
|
|
+ private var binding: ViewItemGiftBinding? = null
|
|
|
|
|
|
|
|
|
- var imCurrentGiftModel:IMGiftModel? = null
|
|
|
+ var imCurrentGiftModel: IMGiftModel? = null
|
|
|
|
|
|
- constructor(context: Context) : super(context){
|
|
|
+ constructor(context: Context) : super(context) {
|
|
|
initView(context)
|
|
|
}
|
|
|
|
|
|
- constructor(context: Context, mAttributeSet: AttributeSet?) : super(context, mAttributeSet){
|
|
|
+ constructor(context: Context, mAttributeSet: AttributeSet?) : super(context, mAttributeSet) {
|
|
|
initView(context)
|
|
|
}
|
|
|
|
|
|
- private var vibrator:Vibrator? = null
|
|
|
+ private var vibrator: Vibrator? = null
|
|
|
|
|
|
private fun initView(context: Context) {
|
|
|
vibrator = context.getSystemService(Service.VIBRATOR_SERVICE) as Vibrator
|
|
|
binding = ViewItemGiftBinding.inflate(LayoutInflater.from(context), this, true)
|
|
|
}
|
|
|
|
|
|
- fun addData(imGiftModel: IMGiftModel){
|
|
|
+ fun addData(imGiftModel: IMGiftModel) {
|
|
|
isBusy = true
|
|
|
binding?.apply {
|
|
|
Glide.with(ivAvatar.context)
|
|
@@ -60,12 +60,20 @@ class GiftDanDaoView : FrameLayout {
|
|
|
.into(ivGiftIcon)
|
|
|
|
|
|
tvSenderName.text = imGiftModel.senderName
|
|
|
- tvSenderTo.text = AppContext.getContext().resources.getString(R.string.send_to).format(imGiftModel.receiverName)
|
|
|
+ if (!tvSenderName.isSelected) {
|
|
|
+ tvSenderName.isSelected = true
|
|
|
+ }
|
|
|
+
|
|
|
+ tvSenderTo.text = AppContext.getContext().resources.getString(R.string.send_to)
|
|
|
+ .format(imGiftModel.receiverName)
|
|
|
+ if (!tvSenderTo.isSelected) {
|
|
|
+ tvSenderTo.isSelected = true
|
|
|
+ }
|
|
|
tvNum.text = "x${imGiftModel.giftNum}"
|
|
|
clItemGift.visibility = View.VISIBLE
|
|
|
- if (imCurrentGiftModel!=null&&imGiftModel.isCombo==1){
|
|
|
+ if (imCurrentGiftModel != null && imGiftModel.isCombo == 1) {
|
|
|
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
//执行进场动画
|
|
|
giftEnterAnimator.start()
|
|
|
}
|
|
@@ -73,9 +81,9 @@ class GiftDanDaoView : FrameLayout {
|
|
|
|
|
|
clItemGift.removeCallbacks(showRunnable)
|
|
|
clItemGift.postDelayed(showRunnable, 3000)
|
|
|
-
|
|
|
- if (imGiftModel.multiple!=0){
|
|
|
- when(imGiftModel.multiple){
|
|
|
+
|
|
|
+ if (imGiftModel.multiple != 0) {
|
|
|
+ when (imGiftModel.multiple) {
|
|
|
in 1..100 -> {
|
|
|
iv.setImageResource(R.mipmap.win_100_prize)
|
|
|
}
|
|
@@ -91,7 +99,9 @@ class GiftDanDaoView : FrameLayout {
|
|
|
}
|
|
|
}
|
|
|
clWinPrize.visibility = View.VISIBLE
|
|
|
- tvWinPrize.text = AppContext.getContext().resources.getString(R.string.win_num_prize).format(imGiftModel.multiple)
|
|
|
+ tvWinPrize.text =
|
|
|
+ AppContext.getContext().resources.getString(R.string.win_num_prize)
|
|
|
+ .format(imGiftModel.multiple)
|
|
|
clWinPrize.removeCallbacks(winPrizeRunnable)
|
|
|
clWinPrize.postDelayed(winPrizeRunnable, 1500)
|
|
|
}
|
|
@@ -102,7 +112,12 @@ class GiftDanDaoView : FrameLayout {
|
|
|
|
|
|
|
|
|
private val giftEnterAnimator by lazy {
|
|
|
- val tx = ObjectAnimator.ofFloat(binding!!.clItemGift, "translationX", -binding!!.clItemGift.width.toFloat(), 0f)
|
|
|
+ val tx = ObjectAnimator.ofFloat(
|
|
|
+ binding!!.clItemGift,
|
|
|
+ "translationX",
|
|
|
+ -binding!!.clItemGift.width.toFloat(),
|
|
|
+ 0f
|
|
|
+ )
|
|
|
val ap = ObjectAnimator.ofFloat(binding!!.clItemGift, "alpha", 0.5f, 1f)
|
|
|
tx.interpolator = DecelerateInterpolator()
|
|
|
tx.duration = 400
|
|
@@ -127,7 +142,7 @@ class GiftDanDaoView : FrameLayout {
|
|
|
Runnable {
|
|
|
vibrator?.cancel()
|
|
|
binding!!.clWinPrize.visibility = View.INVISIBLE
|
|
|
- binding!!.tvWinPrize.text=""
|
|
|
+ binding!!.tvWinPrize.text = ""
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -135,7 +150,7 @@ class GiftDanDaoView : FrameLayout {
|
|
|
fun clear() {
|
|
|
vibrator?.cancel()
|
|
|
isBusy = false
|
|
|
- imCurrentGiftModel=null
|
|
|
+ imCurrentGiftModel = null
|
|
|
binding?.apply {
|
|
|
clWinPrize.visibility = View.INVISIBLE
|
|
|
clItemGift.visibility = View.INVISIBLE
|