allow changing the timer time my clicking at the initial time

This commit is contained in:
tibbi 2018-03-09 14:18:35 +01:00
parent 9fc8115f26
commit 07a3b876b2
2 changed files with 16 additions and 3 deletions

View File

@ -7,7 +7,7 @@ import com.simplemobiletools.clock.extensions.config
import com.simplemobiletools.commons.extensions.setupDialogStuff
import kotlinx.android.synthetic.main.dialog_my_time_picker.view.*
class MyTimePickerDialogDialog(val activity: SimpleActivity, val initialSeconds: Int, private val callback: () -> Unit) {
class MyTimePickerDialogDialog(val activity: SimpleActivity, val initialSeconds: Int, val callback: (result: Int) -> Unit) {
private var view = activity.layoutInflater.inflate(R.layout.dialog_my_time_picker, null)
init {
@ -18,6 +18,10 @@ class MyTimePickerDialogDialog(val activity: SimpleActivity, val initialSeconds:
it.selectedTextColor = textColor
it.dividerColor = textColor
}
my_time_picker_hours.value = initialSeconds / 3600
my_time_picker_minutes.value = (initialSeconds) / 60 % 60
my_time_picker_seconds.value = initialSeconds % 60
}
AlertDialog.Builder(activity)
@ -29,6 +33,11 @@ class MyTimePickerDialogDialog(val activity: SimpleActivity, val initialSeconds:
}
private fun dialogConfirmed() {
callback()
view.apply {
val hours = my_time_picker_hours.value
val minutes = my_time_picker_minutes.value
val seconds = my_time_picker_seconds.value
callback(hours * 3600 + minutes * 60 + seconds)
}
}
}

View File

@ -84,7 +84,11 @@ class TimerFragment : Fragment() {
timer_initial_time.colorLeftDrawable(textColor)
timer_initial_time.setOnClickListener {
MyTimePickerDialogDialog(activity as SimpleActivity, config.timerSeconds) {
config.timerSeconds = it
timer_initial_time.text = it.getFormattedDuration()
if (!isRunning) {
resetTimer()
}
}
}