use of android.app.TimePickerDialog in project incubator-weex by apache.
the class DatePickerImpl method pickTime.
public static void pickTime(@NonNull Context context, String value, @NonNull final OnPickListener listener, @Nullable Map<String, Object> extras) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(parseTime(value));
TimePickerDialog dialog = new TimePickerDialog(context, new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
String h = hourOfDay < 10 ? "0" + hourOfDay : String.valueOf(hourOfDay);
String m = minute < 10 ? "0" + minute : String.valueOf(minute);
String result = h + ":" + m;
listener.onPick(true, result);
}
}, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), false);
dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
listener.onPick(false, null);
}
});
setButtonText(dialog, DialogInterface.BUTTON_NEGATIVE, String.valueOf(extras != null ? extras.get("cancelTitle") : null));
setButtonText(dialog, DialogInterface.BUTTON_POSITIVE, String.valueOf(extras != null ? extras.get("confirmTitle") : null));
dialog.show();
}
use of android.app.TimePickerDialog in project android_packages_apps_Settings by SudaMod.
the class NightDisplaySettings method onCreateDialog.
@Override
public Dialog onCreateDialog(final int dialogId) {
if (dialogId == DIALOG_START_TIME || dialogId == DIALOG_END_TIME) {
final LocalTime initialTime;
if (dialogId == DIALOG_START_TIME) {
initialTime = mController.getCustomStartTime();
} else {
initialTime = mController.getCustomEndTime();
}
final Context context = getContext();
final boolean use24HourFormat = android.text.format.DateFormat.is24HourFormat(context);
return new TimePickerDialog(context, new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
final LocalTime time = LocalTime.of(hourOfDay, minute);
if (dialogId == DIALOG_START_TIME) {
mController.setCustomStartTime(time);
} else {
mController.setCustomEndTime(time);
}
}
}, initialTime.getHour(), initialTime.getMinute(), use24HourFormat);
}
return super.onCreateDialog(dialogId);
}
use of android.app.TimePickerDialog in project iNaturalistAndroid by inaturalist.
the class TimePickerFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
String currentHour = mDate.getText().toString();
Calendar c;
mIsCanceled = false;
if (currentHour.equals("")) {
// Use the current hour as the default hour in the picker
c = Calendar.getInstance();
} else {
Date date;
c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, Integer.valueOf(currentHour.split(":")[0]));
c.set(Calendar.MINUTE, Integer.valueOf(currentHour.split(":")[1]));
}
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
// Create a new instance of TimePickerDialog and return it
TimePickerDialog dialog = new TimePickerDialog(getActivity(), this, hour, minute, true);
dialog.setOnCancelListener(this);
dialog.setOnDismissListener(this);
return dialog;
}
use of android.app.TimePickerDialog in project platform_packages_apps_Settings by BlissRoms.
the class NightDisplaySettings method onCreateDialog.
@Override
public Dialog onCreateDialog(final int dialogId) {
if (dialogId == DIALOG_START_TIME || dialogId == DIALOG_END_TIME) {
final LocalTime initialTime;
if (dialogId == DIALOG_START_TIME) {
initialTime = mController.getCustomStartTime();
} else {
initialTime = mController.getCustomEndTime();
}
final Context context = getContext();
final boolean use24HourFormat = android.text.format.DateFormat.is24HourFormat(context);
return new TimePickerDialog(context, new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
final LocalTime time = LocalTime.of(hourOfDay, minute);
if (dialogId == DIALOG_START_TIME) {
mController.setCustomStartTime(time);
} else {
mController.setCustomEndTime(time);
}
}
}, initialTime.getHour(), initialTime.getMinute(), use24HourFormat);
}
return super.onCreateDialog(dialogId);
}
use of android.app.TimePickerDialog in project cyborg-core by nu-art.
the class DateTimePicker method timePicker.
/**
* Show only a time picker
*/
public void timePicker() {
TimePickerDialog timePickerDialog = new TimePickerDialog(activity, new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), hourOfDay, minute);
listener.onDateTimeChanged();
}
}, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), false);
timePickerDialog.show();
}
Aggregations