From c9aaa931ef5ccbc4c5183e676295361460eaf439 Mon Sep 17 00:00:00 2001 From: Altonss Date: Wed, 6 Dec 2023 01:25:59 +0100 Subject: [PATCH] timePicker: fix minutes resetting to current hour --- .../java/de/grobox/transportr/ui/TimeDateFragment.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/de/grobox/transportr/ui/TimeDateFragment.kt b/app/src/main/java/de/grobox/transportr/ui/TimeDateFragment.kt index 0ded2f25e..a4e28a218 100755 --- a/app/src/main/java/de/grobox/transportr/ui/TimeDateFragment.kt +++ b/app/src/main/java/de/grobox/transportr/ui/TimeDateFragment.kt @@ -21,6 +21,7 @@ package de.grobox.transportr.ui import android.app.DatePickerDialog import android.app.DatePickerDialog.OnDateSetListener +import android.os.Build import android.os.Bundle import android.text.format.DateFormat.getDateFormat import android.view.LayoutInflater @@ -162,8 +163,15 @@ class TimeDateFragment : DialogFragment(), OnDateSetListener, OnTimeChangedListe @Suppress("DEPRECATION") private fun showTime(c: Calendar) { - timePicker.currentHour = c.get(HOUR_OF_DAY) - timePicker.currentMinute = c.get(MINUTE) + val hour = c.get(HOUR_OF_DAY) + val min = c.get(MINUTE) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + timePicker.hour = hour + timePicker.minute = min + } else { + timePicker.currentHour = hour + timePicker.currentMinute = min + } } private fun showDate(c: Calendar) {