List of usage examples for android.app DatePickerDialog getDatePicker
@NonNull
public DatePicker getDatePicker()
From source file:com.collabora.xwperf.notxw_contacts.fragments.DatePickerFragment.java
@NonNull @Override//from w w w.ja v a 2 s . c o m public Dialog onCreateDialog(Bundle savedInstanceState) { Calendar c = Calendar.getInstance(); c.setTime(new Date(getArguments().getLong(EXTRA_INIT_DATE))); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH); int day = c.get(Calendar.DAY_OF_MONTH); DatePickerDialog dialog = new DatePickerDialog(getActivity(), this, year, month, day); dialog.getDatePicker().setMaxDate(new Date().getTime() + 1); return dialog; }
From source file:com.kyleszombathy.sms_scheduler.DatePickerFragment.java
@NonNull @Override/*from www . j a va2 s.c o m*/ public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the current date as the default date in the picker final Calendar c = Calendar.getInstance(); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH); int day = c.get(Calendar.DAY_OF_MONTH); // Create a new instance of DatePickerDialog and return it DatePickerDialog dialog = new DatePickerDialog(getActivity(), this, year, month, day); dialog.getDatePicker().setMinDate(System.currentTimeMillis() - 1000); return dialog; }
From source file:ca.ualberta.cs.shoven_habittracker.DatePickerFragment.java
@Override @NonNull//from w w w . ja v a 2s.c om public Dialog onCreateDialog(Bundle savedInstanceState) { DatePickerDialog dialog = new DatePickerDialog(getActivity(), this, year, month, day); dialog.getDatePicker().setMaxDate(System.currentTimeMillis()); return dialog; }
From source file:se.chalmers.watchme.ui.DatePickerFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the current date as the default date in the picker pickedDate = Calendar.getInstance(); int year = pickedDate.get(Calendar.YEAR); int month = pickedDate.get(Calendar.MONTH); int day = pickedDate.get(Calendar.DAY_OF_MONTH); DatePickerDialog datePickerDialog = new DatePickerDialog(getActivity(), this, year, month, day); // Disallow any earlier dates than today's date datePickerDialog.getDatePicker().setMinDate(pickedDate.getTimeInMillis()); // Create a new instance of DatePickerDialog and return it return datePickerDialog; }
From source file:com.mifos.mifosxdroid.uihelpers.MFDatePicker.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { DatePickerDialog dialog = new DatePickerDialog(getActivity(), this, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)); dialog.getDatePicker().setMaxDate(new Date().getTime()); return dialog; }
From source file:de.uni_koblenz_landau.apow.dialogs.DateDialogFragment.java
@NonNull @Override/*from ww w. j a va 2 s . c o m*/ public Dialog onCreateDialog(Bundle savedInstanceState) { setRetainInstance(true); mTarget = this.getTag(); DatePickerDialog dialog = new DatePickerDialog(getActivity(), dateSetListener, mCalendar.get(Calendar.YEAR), mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH)); dialog.getDatePicker().setMaxDate(new Date().getTime()); return dialog; }
From source file:org.mythtv.client.ui.dvr.GuideDatePickerFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { Log.v(TAG, "onCreate : enter"); if (null == listener) { throw new IllegalArgumentException("OnDialogResultListener is required!"); }//from ww w . j av a 2 s.c o m Bundle args = getArguments(); selectedDate = new DateTime(args.getLong("selectedDate")); downloadDays = args.getInt("downloadDays"); Log.v(TAG, "onCreate : selectedDate=" + selectedDate.toString() + ", downloadDays=" + downloadDays); // Create a new instance of DatePickerDialog and return it DatePickerDialog datePickerDialog = new DatePickerDialog(getActivity(), this, selectedDate.getYear(), selectedDate.getMonthOfYear() - 1, selectedDate.getDayOfMonth()); if (null != datePickerDialog.getDatePicker()) { DateTime today = new DateTime().withTimeAtStartOfDay(); Log.v(TAG, "onCreate : today=" + today.toString()); // datePickerDialog.getDatePicker().setMinDate( today.getMillis() ); Log.v(TAG, "onCreate : today+downloadDays=" + today.plusDays(downloadDays).toString()); // datePickerDialog.getDatePicker().setMaxDate( today.plusDays( downloadDays ).getMillis() ); } Log.v(TAG, "onCreate : exit"); return datePickerDialog; }
From source file:com.example.crudcontent.fragment.DatePickerDialogFragment.java
@NonNull @Override// w w w . j ava 2 s .co m public Dialog onCreateDialog(Bundle savedInstanceState) { // Initialize our date picker dialog with the last birthday of the user... Calendar cal = Calendar.getInstance(); cal.setTime(date); DatePickerDialog dialog = new DatePickerDialog(getActivity(), this, cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH)); // No birthdays allowed in the future... dialog.getDatePicker().setMaxDate(System.currentTimeMillis()); // One note. The DatePickerDialog is managing the saved state for us. This is why // this fragment isn't trying to do that. It is nice when that happens, but you // should always verify expected behavior. return dialog; }
From source file:com.facebook.react.modules.datepicker.DatePickerDialogFragment.java
static Dialog createDialog(Bundle args, Context activityContext, @Nullable OnDateSetListener onDateSetListener) { final Calendar c = Calendar.getInstance(); if (args != null && args.containsKey(DatePickerDialogModule.ARG_DATE)) { c.setTimeInMillis(args.getLong(DatePickerDialogModule.ARG_DATE)); }// ww w .ja v a2s .com final int year = c.get(Calendar.YEAR); final int month = c.get(Calendar.MONTH); final int day = c.get(Calendar.DAY_OF_MONTH); DatePickerMode mode = DatePickerMode.DEFAULT; if (args != null && args.getString(DatePickerDialogModule.ARG_MODE, null) != null) { mode = DatePickerMode.valueOf(args.getString(DatePickerDialogModule.ARG_MODE).toUpperCase(Locale.US)); } DatePickerDialog dialog = null; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { switch (mode) { case CALENDAR: dialog = new DismissableDatePickerDialog(activityContext, activityContext.getResources() .getIdentifier("CalendarDatePickerDialog", "style", activityContext.getPackageName()), onDateSetListener, year, month, day); break; case SPINNER: dialog = new DismissableDatePickerDialog(activityContext, activityContext.getResources() .getIdentifier("SpinnerDatePickerDialog", "style", activityContext.getPackageName()), onDateSetListener, year, month, day); break; case DEFAULT: dialog = new DismissableDatePickerDialog(activityContext, onDateSetListener, year, month, day); break; } } else { dialog = new DismissableDatePickerDialog(activityContext, onDateSetListener, year, month, day); switch (mode) { case CALENDAR: dialog.getDatePicker().setCalendarViewShown(true); dialog.getDatePicker().setSpinnersShown(false); break; case SPINNER: dialog.getDatePicker().setCalendarViewShown(false); break; } } final DatePicker datePicker = dialog.getDatePicker(); if (args != null && args.containsKey(DatePickerDialogModule.ARG_MINDATE)) { // Set minDate to the beginning of the day. We need this because of clowniness in datepicker // that causes it to throw an exception if minDate is greater than the internal timestamp // that it generates from the y/m/d passed in the constructor. c.setTimeInMillis(args.getLong(DatePickerDialogModule.ARG_MINDATE)); c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); datePicker.setMinDate(c.getTimeInMillis()); } else { // This is to work around a bug in DatePickerDialog where it doesn't display a title showing // the date under certain conditions. datePicker.setMinDate(DEFAULT_MIN_DATE); } if (args != null && args.containsKey(DatePickerDialogModule.ARG_MAXDATE)) { // Set maxDate to the end of the day, same reason as for minDate. c.setTimeInMillis(args.getLong(DatePickerDialogModule.ARG_MAXDATE)); c.set(Calendar.HOUR_OF_DAY, 23); c.set(Calendar.MINUTE, 59); c.set(Calendar.SECOND, 59); c.set(Calendar.MILLISECOND, 999); datePicker.setMaxDate(c.getTimeInMillis()); } return dialog; }
From source file:com.simplaapliko.trips.presentation.fragment.SelectDateDialog.java
@NonNull @Override/*from ww w .ja va 2s . c om*/ public Dialog onCreateDialog(Bundle savedInstanceState) { final DatePickerDialog pickerDialog = new DatePickerDialog(getActivity(), this, mCalendar.get(Calendar.YEAR), mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DATE)); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { pickerDialog.getDatePicker().setCalendarViewShown(false); } pickerDialog.setOnKeyListener((dialog, keyCode, event) -> { switch (keyCode) { case KeyEvent.KEYCODE_BACK: dialog.cancel(); dialog.dismiss(); return true; default: return false; } }); return pickerDialog; }