parent
c7409e4dec
commit
6c9ace146d
|
@ -1,5 +1,6 @@
|
|||
package kr.co.vividnext.sodalive.live.room
|
||||
|
||||
import android.animation.ObjectAnimator
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.AlertDialog
|
||||
import android.app.Service
|
||||
|
@ -21,8 +22,11 @@ import android.text.method.LinkMovementMethod
|
|||
import android.text.style.ClickableSpan
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.animation.AccelerateDecelerateInterpolator
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
|
@ -90,6 +94,7 @@ import kr.co.vividnext.sodalive.report.UserReportDialog
|
|||
import kr.co.vividnext.sodalive.settings.notification.MemberRole
|
||||
import org.koin.android.ext.android.inject
|
||||
import java.util.regex.Pattern
|
||||
import kotlin.random.Random
|
||||
|
||||
class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomBinding::inflate) {
|
||||
|
||||
|
@ -257,17 +262,6 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
|||
viewModel.getMemberCan()
|
||||
viewModel.getRoomInfo(roomId)
|
||||
viewModel.getBlockedMemberIdList()
|
||||
|
||||
binding.etChat.setOnFocusChangeListener { view, hasFocus ->
|
||||
if (isNoChatting && hasFocus) {
|
||||
Toast.makeText(
|
||||
applicationContext,
|
||||
"${remainingNoChattingTime}초 동안 채팅하실 수 없습니다",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
view.clearFocus()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
|
@ -449,6 +443,16 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
|||
}
|
||||
)
|
||||
|
||||
binding.etChat.setOnFocusChangeListener { view, hasFocus ->
|
||||
if (isNoChatting && hasFocus) {
|
||||
Toast.makeText(
|
||||
applicationContext,
|
||||
"${remainingNoChattingTime}초 동안 채팅하실 수 없습니다",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
view.clearFocus()
|
||||
}
|
||||
}
|
||||
binding.tvQuit.setOnClickListener { onClickQuit() }
|
||||
binding.flMicrophoneMute.setOnClickListener {
|
||||
microphoneMute()
|
||||
|
@ -522,6 +526,102 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
|||
super.onDestroy()
|
||||
}
|
||||
|
||||
private fun secondToMillis(second: Float): Long {
|
||||
return (second * 1000).toLong()
|
||||
}
|
||||
|
||||
private fun addHeartAnimation(button: View) {
|
||||
// 버튼의 위치
|
||||
val buttonPosition = IntArray(2)
|
||||
button.getLocationInWindow(buttonPosition)
|
||||
|
||||
// 하트 이미지뷰 생성
|
||||
val heart = ImageView(this).apply {
|
||||
setImageResource(R.drawable.ic_heart_pink) // 투명한 하트 이미지
|
||||
layoutParams = FrameLayout.LayoutParams(
|
||||
33.3f.dpToPx().toInt(),
|
||||
33.3f.dpToPx().toInt()
|
||||
) // 하트 크기 설정
|
||||
}
|
||||
|
||||
// 하트의 초기 위치를 버튼의 위치로 설정
|
||||
heart.x = (buttonPosition[0] + button.width / 2f - 50) // X축 (가운데 정렬)
|
||||
heart.y = (buttonPosition[1] - 100).toFloat() // Y축 (버튼 바로 위에 생성)
|
||||
|
||||
binding.flRoot.addView(heart)
|
||||
|
||||
// 하트가 위로 올라가는 애니메이션
|
||||
val animateDuration = secondToMillis(2.5f)
|
||||
val moveUpAnimator = ObjectAnimator.ofFloat(
|
||||
heart,
|
||||
"translationY",
|
||||
heart.y,
|
||||
heart.y - (screenHeight * 1000 / 2337)
|
||||
).apply {
|
||||
duration = animateDuration
|
||||
interpolator = AccelerateDecelerateInterpolator()
|
||||
}
|
||||
|
||||
val isNegativeFirst = Random.nextBoolean()
|
||||
|
||||
// 좌우 이동 범위를 랜덤으로 설정
|
||||
val x = 13.3f
|
||||
val startX = if (isNegativeFirst) (0 - x).dpToPx() else x.dpToPx()
|
||||
val endX = if (isNegativeFirst) x.dpToPx() else (0 - x).dpToPx()
|
||||
|
||||
val moveAnimator = ObjectAnimator.ofFloat(
|
||||
heart,
|
||||
"translationX",
|
||||
heart.x + startX,
|
||||
heart.x + endX
|
||||
).apply {
|
||||
duration = secondToMillis(1.5f)
|
||||
repeatCount = ObjectAnimator.INFINITE
|
||||
repeatMode = ObjectAnimator.REVERSE
|
||||
interpolator = AccelerateDecelerateInterpolator()
|
||||
}
|
||||
|
||||
val scaleXAnimator = ObjectAnimator.ofFloat(
|
||||
heart,
|
||||
"scaleX",
|
||||
0.5f,
|
||||
1.0f
|
||||
).apply {
|
||||
duration = animateDuration
|
||||
}
|
||||
|
||||
val scaleYAnimator = ObjectAnimator.ofFloat(
|
||||
heart,
|
||||
"scaleY",
|
||||
0.5f,
|
||||
1.0f
|
||||
).apply {
|
||||
duration = animateDuration
|
||||
}
|
||||
|
||||
// 하트 투명도 애니메이션
|
||||
val fadeOutAnimator = ObjectAnimator.ofFloat(
|
||||
heart,
|
||||
"alpha",
|
||||
1f,
|
||||
0f
|
||||
).apply {
|
||||
duration = animateDuration
|
||||
}
|
||||
|
||||
// 애니메이션 실행
|
||||
moveUpAnimator.start()
|
||||
moveAnimator.start()
|
||||
fadeOutAnimator.start()
|
||||
scaleXAnimator.start()
|
||||
scaleYAnimator.start()
|
||||
|
||||
// 애니메이션이 끝나면 하트 제거
|
||||
handler.postDelayed({
|
||||
binding.flRoot.removeView(heart)
|
||||
}, animateDuration)
|
||||
}
|
||||
|
||||
private fun showOptionMenu(
|
||||
context: Context,
|
||||
userId: Long,
|
||||
|
@ -997,7 +1097,7 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
|||
private fun initLikeHeartButton(isHost: Boolean) {
|
||||
if (!isHost) {
|
||||
binding.flLikeHeart.visibility = View.VISIBLE
|
||||
binding.flLikeHeart.setOnClickListener { }
|
||||
binding.flLikeHeart.setOnClickListener { addHeartAnimation(it) }
|
||||
} else {
|
||||
binding.flLikeHeart.visibility = View.GONE
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue