라이브 리스트, 상세, 예약 - 타임존을 적용해서 내려주는 beginDateTime을 제거하고 UTC 타임존이 적용된 beginDateTimeUtc를 사용하도록 수정
This commit is contained in:
@@ -69,7 +69,6 @@ data class LiveRoomResponse(
|
||||
@SerializedName("title") val title: String,
|
||||
@SerializedName("content") val content: String,
|
||||
@SerializedName("isPaid") val isPaid: Boolean,
|
||||
@SerializedName("beginDateTime") val beginDateTime: String,
|
||||
@SerializedName("beginDateTimeUtc") val beginDateTimeUtc: String,
|
||||
@SerializedName("coverImageUrl") val coverImageUrl: String,
|
||||
@SerializedName("isAdult") val isAdult: Boolean,
|
||||
|
||||
@@ -74,6 +74,7 @@ import org.koin.android.ext.android.inject
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import java.util.TimeZone
|
||||
|
||||
class UserProfileActivity : BaseActivity<ActivityUserProfileBinding>(
|
||||
ActivityUserProfileBinding::inflate
|
||||
@@ -1093,8 +1094,9 @@ class UserProfileActivity : BaseActivity<ActivityUserProfileBinding>(
|
||||
liveViewModel.enterRoom(roomId, onEnterRoomSuccess)
|
||||
}
|
||||
} else {
|
||||
val beginDateFormat = SimpleDateFormat("yyyy.MM.dd EEE hh:mm a", Locale.ENGLISH)
|
||||
val beginDate = beginDateFormat.parse(it.beginDateTime)!!
|
||||
val beginDateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH)
|
||||
beginDateFormat.timeZone = TimeZone.getTimeZone("UTC")
|
||||
val beginDate = beginDateFormat.parse(it.beginDateTimeUtc)!!
|
||||
val now = Date()
|
||||
|
||||
val dateFormat = SimpleDateFormat("yyyy-MM-dd, HH:mm", Locale.getDefault())
|
||||
|
||||
@@ -13,10 +13,14 @@ fun String.convertDateFormat(
|
||||
from: String,
|
||||
to: String,
|
||||
inputLocale: Locale = Locale.getDefault(),
|
||||
outputLocale: Locale = Locale.getDefault()
|
||||
outputLocale: Locale = Locale.getDefault(),
|
||||
inputTimeZone: TimeZone = TimeZone.getDefault(),
|
||||
outputTimeZone: TimeZone = TimeZone.getDefault()
|
||||
): String {
|
||||
val fromDateFormat = SimpleDateFormat(from, inputLocale)
|
||||
fromDateFormat.timeZone = inputTimeZone
|
||||
val toDateFormat = SimpleDateFormat(to, outputLocale)
|
||||
toDateFormat.timeZone = outputTimeZone
|
||||
|
||||
var outputDateString = ""
|
||||
val date = fromDateFormat.parse(this)
|
||||
|
||||
@@ -65,6 +65,7 @@ import org.koin.android.ext.android.inject
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import java.util.TimeZone
|
||||
|
||||
@OptIn(UnstableApi::class)
|
||||
class HomeFragment : BaseFragment<FragmentHomeBinding>(FragmentHomeBinding::inflate) {
|
||||
@@ -1254,8 +1255,9 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(FragmentHomeBinding::infl
|
||||
}, 300)
|
||||
}
|
||||
} else {
|
||||
val beginDateFormat = SimpleDateFormat("yyyy.MM.dd EEE hh:mm a", Locale.ENGLISH)
|
||||
val beginDate = beginDateFormat.parse(it.beginDateTime)!!
|
||||
val beginDateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH)
|
||||
beginDateFormat.timeZone = TimeZone.getTimeZone("UTC")
|
||||
val beginDate = beginDateFormat.parse(it.beginDateTimeUtc)!!
|
||||
val now = Date()
|
||||
|
||||
val dateFormat = SimpleDateFormat("yyyy-MM-dd, HH:mm", Locale.getDefault())
|
||||
|
||||
@@ -8,7 +8,6 @@ data class GetRoomListResponse(
|
||||
@SerializedName("roomId") val roomId: Long,
|
||||
@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,
|
||||
|
||||
@@ -61,6 +61,7 @@ import org.koin.android.ext.android.inject
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import java.util.TimeZone
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
@UnstableApi
|
||||
@@ -902,8 +903,9 @@ class LiveFragment : BaseFragment<FragmentLiveBinding>(FragmentLiveBinding::infl
|
||||
}, 300)
|
||||
}
|
||||
} else {
|
||||
val beginDateFormat = SimpleDateFormat("yyyy.MM.dd EEE hh:mm a", Locale.ENGLISH)
|
||||
val beginDate = beginDateFormat.parse(it.beginDateTime)!!
|
||||
val beginDateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH)
|
||||
beginDateFormat.timeZone = TimeZone.getTimeZone("UTC")
|
||||
val beginDate = beginDateFormat.parse(it.beginDateTimeUtc)!!
|
||||
val now = Date()
|
||||
|
||||
val dateFormat = SimpleDateFormat("yyyy-MM-dd, HH:mm", Locale.getDefault())
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.koin.android.ext.android.inject
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import java.util.TimeZone
|
||||
|
||||
@UnstableApi
|
||||
class LiveNowAllActivity : BaseActivity<ActivityLiveNowAllBinding>(
|
||||
@@ -140,8 +141,9 @@ class LiveNowAllActivity : BaseActivity<ActivityLiveNowAllBinding>(
|
||||
viewModel.enterRoom(roomId, onEnterRoomSuccess)
|
||||
}
|
||||
} else {
|
||||
val beginDateFormat = SimpleDateFormat("yyyy.MM.dd EEE hh:mm a", Locale.ENGLISH)
|
||||
val beginDate = beginDateFormat.parse(it.beginDateTime)!!
|
||||
val beginDateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH)
|
||||
beginDateFormat.timeZone = TimeZone.getTimeZone("UTC")
|
||||
val beginDate = beginDateFormat.parse(it.beginDateTimeUtc)!!
|
||||
val now = Date()
|
||||
|
||||
val dateFormat = SimpleDateFormat("yyyy-MM-dd, HH:mm", Locale.getDefault())
|
||||
|
||||
@@ -14,6 +14,6 @@ data class GetLiveReservationResponse(
|
||||
@SerializedName("coverImageUrl") val coverImageUrl: String,
|
||||
@SerializedName("price") val price: Int,
|
||||
@SerializedName("masterNickname") val masterNickname: String,
|
||||
@SerializedName("beginDateTime") val beginDateTime: String,
|
||||
@SerializedName("beginDateTimeUtc") val beginDateTimeUtc: String,
|
||||
@SerializedName("cancelable") val cancelable: Boolean,
|
||||
) : Parcelable
|
||||
|
||||
@@ -16,10 +16,12 @@ import kr.co.vividnext.sodalive.base.BaseActivity
|
||||
import kr.co.vividnext.sodalive.common.LoadingDialog
|
||||
import kr.co.vividnext.sodalive.common.SodaLiveApplicationHolder
|
||||
import kr.co.vividnext.sodalive.databinding.ActivityLiveReservationCancelBinding
|
||||
import kr.co.vividnext.sodalive.extensions.convertDateFormat
|
||||
import kr.co.vividnext.sodalive.extensions.dpToPx
|
||||
import kr.co.vividnext.sodalive.main.MainActivity
|
||||
import kr.co.vividnext.sodalive.mypage.can.status.CanStatusActivity
|
||||
import org.koin.android.ext.android.inject
|
||||
import java.util.TimeZone
|
||||
|
||||
class LiveReservationCancelActivity : BaseActivity<ActivityLiveReservationCancelBinding>(
|
||||
ActivityLiveReservationCancelBinding::inflate
|
||||
@@ -146,7 +148,11 @@ class LiveReservationCancelActivity : BaseActivity<ActivityLiveReservationCancel
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun setReservation(response: GetLiveReservationResponse) {
|
||||
binding.tvDate.text = response.beginDateTime
|
||||
binding.tvDate.text = response.beginDateTimeUtc.convertDateFormat(
|
||||
from = "yyyy-MM-dd'T'HH:mm:ss",
|
||||
to = "yyyy.MM.dd EEE hh:mm a",
|
||||
inputTimeZone = TimeZone.getTimeZone("UTC")
|
||||
)
|
||||
binding.tvNickname.text = response.masterNickname
|
||||
binding.tvTitle.text = response.title
|
||||
binding.ivProfile.load(response.coverImageUrl) {
|
||||
|
||||
@@ -7,8 +7,10 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import coil.load
|
||||
import coil.transform.RoundedCornersTransformation
|
||||
import kr.co.vividnext.sodalive.databinding.ItemLiveReservationStatusBinding
|
||||
import kr.co.vividnext.sodalive.extensions.convertDateFormat
|
||||
import kr.co.vividnext.sodalive.extensions.dpToPx
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import java.util.TimeZone
|
||||
|
||||
class LiveReservationStatusAdapter(
|
||||
private val onClickCancel: (GetLiveReservationResponse) -> Unit
|
||||
@@ -22,7 +24,11 @@ class LiveReservationStatusAdapter(
|
||||
|
||||
fun bind(item: GetLiveReservationResponse) {
|
||||
val context = binding.root.context
|
||||
binding.tvDate.text = item.beginDateTime
|
||||
binding.tvDate.text = item.beginDateTimeUtc.convertDateFormat(
|
||||
from = "yyyy-MM-dd'T'HH:mm:ss",
|
||||
to = "yyyy.MM.dd EEE hh:mm a",
|
||||
inputTimeZone = TimeZone.getTimeZone("UTC")
|
||||
)
|
||||
binding.tvNickname.text = item.masterNickname
|
||||
binding.tvTitle.text = item.title
|
||||
binding.ivProfile.load(item.coverImageUrl) {
|
||||
|
||||
@@ -18,7 +18,6 @@ data class GetRoomDetailResponse(
|
||||
@SerializedName("password") val password: Int?,
|
||||
@SerializedName("tags") val tags: List<String>,
|
||||
@SerializedName("channelName") val channelName: String?,
|
||||
@SerializedName("beginDateTime") val beginDateTime: String,
|
||||
@SerializedName("beginDateTimeUtc") val beginDateTimeUtc: String,
|
||||
@SerializedName("isNotification") val isNotification: Boolean,
|
||||
@SerializedName("numberOfParticipants") val numberOfParticipants: Int,
|
||||
|
||||
@@ -26,10 +26,9 @@ import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||
import kr.co.vividnext.sodalive.databinding.FragmentLiveRoomDetailBinding
|
||||
import kr.co.vividnext.sodalive.databinding.ItemLiveDetailUserSummaryBinding
|
||||
import kr.co.vividnext.sodalive.explorer.profile.UserProfileActivity
|
||||
import kr.co.vividnext.sodalive.extensions.convertDateFormat
|
||||
import kr.co.vividnext.sodalive.extensions.dpToPx
|
||||
import org.koin.android.ext.android.inject
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
import java.util.TimeZone
|
||||
|
||||
class LiveRoomDetailFragment(
|
||||
@@ -124,10 +123,10 @@ class LiveRoomDetailFragment(
|
||||
}
|
||||
|
||||
binding.tvTitle.text = response.title
|
||||
binding.tvDate.text = formatUtcToLocal(
|
||||
utcDateString = response.beginDateTimeUtc,
|
||||
fromFormat = "yyyy-MM-dd'T'HH:mm:ss",
|
||||
toFormat = getString(R.string.screen_live_room_detail_date_format)
|
||||
binding.tvDate.text = response.beginDateTimeUtc.convertDateFormat(
|
||||
from = "yyyy-MM-dd'T'HH:mm:ss",
|
||||
to = getString(R.string.screen_live_room_detail_date_format),
|
||||
inputTimeZone = TimeZone.getTimeZone("UTC")
|
||||
)
|
||||
|
||||
if (response.price > 0) {
|
||||
@@ -368,26 +367,4 @@ class LiveRoomDetailFragment(
|
||||
startActivity(shareIntent)
|
||||
}
|
||||
}
|
||||
|
||||
private fun formatUtcToLocal(
|
||||
utcDateString: String,
|
||||
fromFormat: String,
|
||||
toFormat: String
|
||||
): String {
|
||||
val fromDateFormat = SimpleDateFormat(fromFormat, Locale.getDefault())
|
||||
fromDateFormat.timeZone = TimeZone.getTimeZone("UTC")
|
||||
val toDateFormat = SimpleDateFormat(toFormat, Locale.getDefault())
|
||||
toDateFormat.timeZone = TimeZone.getDefault()
|
||||
|
||||
return try {
|
||||
val date = fromDateFormat.parse(utcDateString)
|
||||
if (date != null) {
|
||||
toDateFormat.format(date)
|
||||
} else {
|
||||
utcDateString
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
utcDateString
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,14 +136,16 @@ class LiveRoomEditViewModel(
|
||||
|
||||
fun setRoomDetail(roomDetail: GetRoomDetailResponse) {
|
||||
this.roomDetail = roomDetail
|
||||
val date = roomDetail.beginDateTime.convertDateFormat(
|
||||
from = "yyyy.MM.dd EEE hh:mm a",
|
||||
to = "yyyy.MM.dd"
|
||||
val date = roomDetail.beginDateTimeUtc.convertDateFormat(
|
||||
from = "yyyy-MM-dd'T'HH:mm:ss",
|
||||
to = "yyyy.MM.dd",
|
||||
inputTimeZone = TimeZone.getTimeZone("UTC")
|
||||
)
|
||||
|
||||
val time = roomDetail.beginDateTime.convertDateFormat(
|
||||
from = "yyyy.MM.dd EEE hh:mm a",
|
||||
to = "a hh:mm"
|
||||
val time = roomDetail.beginDateTimeUtc.convertDateFormat(
|
||||
from = "yyyy-MM-dd'T'HH:mm:ss",
|
||||
to = "a hh:mm",
|
||||
inputTimeZone = TimeZone.getTimeZone("UTC")
|
||||
)
|
||||
|
||||
_reservationDateLiveData.value = date
|
||||
|
||||
Reference in New Issue
Block a user