From 7557fc2102c4d217a4bc2cddc3893ab80ae39d08 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Wed, 17 Jan 2024 23:36:26 +0900 Subject: [PATCH] =?UTF-8?q?[FIX/#152]=20=EC=B7=A8=ED=96=A5=20=ED=83=9C?= =?UTF-8?q?=EA=B7=B8=20=EB=B2=84=ED=8A=BC=20=ED=84=B0=EC=B9=98=20=EC=98=81?= =?UTF-8?q?=EC=97=AD=20=EB=84=93=ED=9E=88=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../preferencetag/PreferenceTagViewHolder.kt | 41 ++++++++---- .../main/res/layout/item_preference_tag.xml | 66 +++++++++++++++++-- 2 files changed, 90 insertions(+), 17 deletions(-) diff --git a/presentation/src/main/java/com/going/presentation/entertrip/preferencetag/PreferenceTagViewHolder.kt b/presentation/src/main/java/com/going/presentation/entertrip/preferencetag/PreferenceTagViewHolder.kt index db19e5e1..b51a300c 100644 --- a/presentation/src/main/java/com/going/presentation/entertrip/preferencetag/PreferenceTagViewHolder.kt +++ b/presentation/src/main/java/com/going/presentation/entertrip/preferencetag/PreferenceTagViewHolder.kt @@ -2,7 +2,6 @@ package com.going.presentation.entertrip.preferencetag import androidx.recyclerview.widget.RecyclerView import com.going.domain.entity.PreferenceData -import com.going.presentation.R import com.going.presentation.databinding.ItemPreferenceTagBinding class PreferenceTagViewHolder( @@ -17,20 +16,36 @@ class PreferenceTagViewHolder( tvPreferenceTag1.text = item.leftPrefer tvPreferenceTag3.text = item.rightPrefer - rgPreferenceTag.setOnCheckedChangeListener { _, checkedId -> - val selectedButtonIdList = listOf( - R.id.rb_preference_1, - R.id.rb_preference_2, - R.id.rb_preference_3, - R.id.rb_preference_4, - R.id.rb_preference_5 - ) + val selectedButtonList = listOf( + rbPreference1, + rbPreference2, + rbPreference3, + rbPreference4, + rbPreference5 + ) - val checkedIndex = selectedButtonIdList.indexOf(checkedId) - if (checkedIndex != -1) { - listener.onPreferenceSelected(item, checkedIndex) + val selectedViewList = listOf( + viewRadio1, + viewRadio2, + viewRadio3, + viewRadio4, + viewRadio5 + ) + + selectedButtonList.forEachIndexed { index, radioButton -> + radioButton.setOnClickListener { + if (radioButton.isChecked) { + listener.onPreferenceSelected(item, index) + } + } + } + + selectedViewList.forEachIndexed { index, view -> + view.setOnClickListener { + selectedButtonList[index].isChecked = true + listener.onPreferenceSelected(item, index) } } } } -} +} \ No newline at end of file diff --git a/presentation/src/main/res/layout/item_preference_tag.xml b/presentation/src/main/res/layout/item_preference_tag.xml index 40feb977..ace88877 100644 --- a/presentation/src/main/res/layout/item_preference_tag.xml +++ b/presentation/src/main/res/layout/item_preference_tag.xml @@ -29,14 +29,14 @@ + app:layout_constraintTop_toTopOf="@id/tv_preference_number" /> + + + + + + + + + + + + + + - + \ No newline at end of file