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/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 } 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..ae4b96588 --- /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.setOnSingleClickListener(onSingleClick: (View) -> Unit) { + val oneClick = OnSingleClickListener { + onSingleClick(it) + } + setOnClickListener(oneClick) +} 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 c1df86cff..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" - android:onClick="@{() -> 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)}" />