use of com.wdullaer.materialdatetimepicker.time.TimePickerDialog in project android_packages_apps_OmniClock by omnirom.
the class AlarmUtils method showTimeEditDialog.
/**
* Show the time picker dialog. This is called from AlarmClockFragment to set alarm.
* @param fragment The calling fragment (which is also a onTimeSetListener),
* we use it as the target fragment of the TimePickerFragment, so later the
* latter can retrieve it and set it as its onTimeSetListener when the fragment
* is recreated.
* @param alarm The clicked alarm, it can be null if user was clicking the fab instead.
*/
public static void showTimeEditDialog(Fragment fragment, final Alarm alarm) {
final FragmentManager manager = fragment.getFragmentManager();
final FragmentTransaction ft = manager.beginTransaction();
final Fragment prev = manager.findFragmentByTag(FRAG_TAG_TIME_PICKER);
if (prev != null) {
ft.remove(prev);
}
ft.commit();
final int hour, minute;
if (alarm == null) {
final Calendar c = Calendar.getInstance();
hour = c.get(Calendar.HOUR_OF_DAY);
minute = c.get(Calendar.MINUTE);
} else {
hour = alarm.hour;
minute = alarm.minutes;
}
final TimePickerDialog timePickerFragment = TimePickerDialog.newInstance((TimePickerDialog.OnTimeSetListener) fragment, hour, minute, DateFormat.is24HourFormat(fragment.getActivity()), Utils.getThemeId(fragment.getActivity()));
timePickerFragment.show(manager, FRAG_TAG_TIME_PICKER);
}
use of com.wdullaer.materialdatetimepicker.time.TimePickerDialog in project haven by guardianproject.
the class SettingsFragment method showTimeDelayDialog.
private void showTimeDelayDialog(String configVideoLength) {
int totalSecs;
if (configVideoLength.equalsIgnoreCase(PreferenceManager.CONFIG_TIME_DELAY)) {
totalSecs = preferences.getTimerDelay();
} else {
totalSecs = preferences.getMonitoringTime();
}
int hours = totalSecs / 3600;
int minutes = (totalSecs % 3600) / 60;
int seconds = totalSecs % 60;
TimePickerDialog mTimePickerDialog = TimePickerDialog.newInstance(this, hours, minutes, seconds, true);
mTimePickerDialog.enableSeconds(true);
if (configVideoLength.equalsIgnoreCase(PreferenceManager.CONFIG_TIME_DELAY)) {
mTimePickerDialog.show(mActivity.getFragmentManager(), "TimeDelayPickerDialog");
} else {
mTimePickerDialog.show(mActivity.getFragmentManager(), "VideoLengthPickerDialog");
}
}
use of com.wdullaer.materialdatetimepicker.time.TimePickerDialog in project MaterialDateTimePicker by wdullaer.
the class TimePickerFragment method onResume.
@Override
public void onResume() {
super.onResume();
TimePickerDialog tpd = (TimePickerDialog) requireFragmentManager().findFragmentByTag("Timepickerdialog");
if (tpd != null)
tpd.setOnTimeSetListener(this);
}
use of com.wdullaer.materialdatetimepicker.time.TimePickerDialog in project MaterialDateTimePicker by wdullaer.
the class TimePickerFragment method onCreateView.
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.timepicker_layout, container, false);
// Find our View instances
timeTextView = view.findViewById(R.id.time_textview);
Button timeButton = view.findViewById(R.id.time_button);
mode24Hours = view.findViewById(R.id.mode_24_hours);
modeDarkTime = view.findViewById(R.id.mode_dark_time);
modeCustomAccentTime = view.findViewById(R.id.mode_custom_accent_time);
vibrateTime = view.findViewById(R.id.vibrate_time);
dismissTime = view.findViewById(R.id.dismiss_time);
titleTime = view.findViewById(R.id.title_time);
enableSeconds = view.findViewById(R.id.enable_seconds);
limitSelectableTimes = view.findViewById(R.id.limit_times);
disableSpecificTimes = view.findViewById(R.id.disable_times);
showVersion2 = view.findViewById(R.id.show_version_2);
view.findViewById(R.id.original_button).setOnClickListener(view1 -> {
Calendar now = Calendar.getInstance();
new android.app.TimePickerDialog(getActivity(), (view11, hour, minute) -> Log.d("Original", "Got clicked"), now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE), mode24Hours.isChecked()).show();
});
// Show a timepicker when the timeButton is clicked
timeButton.setOnClickListener(v -> {
Calendar now = Calendar.getInstance();
/*
It is recommended to always create a new instance whenever you need to show a Dialog.
The sample app is reusing them because it is useful when looking for regressions
during testing
*/
if (tpd == null) {
tpd = TimePickerDialog.newInstance(TimePickerFragment.this, now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE), mode24Hours.isChecked());
} else {
tpd.initialize(TimePickerFragment.this, now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE), now.get(Calendar.SECOND), mode24Hours.isChecked());
}
tpd.setThemeDark(modeDarkTime.isChecked());
tpd.vibrate(vibrateTime.isChecked());
tpd.dismissOnPause(dismissTime.isChecked());
tpd.enableSeconds(enableSeconds.isChecked());
tpd.setVersion(showVersion2.isChecked() ? TimePickerDialog.Version.VERSION_2 : TimePickerDialog.Version.VERSION_1);
if (modeCustomAccentTime.isChecked()) {
tpd.setAccentColor(Color.parseColor("#9C27B0"));
}
if (titleTime.isChecked()) {
tpd.setTitle("TimePicker Title");
}
if (limitSelectableTimes.isChecked()) {
if (enableSeconds.isChecked()) {
tpd.setTimeInterval(3, 5, 10);
} else {
tpd.setTimeInterval(3, 5, 60);
}
}
if (disableSpecificTimes.isChecked()) {
Timepoint[] disabledTimes = { new Timepoint(10), new Timepoint(10, 30), new Timepoint(11), new Timepoint(12, 30) };
tpd.setDisabledTimes(disabledTimes);
}
tpd.setOnCancelListener(dialogInterface -> {
Log.d("TimePicker", "Dialog was cancelled");
tpd = null;
});
tpd.show(requireFragmentManager(), "Timepickerdialog");
});
return view;
}
use of com.wdullaer.materialdatetimepicker.time.TimePickerDialog in project UltimateAndroid by cymcsg.
the class MaterialDataTimePickerActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.material_data_time_picker_activity_main);
// Find our View instances
timeTextView = (TextView) findViewById(R.id.time_textview);
dateTextView = (TextView) findViewById(R.id.date_textview);
Button timeButton = (Button) findViewById(R.id.time_button);
Button dateButton = (Button) findViewById(R.id.date_button);
mode24Hours = (CheckBox) findViewById(R.id.mode_24_hours);
modeDarkTime = (CheckBox) findViewById(R.id.mode_dark_time);
modeDarkDate = (CheckBox) findViewById(R.id.mode_dark_date);
// Show a timepicker when the timeButton is clicked
timeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Calendar now = Calendar.getInstance();
TimePickerDialog tpd = TimePickerDialog.newInstance(MaterialDataTimePickerActivity.this, now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE), mode24Hours.isChecked());
tpd.setThemeDark(modeDarkTime.isChecked());
tpd.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
Log.d("TimePicker", "Dialog was cancelled");
}
});
tpd.show(getFragmentManager(), "Timepickerdialog");
}
});
// Show a datepicker when the dateButton is clicked
dateButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Calendar now = Calendar.getInstance();
DatePickerDialog dpd = DatePickerDialog.newInstance(MaterialDataTimePickerActivity.this, now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH));
dpd.setThemeDark(modeDarkDate.isChecked());
dpd.show(getFragmentManager(), "Datepickerdialog");
}
});
}
Aggregations