allow changing the timer duration by clicking at the top time too

This commit is contained in:
tibbi 2020-12-29 11:11:15 +01:00
parent e8e168355e
commit 7a37455036
1 changed files with 18 additions and 5 deletions

View File

@ -80,12 +80,12 @@ class TimerFragment : Fragment() {
stopTimer()
}
timer_time.setOnClickListener {
changeDuration()
}
timer_initial_time.setOnClickListener {
MyTimePickerDialogDialog(activity as SimpleActivity, config.timerSeconds) { seconds ->
val timerSeconds = if (seconds <= 0) 10 else seconds
config.timerSeconds = timerSeconds
timer_initial_time.text = timerSeconds.getFormattedDuration()
}
changeDuration()
}
timer_vibrate_holder.setOnClickListener {
@ -126,6 +126,19 @@ class TimerFragment : Fragment() {
view.timer_time.text = activity?.config?.timerSeconds?.getFormattedDuration()
}
private fun changeDuration() {
MyTimePickerDialogDialog(activity as SimpleActivity, context!!.config.timerSeconds) { seconds ->
val timerSeconds = if (seconds <= 0) 10 else seconds
activity?.config?.timerSeconds = timerSeconds
val duration = timerSeconds.getFormattedDuration()
view.timer_initial_time.text = duration
if (view.timer_reset.isGone()) {
stopTimer()
}
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
fun onMessageEvent(state: TimerState.Idle) {
view.timer_time.text = requiredActivity.config.timerSeconds.getFormattedDuration()