feat: 메인 라이브
- 라이브 예약 중 UI 변경
This commit is contained in:
@@ -9,6 +9,7 @@ data class GetRoomListResponse(
|
||||
@SerializedName("title") val title: String,
|
||||
@SerializedName("content") val content: String,
|
||||
@SerializedName("beginDateTime") val beginDateTime: String,
|
||||
@SerializedName("beginDateTimeUtc") val beginDateTimeUtc: String,
|
||||
@SerializedName("numberOfParticipate") val numberOfParticipate: Int,
|
||||
@SerializedName("numberOfPeople") val numberOfPeople: Int,
|
||||
@SerializedName("coverImageUrl") val coverImageUrl: String,
|
||||
|
||||
@@ -489,23 +489,23 @@ class LiveFragment : BaseFragment<FragmentLiveBinding>(FragmentLiveBinding::infl
|
||||
) {
|
||||
super.getItemOffsets(outRect, view, parent, state)
|
||||
|
||||
outRect.left = 13.3f.dpToPx().toInt()
|
||||
outRect.right = 13.3f.dpToPx().toInt()
|
||||
outRect.left = 0
|
||||
outRect.right = 0
|
||||
|
||||
when (parent.getChildAdapterPosition(view)) {
|
||||
0 -> {
|
||||
outRect.top = 0f.dpToPx().toInt()
|
||||
outRect.bottom = 6.7f.dpToPx().toInt()
|
||||
outRect.bottom = 8.dpToPx().toInt()
|
||||
}
|
||||
|
||||
liveReservationAdapter.itemCount - 1 -> {
|
||||
outRect.top = 6.7f.dpToPx().toInt()
|
||||
outRect.bottom = 13.3f.dpToPx().toInt()
|
||||
outRect.top = 8.dpToPx().toInt()
|
||||
outRect.bottom = 0.dpToPx().toInt()
|
||||
}
|
||||
|
||||
else -> {
|
||||
outRect.top = 6.7f.dpToPx().toInt()
|
||||
outRect.bottom = 6.7f.dpToPx().toInt()
|
||||
outRect.top = 8.dpToPx().toInt()
|
||||
outRect.bottom = 8.dpToPx().toInt()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -549,6 +549,21 @@ class LiveFragment : BaseFragment<FragmentLiveBinding>(FragmentLiveBinding::infl
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
private fun setupCommunityPost() {
|
||||
creatorCommunityAdapter = CreatorCommunityAdapter {
|
||||
if (SharedPreferenceManager.token.isNotBlank()) {
|
||||
startActivity(
|
||||
Intent(
|
||||
requireActivity(),
|
||||
CreatorCommunityAllActivity::class.java
|
||||
).apply {
|
||||
putExtra(Constants.EXTRA_COMMUNITY_CREATOR_ID, it)
|
||||
}
|
||||
)
|
||||
} else {
|
||||
(requireActivity() as MainActivity).showLoginActivity()
|
||||
}
|
||||
}
|
||||
|
||||
val recyclerView = binding.rvCommunityPost
|
||||
|
||||
recyclerView.layoutManager = LinearLayoutManager(
|
||||
@@ -568,37 +583,23 @@ class LiveFragment : BaseFragment<FragmentLiveBinding>(FragmentLiveBinding::infl
|
||||
|
||||
when (parent.getChildAdapterPosition(view)) {
|
||||
0 -> {
|
||||
outRect.left = 13.3f.dpToPx().toInt()
|
||||
outRect.right = 5.dpToPx().toInt()
|
||||
outRect.left = 0
|
||||
outRect.right = 8.dpToPx().toInt()
|
||||
}
|
||||
|
||||
liveNowAdapter.itemCount - 1 -> {
|
||||
outRect.left = 6.7f.dpToPx().toInt()
|
||||
outRect.right = 13.3f.dpToPx().toInt()
|
||||
creatorCommunityAdapter.itemCount - 1 -> {
|
||||
outRect.left = 8.dpToPx().toInt()
|
||||
outRect.right = 0
|
||||
}
|
||||
|
||||
else -> {
|
||||
outRect.left = 6.7f.dpToPx().toInt()
|
||||
outRect.right = 6.7f.dpToPx().toInt()
|
||||
outRect.left = 8.dpToPx().toInt()
|
||||
outRect.right = 8.dpToPx().toInt()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
creatorCommunityAdapter = CreatorCommunityAdapter {
|
||||
if (SharedPreferenceManager.token.isNotBlank()) {
|
||||
startActivity(
|
||||
Intent(
|
||||
requireActivity(),
|
||||
CreatorCommunityAllActivity::class.java
|
||||
).apply {
|
||||
putExtra(Constants.EXTRA_COMMUNITY_CREATOR_ID, it)
|
||||
}
|
||||
)
|
||||
} else {
|
||||
(requireActivity() as MainActivity).showLoginActivity()
|
||||
}
|
||||
}
|
||||
recyclerView.adapter = creatorCommunityAdapter
|
||||
|
||||
viewModel.communityPostItemLiveData.observe(viewLifecycleOwner) {
|
||||
|
||||
@@ -2,8 +2,6 @@ package kr.co.vividnext.sodalive.live.reservation
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@@ -11,14 +9,15 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.resource.bitmap.CenterCrop
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
||||
import com.bumptech.glide.request.target.CustomTarget
|
||||
import com.bumptech.glide.request.transition.Transition
|
||||
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||
import kr.co.vividnext.sodalive.databinding.ItemLiveReservationBinding
|
||||
import kr.co.vividnext.sodalive.databinding.ItemMyLiveReservationBinding
|
||||
import kr.co.vividnext.sodalive.databinding.LiveBookingCardBinding
|
||||
import kr.co.vividnext.sodalive.extensions.dpToPx
|
||||
import kr.co.vividnext.sodalive.extensions.moneyFormat
|
||||
import kr.co.vividnext.sodalive.live.GetRoomListResponse
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
import java.util.TimeZone
|
||||
|
||||
class LiveReservationAdapter(
|
||||
private val isMain: Boolean = false,
|
||||
@@ -39,7 +38,7 @@ class LiveReservationAdapter(
|
||||
} else {
|
||||
ViewHolder(
|
||||
parent.context,
|
||||
ItemLiveReservationBinding.inflate(
|
||||
LiveBookingCardBinding.inflate(
|
||||
LayoutInflater.from(parent.context),
|
||||
parent,
|
||||
false
|
||||
@@ -78,54 +77,45 @@ class LiveReservationAdapter(
|
||||
|
||||
inner class ViewHolder(
|
||||
private val context: Context,
|
||||
private val binding: ItemLiveReservationBinding
|
||||
private val binding: LiveBookingCardBinding
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
fun bind(item: GetRoomListResponse) {
|
||||
val lp = binding.ivCover.layoutParams
|
||||
lp.width = 80f.dpToPx().toInt()
|
||||
lp.height = 116.7f.dpToPx().toInt()
|
||||
val dateMap = parseUtcIsoLocalDateTime(item.beginDateTimeUtc)
|
||||
|
||||
Glide
|
||||
.with(context)
|
||||
.asBitmap()
|
||||
.transform(CenterCrop(), RoundedCorners(16f.dpToPx().toInt()))
|
||||
.load(item.coverImageUrl)
|
||||
.into(object : CustomTarget<Bitmap>() {
|
||||
override fun onResourceReady(
|
||||
resource: Bitmap,
|
||||
transition: Transition<in Bitmap>?
|
||||
) {
|
||||
binding.ivCover.setImageBitmap(resource)
|
||||
binding.ivCover.layoutParams = lp
|
||||
}
|
||||
.load(item.creatorProfileImage)
|
||||
.into(binding.ivProfile)
|
||||
|
||||
override fun onLoadCleared(placeholder: Drawable?) {
|
||||
}
|
||||
})
|
||||
binding.tvDate.text = item.beginDateTime
|
||||
binding.tvNickname.text = item.creatorNickname
|
||||
binding.tvTitle.text = item.title
|
||||
binding.root.setOnClickListener { onClick(item) }
|
||||
binding.ivLock.visibility = if (item.isPrivateRoom) {
|
||||
View.VISIBLE
|
||||
} else {
|
||||
View.GONE
|
||||
}
|
||||
binding.tvDayOfWeek.text = dateMap["dayOfWeek"]
|
||||
binding.tvTime.text = dateMap["time"]
|
||||
|
||||
binding.tvMonth.text = "${dateMap["month"]}월"
|
||||
binding.tvDay.text = dateMap["day"]
|
||||
|
||||
if (item.isReservation) {
|
||||
binding.tvPrice.visibility = View.GONE
|
||||
binding.tvCan.visibility = View.GONE
|
||||
binding.tvFree.visibility = View.GONE
|
||||
binding.tvCompleteReservation.visibility = View.VISIBLE
|
||||
} else {
|
||||
binding.tvPrice.visibility = View.VISIBLE
|
||||
} else if (item.price <= 0) {
|
||||
binding.tvCan.visibility = View.GONE
|
||||
binding.tvCompleteReservation.visibility = View.GONE
|
||||
binding.tvFree.visibility = View.VISIBLE
|
||||
} else {
|
||||
binding.tvFree.visibility = View.GONE
|
||||
binding.tvCompleteReservation.visibility = View.GONE
|
||||
binding.tvCan.visibility = View.VISIBLE
|
||||
|
||||
binding.tvPrice.text = if (item.price <= 0) {
|
||||
"무료"
|
||||
} else {
|
||||
"${item.price.moneyFormat()}캔"
|
||||
}
|
||||
binding.tvCan.text = item.price.moneyFormat()
|
||||
}
|
||||
|
||||
binding.root.setOnClickListener { onClick(item) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,6 +123,7 @@ class LiveReservationAdapter(
|
||||
private val context: Context,
|
||||
private val binding: ItemMyLiveReservationBinding
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
@SuppressLint("SetTextI18n")
|
||||
fun bind(item: GetRoomListResponse, position: Int) {
|
||||
binding.tvMyLive.visibility = if (position == 0) {
|
||||
View.VISIBLE
|
||||
@@ -140,37 +131,62 @@ class LiveReservationAdapter(
|
||||
View.GONE
|
||||
}
|
||||
|
||||
val lp = binding.ivCover.layoutParams
|
||||
lp.width = 80f.dpToPx().toInt()
|
||||
lp.height = 116.7f.dpToPx().toInt()
|
||||
val dateMap = parseUtcIsoLocalDateTime(item.beginDateTimeUtc)
|
||||
|
||||
Glide
|
||||
.with(context)
|
||||
.asBitmap()
|
||||
.load(item.coverImageUrl)
|
||||
.transform(CenterCrop(), RoundedCorners(16f.dpToPx().toInt()))
|
||||
.into(object : CustomTarget<Bitmap>() {
|
||||
override fun onResourceReady(
|
||||
resource: Bitmap,
|
||||
transition: Transition<in Bitmap>?
|
||||
) {
|
||||
binding.ivCover.setImageBitmap(resource)
|
||||
binding.ivCover.layoutParams = lp
|
||||
}
|
||||
.load(item.creatorProfileImage)
|
||||
.into(binding.ivProfile)
|
||||
|
||||
override fun onLoadCleared(placeholder: Drawable?) {
|
||||
}
|
||||
})
|
||||
binding.tvDate.text = item.beginDateTime
|
||||
binding.tvNickname.text = item.creatorNickname
|
||||
binding.tvTitle.text = item.title
|
||||
binding.root.setOnClickListener { onClick(item) }
|
||||
binding.tvDayOfWeek.text = dateMap["dayOfWeek"]
|
||||
binding.tvTime.text = dateMap["time"]
|
||||
|
||||
binding.ivLock.visibility = if (item.isPrivateRoom) {
|
||||
View.VISIBLE
|
||||
binding.tvMonth.text = "${dateMap["month"]}월"
|
||||
binding.tvDay.text = dateMap["day"]
|
||||
|
||||
if (item.price <= 0) {
|
||||
binding.tvCan.visibility = View.GONE
|
||||
binding.tvFree.visibility = View.VISIBLE
|
||||
} else {
|
||||
View.GONE
|
||||
binding.tvFree.visibility = View.GONE
|
||||
binding.tvCan.visibility = View.VISIBLE
|
||||
|
||||
binding.tvCan.text = item.price.moneyFormat()
|
||||
}
|
||||
|
||||
binding.root.setOnClickListener { onClick(item) }
|
||||
}
|
||||
}
|
||||
|
||||
private fun parseUtcIsoLocalDateTime(utcString: String): Map<String, String> {
|
||||
// 1. 서버가 내려준 포맷: "yyyy-MM-dd'T'HH:mm:ss"
|
||||
val utcFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.getDefault())
|
||||
utcFormat.timeZone = TimeZone.getTimeZone("UTC") // 서버가 UTC 기준으로 보낸 것
|
||||
|
||||
// 2. Date 객체 생성
|
||||
val date = utcFormat.parse(utcString)!!
|
||||
|
||||
// 3. 월 (1~12)
|
||||
val month = SimpleDateFormat("M", Locale.getDefault()).format(date)
|
||||
|
||||
// 4. 일 (1~31)
|
||||
val day = SimpleDateFormat("d", Locale.getDefault()).format(date)
|
||||
|
||||
// 5. 요일 (예: "Mon", "목")
|
||||
val dayOfWeek = SimpleDateFormat("E", Locale.getDefault()).format(date)
|
||||
|
||||
// 6. 시간 (예: "AM 05:00")
|
||||
val time = SimpleDateFormat("a hh:mm", Locale.getDefault()).format(date)
|
||||
|
||||
return mapOf(
|
||||
"month" to month,
|
||||
"day" to day,
|
||||
"dayOfWeek" to dayOfWeek,
|
||||
"time" to time
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user