feat(chat): 톡 목록 스키마 반영 및 채팅방 진입 연결
- TalkRoom 필드 변경 및 신규 스키마 적용 - 어댑터 바인딩/DiffUtil 수정, 프로필 이미지 28dp 라운드 처리 - 아이템 클릭 시 ChatRoomActivity로 이동(roomId 전달) - item_talk 배경 제거, 최근 캐릭터 썸네일 모서리 28dp로 통일
This commit is contained in:
@@ -27,7 +27,7 @@ class RecentCharacterAdapter(
|
|||||||
.apply(
|
.apply(
|
||||||
RequestOptions().transform(
|
RequestOptions().transform(
|
||||||
RoundedCorners(
|
RoundedCorners(
|
||||||
16f.dpToPx().toInt()
|
28f.dpToPx().toInt()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import com.google.gson.annotations.SerializedName
|
|||||||
|
|
||||||
@Keep
|
@Keep
|
||||||
data class TalkRoom(
|
data class TalkRoom(
|
||||||
@SerializedName("id") val id: Long,
|
@SerializedName("chatRoomId") val chatRoomId: Long,
|
||||||
@SerializedName("profileImageUrl") val profileImageUrl: String,
|
@SerializedName("title") val title: String,
|
||||||
@SerializedName("characterName") val characterName: String,
|
@SerializedName("imageUrl") val imageUrl: String,
|
||||||
@SerializedName("characterType") val characterType: String,
|
@SerializedName("opponentType") val opponentType: String,
|
||||||
@SerializedName("lastMessageTime") val lastMessageTime: String,
|
@SerializedName("lastMessagePreview") val lastMessagePreview: String?,
|
||||||
@SerializedName("lastMessage") val lastMessage: String
|
@SerializedName("lastMessageTimeLabel") val lastMessageTimeLabel: String
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6,7 +6,11 @@ import androidx.recyclerview.widget.DiffUtil
|
|||||||
import androidx.recyclerview.widget.ListAdapter
|
import androidx.recyclerview.widget.ListAdapter
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
|
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
||||||
|
import com.bumptech.glide.request.RequestOptions
|
||||||
|
import com.orhanobut.logger.Logger
|
||||||
import kr.co.vividnext.sodalive.databinding.ItemTalkBinding
|
import kr.co.vividnext.sodalive.databinding.ItemTalkBinding
|
||||||
|
import kr.co.vividnext.sodalive.extensions.dpToPx
|
||||||
|
|
||||||
class TalkTabAdapter(
|
class TalkTabAdapter(
|
||||||
private val onItemClick: (TalkRoom) -> Unit
|
private val onItemClick: (TalkRoom) -> Unit
|
||||||
@@ -36,19 +40,27 @@ class TalkTabAdapter(
|
|||||||
|
|
||||||
fun bind(talkRoom: TalkRoom) {
|
fun bind(talkRoom: TalkRoom) {
|
||||||
binding.apply {
|
binding.apply {
|
||||||
|
Logger.d("bind talkRoom: $talkRoom")
|
||||||
// 프로필 이미지 로드
|
// 프로필 이미지 로드
|
||||||
Glide.with(ivProfile.context)
|
Glide.with(ivProfile.context)
|
||||||
.load(talkRoom.profileImageUrl)
|
.load(talkRoom.imageUrl)
|
||||||
|
.apply(
|
||||||
|
RequestOptions().transform(
|
||||||
|
RoundedCorners(
|
||||||
|
28f.dpToPx().toInt()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
.into(ivProfile)
|
.into(ivProfile)
|
||||||
|
|
||||||
// 텍스트 설정
|
// 텍스트 설정
|
||||||
tvCharacterName.text = talkRoom.characterName
|
tvCharacterName.text = talkRoom.title
|
||||||
tvCharacterType.text = talkRoom.characterType
|
tvCharacterType.text = talkRoom.opponentType
|
||||||
tvLastTime.text = talkRoom.lastMessageTime
|
tvLastTime.text = talkRoom.lastMessageTimeLabel
|
||||||
tvLastMessage.text = talkRoom.lastMessage
|
tvLastMessage.text = talkRoom.lastMessagePreview ?: ""
|
||||||
|
|
||||||
// 캐릭터 유형에 따른 배경 설정
|
// 캐릭터 유형에 따른 배경 설정
|
||||||
val backgroundResId = when (talkRoom.characterType.lowercase()) {
|
val backgroundResId = when (talkRoom.opponentType.lowercase()) {
|
||||||
"character" -> kr.co.vividnext.sodalive.R.drawable.bg_character_type_badge_character
|
"character" -> kr.co.vividnext.sodalive.R.drawable.bg_character_type_badge_character
|
||||||
"clone" -> kr.co.vividnext.sodalive.R.drawable.bg_character_type_badge_clone
|
"clone" -> kr.co.vividnext.sodalive.R.drawable.bg_character_type_badge_clone
|
||||||
"creator" -> kr.co.vividnext.sodalive.R.drawable.bg_character_type_badge_creator
|
"creator" -> kr.co.vividnext.sodalive.R.drawable.bg_character_type_badge_creator
|
||||||
@@ -61,7 +73,7 @@ class TalkTabAdapter(
|
|||||||
|
|
||||||
private class TalkDiffCallback : DiffUtil.ItemCallback<TalkRoom>() {
|
private class TalkDiffCallback : DiffUtil.ItemCallback<TalkRoom>() {
|
||||||
override fun areItemsTheSame(oldItem: TalkRoom, newItem: TalkRoom): Boolean {
|
override fun areItemsTheSame(oldItem: TalkRoom, newItem: TalkRoom): Boolean {
|
||||||
return oldItem.id == newItem.id
|
return oldItem.chatRoomId == newItem.chatRoomId
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun areContentsTheSame(oldItem: TalkRoom, newItem: TalkRoom): Boolean {
|
override fun areContentsTheSame(oldItem: TalkRoom, newItem: TalkRoom): Boolean {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import android.view.View
|
|||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import kr.co.vividnext.sodalive.base.BaseFragment
|
import kr.co.vividnext.sodalive.base.BaseFragment
|
||||||
|
import kr.co.vividnext.sodalive.chat.talk.room.ChatRoomActivity
|
||||||
import kr.co.vividnext.sodalive.common.LoadingDialog
|
import kr.co.vividnext.sodalive.common.LoadingDialog
|
||||||
import kr.co.vividnext.sodalive.databinding.FragmentTalkTabBinding
|
import kr.co.vividnext.sodalive.databinding.FragmentTalkTabBinding
|
||||||
import org.koin.android.ext.android.inject
|
import org.koin.android.ext.android.inject
|
||||||
@@ -30,14 +31,13 @@ class TalkTabFragment : BaseFragment<FragmentTalkTabBinding>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setupRecyclerView() {
|
private fun setupRecyclerView() {
|
||||||
adapter = TalkTabAdapter { talkRoom ->
|
adapter = TalkTabAdapter {
|
||||||
// 대화방 클릭 이벤트 처리
|
startActivity(
|
||||||
// TODO: 대화방 상세 화면으로 이동
|
ChatRoomActivity.newIntent(
|
||||||
Toast.makeText(
|
context = requireContext(),
|
||||||
requireContext(),
|
roomId = it.chatRoomId
|
||||||
"대화방 ${talkRoom.characterName} 클릭됨",
|
)
|
||||||
Toast.LENGTH_SHORT
|
)
|
||||||
).show()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.rvTalk.apply {
|
binding.rvTalk.apply {
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
android:id="@+id/iv_profile"
|
android:id="@+id/iv_profile"
|
||||||
android:layout_width="76dp"
|
android:layout_width="76dp"
|
||||||
android:layout_height="76dp"
|
android:layout_height="76dp"
|
||||||
android:background="@color/color_777777"
|
|
||||||
android:contentDescription="@null"
|
android:contentDescription="@null"
|
||||||
android:scaleType="centerCrop" />
|
android:scaleType="centerCrop" />
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user