File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
app/src/main/kotlin/com/w2sv/autocrop/ui Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ import com.w2sv.autocrop.ui.util.hideSystemBars
2727import com.w2sv.autocrop.ui.util.postponeEnterTransition
2828import com.w2sv.autocrop.ui.util.registerOnBackPressedHandler
2929import com.w2sv.autocrop.ui.util.showSystemBars
30+ import com.w2sv.autocrop.ui.util.view.setDebouncedOnClickListener
3031import com.w2sv.autocrop.ui.views.FadeOutTextView
3132import com.w2sv.kotlinutils.coroutines.flow.collectLatestOn
3233import com.w2sv.kotlinutils.coroutines.launchDelayed
@@ -71,7 +72,7 @@ class ComparisonFragment : ViewBoundAppFragment<ComparisonBinding>(ComparisonBin
7172 initializeScreenshotViewAndCropViewScaleAndPositioning()
7273 initializeCropView()
7374 setOnTouchEventListener()
74- backButton.setOnClickListener { onBack() }
75+ backButton.setDebouncedOnClickListener { onBack() }
7576
7677 viewModel.fadeOutTextArgs.collectLatestOn(lifecycleScope) {
7778 displayedImageTv.setAndShow(it)
Original file line number Diff line number Diff line change 1+ package com.w2sv.autocrop.ui.util.view
2+
3+ import android.view.View
4+
5+ // TODO: move to AndroidUtils
6+ fun View.setDebouncedOnClickListener (interval : Long = 500L, onClick : (View ) -> Unit ) {
7+ var lastClickTime = 0L
8+ setOnClickListener { v ->
9+ val now = System .currentTimeMillis()
10+ if (now - lastClickTime >= interval) {
11+ lastClickTime = now
12+ onClick(v)
13+ }
14+ }
15+ }
You can’t perform that action at this time.
0 commit comments