Java Code Examples for android.app.DatePickerDialog#setTitle()
The following examples show how to use
android.app.DatePickerDialog#setTitle() .
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: DatePickerFragment.java From xDrip with GNU General Public License v3.0 | 6 votes |
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the current date as the default date in the picker final Calendar c = Calendar.getInstance(); if (initial != -1) { c.setTimeInMillis(initial); } 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 dp = new DatePickerDialog(getActivity(), this, year, month, day); if (title != null) dp.setTitle(title); if (!allow_future) dp.getDatePicker().setMaxDate(System.currentTimeMillis()); if (earliest > -1) dp.getDatePicker().setMinDate(earliest); return dp; }
Example 2
Source File: DatePickerFragment.java From xDrip-plus with GNU General Public License v3.0 | 6 votes |
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the current date as the default date in the picker final Calendar c = Calendar.getInstance(); if (initial != -1) { c.setTimeInMillis(initial); } 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 dp = new DatePickerDialog(getActivity(), this, year, month, day); if (title != null) dp.setTitle(title); if (!allow_future) dp.getDatePicker().setMaxDate(System.currentTimeMillis()); if (earliest > -1) dp.getDatePicker().setMinDate(earliest); return dp; }
Example 3
Source File: DatePickerFragment.java From android-player-samples with Apache License 2.0 | 6 votes |
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the current date as the default date in the picker final Calendar calendar = Calendar.getInstance(); int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH); int day = calendar.get(Calendar.DAY_OF_MONTH); Activity activity = getActivity(); DatePickerDialog dialog = new DatePickerDialog(activity, R.style.DialogWithTitle, onDateSetListener, year, month, day); if (title != null) { dialog.setTitle(title); } return dialog; }
Example 4
Source File: SystemUpdatePolicyFragment.java From android-testdpc with Apache License 2.0 | 5 votes |
@RequiresApi(api = VERSION_CODES.O) private void showDatePicker(LocalDate hint, int titleResId, DatePickResult resultCallback) { DatePickerDialog picker = new DatePickerDialog(getActivity(), (pickerObj, year, month, day) -> { final LocalDate pickedDate = LocalDate.of(year, month + 1, day); resultCallback.onResult(pickedDate); }, hint.getYear(), hint.getMonth().getValue() - 1, hint.getDayOfMonth()); picker.setTitle(getString(titleResId)); picker.show(); }
Example 5
Source File: SearchTEPresenter.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void showNativeCalendar(OrganisationUnit selectedOrgUnit, String programUid, String uid) { Calendar c = Calendar.getInstance(); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH); int day = c.get(Calendar.DAY_OF_MONTH); DatePickerDialog dateDialog = new DatePickerDialog(view.getContext(), ( (datePicker, year1, month1, day1) -> { Calendar selectedCalendar = Calendar.getInstance(); selectedCalendar.set(Calendar.YEAR, year1); selectedCalendar.set(Calendar.MONTH, month1); selectedCalendar.set(Calendar.DAY_OF_MONTH, day1); selectedCalendar.set(Calendar.HOUR_OF_DAY, 0); selectedCalendar.set(Calendar.MINUTE, 0); selectedCalendar.set(Calendar.SECOND, 0); selectedCalendar.set(Calendar.MILLISECOND, 0); selectedEnrollmentDate = selectedCalendar.getTime(); enrollInOrgUnit(selectedOrgUnit.uid(), programUid, uid, selectedEnrollmentDate); }), year, month, day); if (selectedOrgUnit.openingDate() != null) dateDialog.getDatePicker().setMinDate(selectedOrgUnit.openingDate().getTime()); if (selectedOrgUnit.closedDate() == null && !selectedProgram.selectEnrollmentDatesInFuture()) { dateDialog.getDatePicker().setMaxDate(System.currentTimeMillis()); } else if (selectedOrgUnit.closedDate() != null && !selectedProgram.selectEnrollmentDatesInFuture()) { if (selectedOrgUnit.closedDate().before(new Date(System.currentTimeMillis()))) { dateDialog.getDatePicker().setMaxDate(selectedOrgUnit.closedDate().getTime()); } else { dateDialog.getDatePicker().setMaxDate(System.currentTimeMillis()); } } else if (selectedOrgUnit.closedDate() != null && selectedProgram.selectEnrollmentDatesInFuture()) { dateDialog.getDatePicker().setMaxDate(selectedOrgUnit.closedDate().getTime()); } dateDialog.setTitle(selectedProgram.enrollmentDateLabel()); dateDialog.setButton(DialogInterface.BUTTON_NEGATIVE, view.getContext().getString(R.string.date_dialog_clear), (dialog, which) -> { dialog.dismiss(); }); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { dateDialog.setButton(DialogInterface.BUTTON_NEUTRAL, view.getContext().getResources().getString(R.string.change_calendar), (dialog, which) -> { dateDialog.dismiss(); showCustomCalendar(selectedOrgUnit, programUid, uid); }); } dateDialog.show(); }
Example 6
Source File: TeiProgramListInteractor.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void showNativeCalendar(String programUid, String uid, OrgUnitDialog orgUnitDialog) { Calendar c = Calendar.getInstance(); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH); int day = c.get(Calendar.DAY_OF_MONTH); DatePickerDialog dateDialog = new DatePickerDialog(view.getContext(), ( (datePicker, year1, month1, day1) -> { Calendar selectedCalendar = Calendar.getInstance(); selectedCalendar.set(Calendar.YEAR, year1); selectedCalendar.set(Calendar.MONTH, month1); selectedCalendar.set(Calendar.DAY_OF_MONTH, day1); selectedCalendar.set(Calendar.HOUR_OF_DAY, 0); selectedCalendar.set(Calendar.MINUTE, 0); selectedCalendar.set(Calendar.SECOND, 0); selectedCalendar.set(Calendar.MILLISECOND, 0); selectedEnrollmentDate = selectedCalendar.getTime(); compositeDisposable.add(getOrgUnits(programUid) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe( allOrgUnits -> { ArrayList<OrganisationUnit> orgUnits = new ArrayList<>(); for (OrganisationUnit orgUnit : allOrgUnits) { boolean afterOpening = false; boolean beforeClosing = false; if (orgUnit.openingDate() == null || !selectedEnrollmentDate.before(orgUnit.openingDate())) afterOpening = true; if (orgUnit.closedDate() == null || !selectedEnrollmentDate.after(orgUnit.closedDate())) beforeClosing = true; if (afterOpening && beforeClosing) orgUnits.add(orgUnit); } if (orgUnits.size() > 1) { orgUnitDialog.setOrgUnits(orgUnits); if (!orgUnitDialog.isAdded()) orgUnitDialog.show(view.getAbstracContext().getSupportFragmentManager(), "OrgUnitEnrollment"); } else enrollInOrgUnit(orgUnits.get(0).uid(), programUid, uid, selectedEnrollmentDate); }, Timber::d ) ); }), year, month, day); Program selectedProgram = getProgramFromUid(programUid); if (selectedProgram != null && !selectedProgram.selectEnrollmentDatesInFuture()) { dateDialog.getDatePicker().setMaxDate(System.currentTimeMillis()); } if (selectedProgram != null) { dateDialog.setTitle(selectedProgram.enrollmentDateLabel()); } dateDialog.setButton(DialogInterface.BUTTON_NEGATIVE, view.getContext().getString(R.string.date_dialog_clear), (dialog, which) -> { dialog.dismiss(); }); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { dateDialog.setButton(DialogInterface.BUTTON_NEUTRAL, view.getContext().getResources().getString(R.string.change_calendar), (dialog, which) -> { dateDialog.dismiss(); showCustomCalendar(programUid, uid, orgUnitDialog); }); } dateDialog.show(); }