From 09f986a7757a6353c37e8ed1a5dac10099cb4f59 Mon Sep 17 00:00:00 2001 From: vrexpert Date: Mon, 23 Oct 2023 14:43:57 +0900 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20SingleClick=20Util=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/util/SingleClickUtil.kt | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 android/festago/app/src/main/java/com/festago/festago/presentation/util/SingleClickUtil.kt diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/util/SingleClickUtil.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/util/SingleClickUtil.kt new file mode 100644 index 000000000..2b433144b --- /dev/null +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/util/SingleClickUtil.kt @@ -0,0 +1,30 @@ +package com.festago.festago.presentation.util + +import android.os.SystemClock +import android.view.View +import androidx.databinding.BindingAdapter + +class OnSingleClickListener( + private var interval: Int = 600, + private var onSingleClick: (View) -> Unit, +) : View.OnClickListener { + + private var lastClickTime: Long = 0 + + override fun onClick(v: View) { + val elapsedRealtime = SystemClock.elapsedRealtime() + if ((elapsedRealtime - lastClickTime) < interval) { + return + } + lastClickTime = elapsedRealtime + onSingleClick(v) + } +} + +@BindingAdapter("onSingleClick") +fun View.onSingleClick(onSingleClick: (View) -> Unit) { + val oneClick = OnSingleClickListener { + onSingleClick(it) + } + setOnClickListener(oneClick) +} From 4cb11284df8b28a13fb1153beaf7bf43b2e1d307 Mon Sep 17 00:00:00 2001 From: vrexpert Date: Mon, 23 Oct 2023 14:54:12 +0900 Subject: [PATCH 2/5] =?UTF-8?q?feat:=20=EB=B0=94=ED=85=80=20=EC=8B=9C?= =?UTF-8?q?=ED=8A=B8=20=EB=B0=94=EA=B9=A5=20=ED=81=B4=EB=A6=AD=20=EB=A7=89?= =?UTF-8?q?=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bottomsheet/TicketReserveBottomSheetFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketreserve/bottomsheet/TicketReserveBottomSheetFragment.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketreserve/bottomsheet/TicketReserveBottomSheetFragment.kt index 6e2aecd0e..9c48dfb6e 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketreserve/bottomsheet/TicketReserveBottomSheetFragment.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketreserve/bottomsheet/TicketReserveBottomSheetFragment.kt @@ -28,7 +28,6 @@ class TicketReserveBottomSheetFragment : BottomSheetDialogFragment() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - val viewModelProvider = ViewModelProvider(requireActivity()) vm = viewModelProvider[TicketReserveViewModel::class.java] } @@ -39,6 +38,7 @@ class TicketReserveBottomSheetFragment : BottomSheetDialogFragment() { savedInstanceState: Bundle?, ): View { _binding = FragmentTicketReserveBottomSheetBinding.inflate(inflater) + dialog?.setCanceledOnTouchOutside(false) binding.lifecycleOwner = viewLifecycleOwner return binding.root } From 1d026a50f8f9ab30b3b8c405202236264b01b050 Mon Sep 17 00:00:00 2001 From: vrexpert Date: Mon, 23 Oct 2023 14:54:24 +0900 Subject: [PATCH 3/5] =?UTF-8?q?feat:=20single=20=ED=81=B4=EB=A6=AD=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/festago/app/src/main/res/layout/item_ticket_reserve.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/festago/app/src/main/res/layout/item_ticket_reserve.xml b/android/festago/app/src/main/res/layout/item_ticket_reserve.xml index c1df86cff..eb6504a59 100644 --- a/android/festago/app/src/main/res/layout/item_ticket_reserve.xml +++ b/android/festago/app/src/main/res/layout/item_ticket_reserve.xml @@ -111,7 +111,7 @@ android:layout_height="wrap_content" android:layout_marginHorizontal="16dp" android:layout_marginTop="28dp" - android:onClick="@{() -> stage.onShowStageTickets.invoke(stage.id, stage.startTime)}" + app:onSingleClick="@{() -> stage.onShowStageTickets.invoke(stage.id, stage.startTime)}" android:text="@string/ticket_reserve_btn_reserve_ticket" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" From 740ac5413f69b59d583184514b4601ef963d7d0c Mon Sep 17 00:00:00 2001 From: vrexpert Date: Mon, 23 Oct 2023 15:05:22 +0900 Subject: [PATCH 4/5] =?UTF-8?q?refactor:=20SingleClick=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/studentverification/StudentVerificationActivity.kt | 3 ++- .../com/festago/festago/presentation/util/SingleClickUtil.kt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/studentverification/StudentVerificationActivity.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/studentverification/StudentVerificationActivity.kt index 349ec05d4..54004bff5 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/studentverification/StudentVerificationActivity.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/studentverification/StudentVerificationActivity.kt @@ -10,6 +10,7 @@ import com.festago.festago.databinding.ActivityStudentVerificationBinding import com.festago.festago.presentation.ui.customview.OkDialogFragment import com.festago.festago.presentation.ui.home.HomeActivity import com.festago.festago.presentation.util.repeatOnStarted +import com.festago.festago.presentation.util.setOnSingleClickListener import dagger.hilt.android.AndroidEntryPoint import java.time.LocalTime import java.time.format.DateTimeFormatter @@ -43,7 +44,7 @@ class StudentVerificationActivity : AppCompatActivity() { } private fun initRequestVerificationCodeBtn(schoolId: Long) { - binding.btnRequestVerificationCode.setOnClickListener { + binding.btnRequestVerificationCode.setOnSingleClickListener { vm.sendVerificationCode(binding.tieUserName.text.toString(), schoolId) } } diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/util/SingleClickUtil.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/util/SingleClickUtil.kt index 2b433144b..ae4b96588 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/util/SingleClickUtil.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/util/SingleClickUtil.kt @@ -22,7 +22,7 @@ class OnSingleClickListener( } @BindingAdapter("onSingleClick") -fun View.onSingleClick(onSingleClick: (View) -> Unit) { +fun View.setOnSingleClickListener(onSingleClick: (View) -> Unit) { val oneClick = OnSingleClickListener { onSingleClick(it) } From d1f7e86d4dec4a1606306b448e477ef0cabff53a Mon Sep 17 00:00:00 2001 From: vrexpert Date: Mon, 23 Oct 2023 15:06:20 +0900 Subject: [PATCH 5/5] =?UTF-8?q?refactor:=20xml=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=ED=98=B8=EC=B6=9C=20=EC=88=9C=EC=84=9C=20=EB=A7=9E=EC=B6=94?= =?UTF-8?q?=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/res/layout/fragment_ticket_reserve_bottom_sheet.xml | 4 ++-- .../festago/app/src/main/res/layout/item_ticket_reserve.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/android/festago/app/src/main/res/layout/fragment_ticket_reserve_bottom_sheet.xml b/android/festago/app/src/main/res/layout/fragment_ticket_reserve_bottom_sheet.xml index 5235b5d9f..384feb9f2 100644 --- a/android/festago/app/src/main/res/layout/fragment_ticket_reserve_bottom_sheet.xml +++ b/android/festago/app/src/main/res/layout/fragment_ticket_reserve_bottom_sheet.xml @@ -93,11 +93,11 @@ android:layout_height="wrap_content" android:layout_marginHorizontal="16dp" android:layout_marginVertical="28dp" - android:onClick="@{() -> onReserve.invoke(selectedTicketTypeId)}" android:text="@string/ticket_reserve_tv_btn_reserve_ticket" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" /> + app:layout_constraintStart_toStartOf="parent" + app:onSingleClick="@{() -> onReserve.invoke(selectedTicketTypeId)}" /> diff --git a/android/festago/app/src/main/res/layout/item_ticket_reserve.xml b/android/festago/app/src/main/res/layout/item_ticket_reserve.xml index eb6504a59..f1835d3db 100644 --- a/android/festago/app/src/main/res/layout/item_ticket_reserve.xml +++ b/android/festago/app/src/main/res/layout/item_ticket_reserve.xml @@ -111,11 +111,11 @@ android:layout_height="wrap_content" android:layout_marginHorizontal="16dp" android:layout_marginTop="28dp" - app:onSingleClick="@{() -> stage.onShowStageTickets.invoke(stage.id, stage.startTime)}" android:text="@string/ticket_reserve_btn_reserve_ticket" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@id/tvAuthGuideStudent" /> + app:layout_constraintTop_toBottomOf="@id/tvAuthGuideStudent" + app:onSingleClick="@{() -> stage.onShowStageTickets.invoke(stage.id, stage.startTime)}" />