parent
a92c2acd88
commit
1d8fd2aff5
@ -0,0 +1,26 @@ |
||||
package net.pokeranalytics.android.util |
||||
|
||||
import android.app.DatePickerDialog |
||||
import android.app.Dialog |
||||
import android.os.Bundle |
||||
import android.widget.DatePicker |
||||
import androidx.fragment.app.DialogFragment |
||||
import java.util.* |
||||
|
||||
class DatePickerFragment : DialogFragment(), DatePickerDialog.OnDateSetListener { |
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { |
||||
// Use the current date as the default date in the picker |
||||
val c = Calendar.getInstance() |
||||
val year = c.get(Calendar.YEAR) |
||||
val month = c.get(Calendar.MONTH) |
||||
val day = c.get(Calendar.DAY_OF_MONTH) |
||||
|
||||
// Create a new instance of DatePickerDialog and return it |
||||
return DatePickerDialog(activity, this, year, month, day) |
||||
} |
||||
|
||||
override fun onDateSet(view: DatePicker, year: Int, month: Int, day: Int) { |
||||
// Do something with the date chosen by the user |
||||
} |
||||
} |
||||
@ -0,0 +1,26 @@ |
||||
package net.pokeranalytics.android.util |
||||
|
||||
import android.app.Dialog |
||||
import android.app.TimePickerDialog |
||||
import android.os.Bundle |
||||
import android.text.format.DateFormat |
||||
import android.widget.TimePicker |
||||
import androidx.fragment.app.DialogFragment |
||||
import java.util.* |
||||
|
||||
class TimePickerFragment : DialogFragment(), TimePickerDialog.OnTimeSetListener { |
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { |
||||
// Use the current time as the default values for the picker |
||||
val c = Calendar.getInstance() |
||||
val hour = c.get(Calendar.HOUR_OF_DAY) |
||||
val minute = c.get(Calendar.MINUTE) |
||||
|
||||
// Create a new instance of TimePickerDialog and return it |
||||
return TimePickerDialog(activity, this, hour, minute, DateFormat.is24HourFormat(activity)) |
||||
} |
||||
|
||||
override fun onTimeSet(view: TimePicker, hourOfDay: Int, minute: Int) { |
||||
// Do something with the time chosen by the user |
||||
} |
||||
} |
||||
Loading…
Reference in new issue