오디션 지원자 투표

- 안내 팝업 Dialog 추가
This commit is contained in:
klaus 2025-01-03 17:42:19 +09:00
parent b0a97ab941
commit 5e6225d14c
2 changed files with 38 additions and 15 deletions

View File

@ -165,19 +165,34 @@ class AuditionRoleDetailActivity : BaseActivity<ActivityAuditionRoleDetailBindin
onClickPlayOrPause = { position, applicantId, voiceUrl ->
mediaPlayerManager.toggleContent(position, applicantId, voiceUrl)
},
onClickVote = {
onClickVote = { applicantId ->
viewModel.voteApplicant(
applicantId,
onSuccess = {
if (isShowNotifyVote) {
SodaDialog(
activity = this@AuditionRoleDetailActivity,
layoutInflater = layoutInflater,
"투표 안내",
"첫 투표 무료 - 이후 투표 유료 (하루에 총 11번 투표 가능)",
"[오디션 응원]",
"오디션을 응원하셨습니다\n(무료응원 : 1계정당 1일 1회)\n1캔으로 추가 응원을 해보세요.",
confirmButtonTitle = "확인",
confirmButtonClick = { isShowNotifyVote = false }
).show(screenWidth)
} else {
viewModel.voteApplicant(it)
confirmButtonClick = {
isShowNotifyVote = false
}
).show(screenWidth)
}
},
onFailure = {
SodaDialog(
activity = this@AuditionRoleDetailActivity,
layoutInflater = layoutInflater,
"[오늘 응원 제한]",
"오늘 응원은 여기까지!\n하루 최대 10회까지 이용이 가능합니다.\n내일 다시 이용해주세요.",
confirmButtonTitle = "확인",
confirmButtonClick = {}
).show(screenWidth)
}
)
}
)

View File

@ -264,7 +264,7 @@ class AuditionRoleDetailViewModel(private val repository: AuditionRepository) :
}
}
fun voteApplicant(position: Int) {
fun voteApplicant(position: Int, onSuccess: () -> Unit, onFailure: (() -> Unit)? = null) {
val applicantId = _applicantListLiveData.value?.get(position)?.applicantId
if (applicantId != null) {
@ -293,9 +293,17 @@ class AuditionRoleDetailViewModel(private val repository: AuditionRepository) :
}
}
_applicantListLiveData.value = updatedList!!
onSuccess()
} else {
if (it.message != null) {
if (
it.message.contains("오늘 응원은 여기까지") &&
onFailure != null
) {
onFailure()
} else {
_toastLiveData.value = it.message
}
} else {
_toastLiveData.value =
"알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."