File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/list/views Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -80,12 +80,13 @@ class CheckmarkButtonView(
8080 setOnLongClickListener(this )
8181 }
8282
83- fun performToggle () {
83+ private fun performToggle () {
8484 value = Entry .nextToggleValue(
8585 value = value,
8686 isSkipEnabled = preferences.isSkipEnabled,
8787 areQuestionMarksEnabled = preferences.areQuestionMarksEnabled
8888 )
89+
8990 onToggle(value)
9091 performHapticFeedback(HapticFeedbackConstants .LONG_PRESS )
9192 invalidate()
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ import android.widget.TextView
3636import org.isoron.platform.gui.toInt
3737import org.isoron.uhabits.R
3838import org.isoron.uhabits.activities.common.views.RingView
39+ import org.isoron.uhabits.activities.habits.list.views.HabitCardView.Companion.delay
3940import org.isoron.uhabits.core.models.Habit
4041import org.isoron.uhabits.core.models.ModelObservable
4142import org.isoron.uhabits.core.models.Timestamp
@@ -143,7 +144,11 @@ class HabitCardView(
143144 checkmarkPanel = checkmarkPanelFactory.create().apply {
144145 onToggle = { timestamp, value ->
145146 triggerRipple(timestamp)
146- habit?.let { behavior.onToggle(it, timestamp, value) }
147+ habit?.let {
148+ {
149+ behavior.onToggle(it, timestamp, value)
150+ }.delay(TOGGLE_DELAY_MILLIS )
151+ }
147152 }
148153 }
149154
@@ -263,4 +268,12 @@ class HabitCardView(
263268 }
264269 innerFrame.setBackgroundResource(background)
265270 }
271+
272+ companion object {
273+ const val TOGGLE_DELAY_MILLIS = 2000L
274+
275+ fun (() -> Unit ).delay(delayInMillis : Long ) {
276+ Handler (Looper .getMainLooper()).postDelayed(this , delayInMillis)
277+ }
278+ }
266279}
You can’t perform that action at this time.
0 commit comments