Skip to content

Commit

Permalink
timePicker: fix minutes resetting to current hour
Browse files Browse the repository at this point in the history
  • Loading branch information
Altonss authored and ialokim committed Jan 7, 2024
1 parent 3d40972 commit c9aaa93
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app/src/main/java/de/grobox/transportr/ui/TimeDateFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit c9aaa93

Please sign in to comment.