하트 애니메이션 재생 순서 유지
This commit is contained in:
@@ -1906,6 +1906,9 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
||||
}
|
||||
}
|
||||
|
||||
private val bigHeartAnimationQueue = mutableListOf<Boolean>()
|
||||
private var isBigHeartAnimating = false
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
private fun initLikeHeartButton() {
|
||||
if (!isHost) {
|
||||
@@ -2361,6 +2364,12 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
||||
}
|
||||
|
||||
private fun addBigHeartAnimation(fromMessage: Boolean = false) {
|
||||
if (isBigHeartAnimating) {
|
||||
bigHeartAnimationQueue.add(fromMessage)
|
||||
return
|
||||
}
|
||||
|
||||
isBigHeartAnimating = true
|
||||
val heart = binding.heartWave
|
||||
|
||||
// 하트 물결 색상 적용 (#ff959a)
|
||||
@@ -2463,7 +2472,13 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
||||
|
||||
// 모든 폭발이 끝난 뒤 하트 비/우박 애니메이션 시작
|
||||
handler.postDelayed({
|
||||
val rainView = HeartRainView(this)
|
||||
val rainView = HeartRainView(this) {
|
||||
isBigHeartAnimating = false
|
||||
if (bigHeartAnimationQueue.isNotEmpty()) {
|
||||
val fromMessage = bigHeartAnimationQueue.removeAt(0)
|
||||
addBigHeartAnimation(fromMessage)
|
||||
}
|
||||
}
|
||||
root.addView(rainView, lp)
|
||||
rainView.start()
|
||||
}, totalDuration)
|
||||
@@ -2629,7 +2644,16 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
||||
|
||||
// 모든 폭발이 끝난 뒤 하트 비/우박 애니메이션 시작
|
||||
parentFL.postDelayed({
|
||||
val rainView = HeartRainView(context)
|
||||
val rainView = HeartRainView(context) {
|
||||
val activity = context as? LiveRoomActivity
|
||||
activity?.let {
|
||||
it.isBigHeartAnimating = false
|
||||
if (it.bigHeartAnimationQueue.isNotEmpty()) {
|
||||
val fromMessage = it.bigHeartAnimationQueue.removeAt(0)
|
||||
it.addBigHeartAnimation(fromMessage)
|
||||
}
|
||||
}
|
||||
}
|
||||
parentFL.addView(rainView, lp)
|
||||
rainView.start()
|
||||
}, totalDuration)
|
||||
@@ -2778,7 +2802,8 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
||||
}
|
||||
|
||||
private class HeartRainView(
|
||||
context: Context
|
||||
context: Context,
|
||||
private val onAnimationEnd: (() -> Unit)? = null
|
||||
) : View(context) {
|
||||
|
||||
private data class Drop(
|
||||
@@ -2914,6 +2939,7 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
||||
val finished = allLanded || (now - startTimeMs) >= maxDurationMs
|
||||
if (finished) {
|
||||
(parent as? FrameLayout)?.removeView(this)
|
||||
onAnimationEnd?.invoke()
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user