List of usage examples for android.app DatePickerDialog DatePickerDialog
public DatePickerDialog(@NonNull Context context, @Nullable OnDateSetListener listener, int year, int month, int dayOfMonth)
From source file:co.carlosandresjimenez.android.gotit.DatePickerFragment.java
@Override 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 return new DatePickerDialog(getActivity(), this, year - 15, month, day); }
From source file:mobi.daytoday.DayToDay.DatePickerDialogFragment.java
/** * Create and return the date picker dialog *//* ww w . j ava 2s. c om*/ public Dialog onCreateDialog(Bundle arg) { String current = getArguments().getString("curDate"); DateTime dt; if ("".equals(current)) { dt = new DateTime(); Log.v(TAG, "year: " + dt.getYear() + " month: " + dt.getMonthOfYear() + " day: " + dt.getDayOfMonth()); } else { try { dt = DateWrap.parseDate(current); } catch (Exception e) { // just ignore it and use now dt = new DateTime(); } } return new DatePickerDialog(getActivity(), (OnDateSetListener) frag, dt.getYear(), dt.getMonthOfYear() - 1, dt.getDayOfMonth()); }
From source file:ca.mudar.parkcatcher.ui.fragments.DatePickerFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { ((ParkingApp) getActivity().getApplicationContext()).updateUiLanguage(); final GregorianCalendar c = mListener.getParkingCalendar(); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH); int day = c.get(Calendar.DAY_OF_MONTH); return new DatePickerDialog(getActivity(), this, year, month, day); }
From source file:at.jclehner.rxdroid.DatePickerFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Calendar cal; final Bundle args = getArguments(); if (args == null || !args.containsKey(ARG_DATE)) cal = DateTime.nowCalendar();/* w ww . j a v a2s. co m*/ else cal = DateTime.calendarFromDate((Date) args.getSerializable(ARG_DATE)); final int d = cal.get(Calendar.DAY_OF_MONTH); final int m = cal.get(Calendar.MONTH); final int y = cal.get(Calendar.YEAR); if (Version.SDK_IS_JELLYBEAN_OR_NEWER) { // Workaround for Android issue #34833 final Dialog dialog = new DatePickerDialog(getActivity(), null, y, m, d); dialog.setOnShowListener(this); return dialog; } else return new DatePickerDialog(getActivity(), mListener, y, m, d); }
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!"); }// w ww .j a va2s . c om 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:org.gnucash.android.ui.util.dialog.DatePickerDialogFragment.java
/** * Creates and returns an Android {@link DatePickerDialog} *//*w w w.j a va 2 s . co m*/ @Override public Dialog onCreateDialog(Bundle savedInstanceState) { Calendar cal = mDate == null ? Calendar.getInstance() : mDate; return new DatePickerDialog(getActivity(), mDateSetListener, cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH)); }
From source file:eu.iescities.pilot.rovereto.roveretoexplorer.fragments.event.info.edit.DatePickerDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Calendar c = Calendar.getInstance(); if (getArguments() != null && getArguments().containsKey(DATA)) { try {//w ww . j a v a 2s. c o m Date d = Utils.FORMAT_DATE_UI_LONG.parse((String) getArguments().getString(DATA)); c.setTime(d); } catch (Exception e) { } } if (getDateEditText().getTag() != null) { c.setTime((Date) getDateEditText().getTag()); } // Use the current date as the default date in the picker 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 return new DatePickerDialog(getActivity(), this, year, month, day); }
From source file:com.example.michael.paradis2_habittracker.DatePickerFragment.java
@NonNull @Override//from ww w . j a v a 2 s . com 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 return new DatePickerDialog(getActivity(), this, year, month, day); }
From source file:org.gnucash.android.ui.chart.ChartDatePickerFragment.java
/** * {@inheritDoc}//from ww w. ja va2s . c om */ @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { DatePickerDialog dialog = new DatePickerDialog(getActivity(), callback, mCalendar.get(Calendar.YEAR), mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH)); try { Field datePickerField = dialog.getClass().getDeclaredField("mDatePicker"); datePickerField.setAccessible(true); DatePicker datePicker = (DatePicker) datePickerField.get(dialog); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { datePicker.setMinDate(minDate); datePicker.setMaxDate(maxDate); } for (Field field : datePicker.getClass().getDeclaredFields()) { if (field.getName().equals("mDaySpinner") || field.getName().equals("mDayPicker")) { field.setAccessible(true); ((View) field.get(datePicker)).setVisibility(View.GONE); } } } catch (Exception e) { Log.w(TAG, e.getMessage()); } return dialog; }
From source file:planets.position.DateTimeDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { int id = getArguments().getInt("id"); int hour = getArguments().getInt("hour"); int min = getArguments().getInt("min"); int month = getArguments().getInt("month"); int day = getArguments().getInt("day"); int year = getArguments().getInt("year"); if (id == 0) { // time dialog return new TimePickerDialog(getActivity(), mTimeSetListener, hour, min, false); } else {//from w ww. j a va 2 s . c o m // date dialog return new DatePickerDialog(getActivity(), mDateSetListener, year, month, day); } }