오디션 투표

- 안내 팝업 추가
- 투표시 데이터가 변경되지 않던 버그 수정
This commit is contained in:
klaus 2025-01-03 08:50:28 +09:00
parent 4e14765e94
commit ee396b3102
6 changed files with 41 additions and 16 deletions

View File

@ -29,7 +29,7 @@ class AuditionApplicantListAdapter(
oldItem: GetAuditionRoleApplicantItem,
newItem: GetAuditionRoleApplicantItem
): Boolean {
return oldItem == newItem
return oldItem == newItem && oldItem.voteCount == newItem.voteCount
}
}
@ -41,6 +41,7 @@ class AuditionApplicantListAdapter(
binding.ivPlayOrPause.setOnClickListener { onClickPlayOrPause(position) }
binding.tvNickname.text = item.nickname
binding.tvCountVote.text = item.voteCount.toString()
binding.ivProfile.load(item.profileImageUrl) {
crossfade(true)
placeholder(R.drawable.bg_placeholder)
@ -49,9 +50,9 @@ class AuditionApplicantListAdapter(
binding.ivPlayOrPause.setImageResource(
if (position == currentPlayingIndex) {
R.drawable.ic_audition_play
} else {
R.drawable.ic_audition_pause
} else {
R.drawable.ic_audition_play
}
)
}

View File

@ -15,5 +15,5 @@ data class GetAuditionRoleApplicantItem(
@SerializedName("nickname") val nickname: String,
@SerializedName("profileImageUrl") val profileImageUrl: String,
@SerializedName("voiceUrl") val voiceUrl: String,
@SerializedName("voteCount") var voteCount: Long
@SerializedName("voteCount") val voteCount: Long
)

View File

@ -40,6 +40,7 @@ class AuditionRoleDetailActivity : BaseActivity<ActivityAuditionRoleDetailBindin
private var isOpenInformation = false
private var reApplication = false
private var isDeleteAudioFile = false
private var isShowNotifyVote = true
private val selectAudioActivityResultLauncher = registerForActivityResult(
ActivityResultContracts.StartActivityForResult()
@ -141,7 +142,20 @@ class AuditionRoleDetailActivity : BaseActivity<ActivityAuditionRoleDetailBindin
adapter = AuditionApplicantListAdapter(
onClickPlayOrPause = {},
onClickVote = { viewModel.voteApplicant(it) }
onClickVote = {
if (isShowNotifyVote) {
SodaDialog(
activity = this@AuditionRoleDetailActivity,
layoutInflater = layoutInflater,
"투표 안내",
"첫 투표 무료 - 이후 투표 유료 (하루에 총 11번 투표 가능)",
confirmButtonTitle = "확인",
confirmButtonClick = { isShowNotifyVote = false }
).show(screenWidth)
} else {
viewModel.voteApplicant(it)
}
}
)
val recyclerView = binding.rvApplicant

View File

@ -228,7 +228,6 @@ class AuditionRoleDetailViewModel(private val repository: AuditionRepository) :
{
_isLoading.value = false
if (it.success) {
_applicantListLiveData.value = emptyList()
page = 1
isLast = false
getAuditionRoleDetail(auditionRoleId = auditionRoleId)
@ -266,11 +265,10 @@ class AuditionRoleDetailViewModel(private val repository: AuditionRepository) :
}
fun voteApplicant(position: Int) {
val updatedList = _applicantListLiveData.value?.toMutableList()
val applicantId = updatedList?.get(position)?.applicantId
val applicantId = _applicantListLiveData.value?.get(position)?.applicantId
if (applicantId != null) {
_isLoading.value = false
_isLoading.value = true
val request = VoteAuditionApplicantRequest(
applicantId = applicantId,
timezone = TimeZone.getDefault().id
@ -286,7 +284,14 @@ class AuditionRoleDetailViewModel(private val repository: AuditionRepository) :
.subscribe(
{
if (it.success) {
updatedList[position].voteCount += 1
val updatedList =
_applicantListLiveData.value?.mapIndexed { index, item ->
if (index == position) {
item.copy(voteCount = item.voteCount + 1)
} else {
item
}
}
_applicantListLiveData.value = updatedList!!
} else {
if (it.message != null) {
@ -310,7 +315,12 @@ class AuditionRoleDetailViewModel(private val repository: AuditionRepository) :
}
private fun addApplicantList(itemList: List<GetAuditionRoleApplicantItem>) {
val updatedList = _applicantListLiveData.value?.toMutableList() ?: mutableListOf()
val updatedList = if (page == 1) {
mutableListOf()
} else {
_applicantListLiveData.value?.toMutableList() ?: mutableListOf()
}
updatedList.addAll(itemList)
_applicantListLiveData.value = updatedList
}

View File

@ -134,7 +134,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/gmarket_sans_medium"
android:text="참여자"
android:text="참여자 "
android:textColor="@color/color_bbbbbb"
android:textSize="10.7sp" />
@ -185,12 +185,11 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_applicant"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_height="match_parent"
android:layout_marginTop="12dp"
android:clipToPadding="false"
android:paddingHorizontal="13.3dp"
android:paddingBottom="12dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ll_applicant_count" />

View File

@ -13,6 +13,7 @@
android:layout_width="40dp"
android:layout_height="40dp"
android:contentDescription="@null"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@ -45,9 +46,9 @@
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="@+id/iv_profile"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/iv_profile"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="UseCompoundDrawables">
<ImageView