Java Code Examples for android.app.DatePickerDialog#setCanceledOnTouchOutside()
The following examples show how to use
android.app.DatePickerDialog#setCanceledOnTouchOutside() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OBSystemsManager.java From GLEXP-Team-onebillion with Apache License 2.0 | 5 votes |
public Dialog createDateSetDialog(String message, Boolean cancelable, OBUtils.RunLambda completionBlock) { dateSetCompletionBlock = completionBlock; final Calendar calendar = Calendar.getInstance(); DatePickerDialog d = new DatePickerDialog(MainActivity.mainActivity, this, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)); // d.setCancelable(cancelable); d.setCanceledOnTouchOutside(cancelable); // if (message == null) { LinearLayout linearLayout = new LinearLayout(MainActivity.mainActivity.getApplicationContext()); d.requestWindowFeature(Window.FEATURE_NO_TITLE); d.setCustomTitle(linearLayout); } else { d.setMessage(message + "\n"); } // d.setButton(DatePickerDialog.BUTTON_NEGATIVE, null, (DialogInterface.OnClickListener) null); // DatePicker datePicker = d.getDatePicker(); calendar.clear(); calendar.set(2016, Calendar.JANUARY, 1); datePicker.setMinDate(calendar.getTimeInMillis()); calendar.clear(); calendar.set(2020, Calendar.DECEMBER, 31); datePicker.setMaxDate(calendar.getTimeInMillis()); return d; }
Example 2
Source File: OCM_ChildMenu.java From GLEXP-Team-onebillion with Apache License 2.0 | 5 votes |
void showPickDateDialog (final DatePickerDialog.OnDateSetListener listener, Date startDate) { Calendar currentCalendar = Calendar.getInstance(); if (startDate != null) { currentCalendar.setTime(startDate); } final Calendar calendar = currentCalendar; DatePickerDialog d = new DatePickerDialog(MainActivity.mainActivity, listener, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)); // d.setCancelable(false); d.setCanceledOnTouchOutside(false); // LinearLayout linearLayout = new LinearLayout(MainActivity.mainActivity.getApplicationContext()); d.requestWindowFeature(Window.FEATURE_NO_TITLE); d.getWindow().clearFlags(Window.FEATURE_ACTION_BAR); d.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); d.setCustomTitle(linearLayout); // d.setButton(DatePickerDialog.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() { @Override public void onClick (DialogInterface dialog, int which) { // do nothing } }); // DatePicker datePicker = d.getDatePicker(); calendar.clear(); calendar.set(2017, Calendar.JANUARY, 1); datePicker.setMinDate(calendar.getTimeInMillis()); calendar.clear(); calendar.set(2025, Calendar.DECEMBER, 31); datePicker.setMaxDate(calendar.getTimeInMillis()); // d.show(); }
Example 3
Source File: OBSetupMenu.java From GLEXP-Team-onebillion with Apache License 2.0 | 5 votes |
void showPickDateDialog (final DatePickerDialog.OnDateSetListener listener, Date startDate) { Calendar currentCalendar = Calendar.getInstance(); if (startDate != null) { currentCalendar.setTime(startDate); } final Calendar calendar = currentCalendar; DatePickerDialog d = new DatePickerDialog(MainActivity.mainActivity, listener, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)); // d.setCancelable(false); d.setCanceledOnTouchOutside(false); // LinearLayout linearLayout = new LinearLayout(MainActivity.mainActivity.getApplicationContext()); d.requestWindowFeature(Window.FEATURE_NO_TITLE); d.getWindow().clearFlags(Window.FEATURE_ACTION_BAR); d.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); d.setCustomTitle(linearLayout); // d.setButton(DatePickerDialog.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() { @Override public void onClick (DialogInterface dialog, int which) { MainActivity.log("OBSetupMenu:showPickDateDialog:cancelled!"); loadHomeScreen(); } }); // DatePicker datePicker = d.getDatePicker(); calendar.clear(); calendar.set(2017, Calendar.JANUARY, 1); datePicker.setMinDate(calendar.getTimeInMillis()); calendar.clear(); calendar.set(2025, Calendar.DECEMBER, 31); datePicker.setMaxDate(calendar.getTimeInMillis()); // d.show(); }
Example 4
Source File: ListPicturesForNameFragment.java From Augendiagnose with GNU General Public License v2.0 | 4 votes |
@Nullable @Override public final Dialog onCreateDialog(final Bundle savedInstanceState) { int year = getArguments().getInt("Year"); int month = getArguments().getInt("Month"); int date = getArguments().getInt("Date"); int position = getArguments().getInt("position"); final Activity activity = getActivity(); final ListPicturesForNameFragment fragment = ((ListPicturesForNameFragmentHolder) activity) .getListPicturesForNameFragment(); final EyePhotoPair pairToUpdate = fragment.getEyePhotoPairs()[position]; final DatePickerDialog dialog = new DatePickerDialog(getActivity(), null, year, month, date); // Workaround due to Android bug dialog.setCancelable(true); dialog.setCanceledOnTouchOutside(true); dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.button_cancel), (OnClickListener) null); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.button_ok), // new OnClickListener() { @Override public void onClick(final DialogInterface dialogInterface, final int which) { int yearSelected = dialog.getDatePicker().getYear(); int monthOfYear = dialog.getDatePicker().getMonth(); int dayOfMonth = dialog.getDatePicker().getDayOfMonth(); fragment.mPictureDate = new GregorianCalendar(yearSelected, monthOfYear, dayOfMonth); Date newDate = new Date(fragment.mPictureDate.getTimeInMillis()); if (!pairToUpdate.isDateChangeable(newDate)) { DialogUtil.displayError(activity, R.string.message_dialog_cannot_change_date, false, pairToUpdate.getPersonName(), pairToUpdate.getDateDisplayString(DATE_FORMAT), DateUtil.format(newDate, DATE_FORMAT)); return; } boolean success = pairToUpdate.changeDate(newDate); fragment.updateEyePhotoPairs(); if (!success) { DialogUtil.displayError(activity, R.string.message_dialog_failed_to_change_date, false, pairToUpdate.getPersonName(), pairToUpdate.getDateDisplayString(DATE_FORMAT), DateUtil.format(newDate, DATE_FORMAT)); } } }); return dialog; }
Example 5
Source File: DatePickerProxy.java From TiDialogs with MIT License | 4 votes |
private DatePickerDialog getDialog() { DatePickerDialog picker = new DatePickerDialog(this.proxy.getActivity(), new DatePickerDialog.OnDateSetListener() { // when dialog box is closed, below method will be // called. public void onDateSet(DatePicker view, int selectedYear, int selectedMonth, int selectedDay) { year = selectedYear; month = selectedMonth; day = selectedDay; KrollDict data = new KrollDict(); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month); calendar.set(Calendar.DAY_OF_MONTH, day); Date value = calendar.getTime(); data.put("value", value); data.put("year", year); data.put("month", month); data.put("day", day); fireEvent("click", data); } }, year, month, day); picker.setCanceledOnTouchOutside(false); picker.setButton(DialogInterface.BUTTON_POSITIVE, okButtonTitle, picker); picker.setButton(DialogInterface.BUTTON_NEGATIVE, cancelButtonTitle, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { fireEvent("cancel", new KrollDict()); } }); return picker; }