라이브방
- 하트 알림 바(채팅) 배경, 닉네임, 글자색 변경 - 하트 알림 바 위치 수정 : 채팅 -> 공지 밑
This commit is contained in:
@@ -9,6 +9,7 @@ import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Rect
|
||||
import android.graphics.Typeface
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
@@ -18,8 +19,11 @@ import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.text.Spannable
|
||||
import android.text.SpannableString
|
||||
import android.text.Spanned
|
||||
import android.text.method.LinkMovementMethod
|
||||
import android.text.style.ClickableSpan
|
||||
import android.text.style.ForegroundColorSpan
|
||||
import android.text.style.StyleSpan
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.animation.AccelerateDecelerateInterpolator
|
||||
@@ -74,7 +78,6 @@ import kr.co.vividnext.sodalive.live.room.chat.LiveRoomChatRawMessage
|
||||
import kr.co.vividnext.sodalive.live.room.chat.LiveRoomChatRawMessageType
|
||||
import kr.co.vividnext.sodalive.live.room.chat.LiveRoomDonationChat
|
||||
import kr.co.vividnext.sodalive.live.room.chat.LiveRoomDonationStatusChat
|
||||
import kr.co.vividnext.sodalive.live.room.chat.LiveRoomHeartDonationChat
|
||||
import kr.co.vividnext.sodalive.live.room.chat.LiveRoomJoinChat
|
||||
import kr.co.vividnext.sodalive.live.room.chat.LiveRoomNormalChat
|
||||
import kr.co.vividnext.sodalive.live.room.chat.LiveRoomRouletteDonationChat
|
||||
@@ -129,7 +132,7 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
||||
|
||||
private var isHost = false
|
||||
private var isNoChatting = false
|
||||
private var remainingNoChattingTime = noChattingTime
|
||||
private var remainingNoChattingTime = NO_CHATTING_TIME
|
||||
|
||||
private val signatureImageUrlList = mutableListOf<String>()
|
||||
private var signatureImageUrl = ""
|
||||
@@ -151,6 +154,23 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
||||
}
|
||||
}
|
||||
|
||||
private val heartNicknameList = mutableListOf<String>()
|
||||
private var heartNickname = ""
|
||||
set(value) {
|
||||
field = value
|
||||
|
||||
if (field.isNotBlank()) {
|
||||
showHeartMessage()
|
||||
handler.postDelayed({
|
||||
if (heartNicknameList.isNotEmpty()) {
|
||||
heartNickname = heartNicknameList.removeAt(0)
|
||||
} else {
|
||||
hideHeartMessage()
|
||||
}
|
||||
}, 1000)
|
||||
}
|
||||
}
|
||||
|
||||
private var isShowSignatureImage = false
|
||||
private var isAvailableLikeHeart = false
|
||||
private var originalButtonPosition: IntArray? = null
|
||||
@@ -162,7 +182,7 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
||||
|
||||
override fun onFinish() {
|
||||
isNoChatting = false
|
||||
remainingNoChattingTime = noChattingTime
|
||||
remainingNoChattingTime = NO_CHATTING_TIME
|
||||
removeNoChatRoom()
|
||||
Toast.makeText(
|
||||
applicationContext,
|
||||
@@ -1149,8 +1169,7 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
||||
SharedPreferenceManager.userId.toInt()
|
||||
)
|
||||
handler.post {
|
||||
chatAdapter.items.add(LiveRoomHeartDonationChat(nickname))
|
||||
invalidateChat()
|
||||
addHeartMessage(nickname)
|
||||
addHeartAnimation()
|
||||
lifecycleScope.launch { viewModel.addHeartDonation() }
|
||||
}
|
||||
@@ -1777,8 +1796,7 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
||||
|
||||
LiveRoomChatRawMessageType.HEART_DONATION -> {
|
||||
handler.post {
|
||||
chatAdapter.items.add(LiveRoomHeartDonationChat(nickname))
|
||||
invalidateChat()
|
||||
addHeartMessage(nickname)
|
||||
addHeartAnimation()
|
||||
lifecycleScope.launch { viewModel.addHeartDonation() }
|
||||
}
|
||||
@@ -2120,6 +2138,46 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
||||
}
|
||||
}
|
||||
|
||||
private fun addHeartMessage(nickname: String) {
|
||||
if (heartNickname.isBlank()) {
|
||||
heartNickname = nickname
|
||||
} else {
|
||||
heartNicknameList.add(nickname)
|
||||
}
|
||||
}
|
||||
|
||||
private fun showHeartMessage() {
|
||||
val str = "'${heartNickname}'님이 마음을 전했습니다 : \uD83D\uDC95"
|
||||
val spStr = SpannableString(str)
|
||||
|
||||
spStr.setSpan(
|
||||
ForegroundColorSpan(
|
||||
ContextCompat.getColor(
|
||||
applicationContext,
|
||||
R.color.color_f0c030
|
||||
)
|
||||
),
|
||||
str.indexOf("'") + 1,
|
||||
str.indexOf("'님"),
|
||||
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
)
|
||||
|
||||
spStr.setSpan(
|
||||
StyleSpan(Typeface.BOLD),
|
||||
str.indexOf("'"),
|
||||
str.indexOf("'님"),
|
||||
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
)
|
||||
binding.tvHeartMessage.text = spStr
|
||||
binding.tvHeartMessage.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
private fun hideHeartMessage() {
|
||||
heartNickname = ""
|
||||
binding.tvHeartMessage.text = ""
|
||||
binding.tvHeartMessage.visibility = View.GONE
|
||||
}
|
||||
|
||||
private fun addSignatureImage(imageUrl: String) {
|
||||
if (imageUrl.isNotBlank()) {
|
||||
if (!isShowSignatureImage) {
|
||||
@@ -2228,6 +2286,6 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val noChattingTime = 180L
|
||||
private const val NO_CHATTING_TIME = 180L
|
||||
}
|
||||
}
|
||||
|
||||
@@ -403,39 +403,3 @@ data class LiveRoomRouletteDonationChat(
|
||||
itemBinding.root.setPadding(33)
|
||||
}
|
||||
}
|
||||
|
||||
@Keep
|
||||
data class LiveRoomHeartDonationChat(
|
||||
val nickname: String
|
||||
) : LiveRoomChat() {
|
||||
override var type = LiveRoomChatType.JOIN
|
||||
override fun bind(context: Context, binding: ViewBinding, onClickProfile: ((Long) -> Unit)?) {
|
||||
(binding as ItemLiveRoomJoinChatBinding).tvJoin.setTextColor(
|
||||
ContextCompat.getColor(context, R.color.color_111111)
|
||||
)
|
||||
val str = "'$nickname'님이 마음을 전했습니다 : \uD83D\uDC95"
|
||||
val spStr = SpannableString(str)
|
||||
|
||||
spStr.setSpan(
|
||||
ForegroundColorSpan(
|
||||
ContextCompat.getColor(
|
||||
context,
|
||||
R.color.color_ec3aa6
|
||||
)
|
||||
),
|
||||
str.indexOf("'") + 1,
|
||||
str.indexOf("'님"),
|
||||
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
)
|
||||
|
||||
spStr.setSpan(
|
||||
StyleSpan(Typeface.BOLD),
|
||||
str.indexOf("'"),
|
||||
str.indexOf("'님"),
|
||||
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
)
|
||||
|
||||
(binding as ItemLiveRoomJoinChatBinding).tvJoin.text = spStr
|
||||
binding.root.setBackgroundResource(R.drawable.bg_round_corner_4_7_ccffffff)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user