android.app.DatePickerDialog Java Examples

The following examples show how to use android.app.DatePickerDialog. 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: TypeFaceActivity.java    From DynamicCalendar with Apache License 2.0 7 votes vote down vote up
@Override
public void onClick(View v) {
    mCurrentDate = Calendar.getInstance();
    int mYear = mCurrentDate.get(Calendar.YEAR);
    int mMonth = mCurrentDate.get(Calendar.MONTH);
    int mDay = mCurrentDate.get(Calendar.DAY_OF_MONTH);

    DatePickerDialog mDatePicker = new DatePickerDialog(TypeFaceActivity.this, new DatePickerDialog.OnDateSetListener() {
        public void onDateSet(DatePicker datepicker, int selectedYear, int selectedMonth, int selectedDay) {
            // Update the editText to display the selected date
            mDateEditText.setText(selectedDay + "-" + (selectedMonth + 1) + "-" + selectedYear);

            // Set the mCurrentDate to the selected date-month-year
            mCurrentDate.set(selectedYear, selectedMonth, selectedDay);
            mGeneratedDateIcon = mImageGenerator.generateDateImage(mCurrentDate, R.drawable.empty_calendar);
            mDisplayGeneratedImage.setImageBitmap(mGeneratedDateIcon);

        }
    }, mYear, mMonth, mDay);
    mDatePicker.show();
}
 
Example #2
Source File: AdapterFilters.java    From fingen with Apache License 2.0 7 votes vote down vote up
@Override
public void onClick(View v) {
    int id = 0;
    Calendar calendar = Calendar.getInstance();
    switch (v.getId()) {
        case R.id.edit_text_start_date:
            calendar.setTime(((DateRangeFilter) getFilter()).getmStartDate());
            id = 0;
            break;
        case R.id.edit_text_end_date:
            calendar.setTime(((DateRangeFilter) getFilter()).getmEndDate());
            id = 1;
            break;
    }

    DatePickerDialog dpd = new DatePickerDialog(mActivity,
            vh,
            calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)
    );
    dateType = id;

    dpd.show();
}
 
Example #3
Source File: StatisticsActivity.java    From ActivityDiary with GNU General Public License v3.0 6 votes vote down vote up
public void showDatePickerDialog(View v) {
    HistoryDetailActivity.DatePickerFragment newFragment = new HistoryDetailActivity.DatePickerFragment();
    Calendar date = Calendar.getInstance();
    date.setTimeInMillis(currentDateTime);
    newFragment.setData(new DatePickerDialog.OnDateSetListener (){
                            @Override
                            public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
                                date.set(Calendar.YEAR, year);
                                date.set(Calendar.MONTH, month);
                                date.set(Calendar.DAY_OF_MONTH, dayOfMonth);
                                currentDateTime = date.getTimeInMillis();
                                currentOffset = 0;
                                loadRange(currentRange, currentOffset);
                            }
                        }
            , date.get(Calendar.YEAR), date.get(Calendar.MONTH), date.get(Calendar.DAY_OF_MONTH));
    newFragment.show(getSupportFragmentManager(), "startDatePicker");
}
 
Example #4
Source File: TextNoteActivity.java    From privacy-friendly-notes with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onMenuItemClick(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.action_reminder_edit) {
        final Calendar c = Calendar.getInstance();
        c.setTimeInMillis(notificationCursor.getLong(notificationCursor.getColumnIndexOrThrow(DbContract.NotificationEntry.COLUMN_TIME)));
        int year = c.get(Calendar.YEAR);
        int month = c.get(Calendar.MONTH);
        int day = c.get(Calendar.DAY_OF_MONTH);
        DatePickerDialog dpd = new DatePickerDialog(TextNoteActivity.this, this, year, month, day);
        dpd.getDatePicker().setMinDate(new Date().getTime());
        dpd.show();
        return true;
    } else if (id == R.id.action_reminder_delete) {
        cancelNotification();
        return true;
    }
    return false;
}
 
Example #5
Source File: DatePicker.java    From react-native-date with MIT License 6 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    int year = mInitialDate.get(Calendar.YEAR);
    int month = mInitialDate.get(Calendar.MONTH);
    int day = mInitialDate.get(Calendar.DAY_OF_MONTH);

    DatePickerDialog picker = new DatePickerDialog(getActivity(), this, year, month, day);

    if (mMinDate != null) {
        picker.getDatePicker().setMinDate(mMinDate.getTimeInMillis());
    }

    if (mMaxDate != null) {
        picker.getDatePicker().setMaxDate(mMaxDate.getTimeInMillis());
    }

    return picker;
}
 
Example #6
Source File: NetworkUsageStatsFragment.java    From android-testdpc with Apache License 2.0 6 votes vote down vote up
private void pickDate(final Date target) {
    final Calendar calendar = Calendar.getInstance();
    calendar.setTime(target);
    DatePickerDialog dialog = new DatePickerDialog(getActivity(),
            new DatePickerDialog.OnDateSetListener() {
                @Override
                public void onDateSet(DatePicker view, int year, int monthOfYear,
                        int dayOfMonth) {
                    calendar.set(Calendar.YEAR, year);
                    calendar.set(Calendar.MONTH, monthOfYear);
                    calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
                    target.setTime(calendar.getTimeInMillis());
                    updateButtonsText();
                }
            }, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
            calendar.get(Calendar.DAY_OF_MONTH));
    dialog.show();
}
 
Example #7
Source File: DatePickerFragment.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
@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 #8
Source File: AudioNoteActivity.java    From privacy-friendly-notes with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onMenuItemClick(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.action_reminder_edit) {
        final Calendar c = Calendar.getInstance();
        c.setTimeInMillis(notificationCursor.getLong(notificationCursor.getColumnIndexOrThrow(DbContract.NotificationEntry.COLUMN_TIME)));
        int year = c.get(Calendar.YEAR);
        int month = c.get(Calendar.MONTH);
        int day = c.get(Calendar.DAY_OF_MONTH);
        DatePickerDialog dpd = new DatePickerDialog(AudioNoteActivity.this, this, year, month, day);
        dpd.getDatePicker().setMinDate(new Date().getTime());
        dpd.show();
        return true;
    } else if (id == R.id.action_reminder_delete) {
        cancelNotification();
        return true;
    }
    return false;
}
 
Example #9
Source File: DatePickerFragmentDialog.java    From RetainedDateTimePickers with Apache License 2.0 6 votes vote down vote up
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) {
    setupArguments(savedInstanceState);
    final Calendar calendar = Calendar.getInstance();
    if (builder.getSelectedDate() != 0) {
        calendar.setTimeInMillis(builder.getSelectedDate());
    }
    DatePickerDialog datePickerDialog = new DatePickerDialog(getContext(), builder.getThemeResId(), this, calendar.get(Calendar.YEAR),
            calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));
    if (builder.getMinDate() != 0) {
        datePickerDialog.getDatePicker().setMinDate(builder.getMinDate());
    }
    if (builder.getMaxDate() != 0) {
        datePickerDialog.getDatePicker().setMaxDate(builder.getMaxDate());
    }
    return datePickerDialog;
}
 
Example #10
Source File: OrganizeNewPhotosActivity.java    From Augendiagnose with GNU General Public License v2.0 6 votes vote down vote up
@NonNull
@Override
public final Dialog onCreateDialog(final Bundle savedInstanceState) {
	int year = getArguments().getInt("Year");
	int month = getArguments().getInt("Month");
	int date = getArguments().getInt("Date");

	DatePickerDialog.OnDateSetListener dateSetListener = new DatePickerDialog.OnDateSetListener() {
		@Override
		public void onDateSet(final DatePicker view, final int yearSelected, final int monthOfYear,
							  final int dayOfMonth) {
			((OrganizeNewPhotosActivity) getActivity()).setDate(yearSelected, monthOfYear, dayOfMonth);
		}
	};
	return new DatePickerDialog(getActivity(), dateSetListener, year, month, date);
}
 
Example #11
Source File: ChecklistNoteActivity.java    From privacy-friendly-notes with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onMenuItemClick(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.action_reminder_edit) {
        final Calendar c = Calendar.getInstance();
        c.setTimeInMillis(notificationCursor.getLong(notificationCursor.getColumnIndexOrThrow(DbContract.NotificationEntry.COLUMN_TIME)));
        int year = c.get(Calendar.YEAR);
        int month = c.get(Calendar.MONTH);
        int day = c.get(Calendar.DAY_OF_MONTH);
        DatePickerDialog dpd = new DatePickerDialog(ChecklistNoteActivity.this, this, year, month, day);
        dpd.getDatePicker().setMinDate(new Date().getTime());
        dpd.show();
        return true;
    } else if (id == R.id.action_reminder_delete) {
        cancelNotification();
        return true;
    }
    return false;
}
 
Example #12
Source File: DatePickerFragment.java    From outlay with Apache License 2.0 6 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    //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);

    DatePickerDialog dialog = new DatePickerDialog(getActivity(), app.outlay.R.style.DatePicker, this, year, month, day);
    if (DeviceUtils.supportV5()) {
        dialog.getDatePicker().setFirstDayOfWeek(Calendar.MONDAY);
    } else {
        //dialog.getDatePicker().getCalendarView().setFirstDayOfWeek(Calendar.MONDAY);
    }
    return dialog;
}
 
Example #13
Source File: DatePickerFragment.java    From three-things-today with Apache License 2.0 6 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    DatePickerDialog dialog = new DatePickerDialog(getActivity(), mOnDateSetListener,
            mInitialYear, mInitialMonth, mInitialDayOfMonth);

    // Disallow future dates. For Lollipop, we need to set the timestamp to the last second
    // of the last allowed day, or that day will be visible but not selectable.
    // TODO(smcgruer): I don't think this actually works. Need to test on real device.
    final Calendar maxCal = Calendar.getInstance();
    maxCal.set(Calendar.HOUR, 23);
    maxCal.set(Calendar.MINUTE, 59);
    maxCal.set(Calendar.SECOND, 59);
    dialog.getDatePicker().setMaxDate(maxCal.getTimeInMillis());

    return dialog;
}
 
Example #14
Source File: SampleFragment.java    From LocaleChanger with Apache License 2.0 6 votes vote down vote up
@OnClick(R.id.showDatePicker)
void onShowDatePickerClick() {
    Calendar now = Calendar.getInstance();

    DatePickerDialog dialog = new DatePickerDialog(
            getActivity(),
            new DatePickerDialog.OnDateSetListener() {
                @Override
                public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                }
            },
            now.get(Calendar.YEAR),
            now.get(Calendar.MONTH),
            now.get(Calendar.DAY_OF_MONTH));

    dialog.show();
}
 
Example #15
Source File: HistoryDetailActivity.java    From ActivityDiary with GNU General Public License v3.0 6 votes vote down vote up
public void showStartDatePickerDialog(View v) {
    DatePickerFragment newFragment = new DatePickerFragment();
    newFragment.setData(new DatePickerDialog.OnDateSetListener (){
                            @Override
                            public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
                                start.set(Calendar.YEAR, year);
                                start.set(Calendar.MONTH, month);
                                start.set(Calendar.DAY_OF_MONTH, dayOfMonth);

                                Long newStart = Long.valueOf(start.getTimeInMillis());
                                updateValues.put(ActivityDiaryContract.Diary.START, newStart);
                                updateDateTimes();
                            }
                        }
            , start.get(Calendar.YEAR), start.get(Calendar.MONTH), start.get(Calendar.DAY_OF_MONTH));
    newFragment.show(getSupportFragmentManager(), "startDatePicker");
}
 
Example #16
Source File: EditMovieFragment.java    From Mizuu with Apache License 2.0 6 votes vote down vote up
private void showDatePickerDialog(String initialValue) {
    String[] dateArray = initialValue.split("-");
    Calendar cal = Calendar.getInstance();
    cal.set(Integer.parseInt(dateArray[0]), Integer.parseInt(dateArray[1]) - 1, Integer.parseInt(dateArray[2]));
    DatePickerDialog dialog = new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            // Update the date
            mMovie.setReleaseDate(year, monthOfYear + 1, dayOfMonth);

            // Update the UI with the new value
            setupValues(false);
        }
    }, cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));
    dialog.show();
}
 
Example #17
Source File: SellDetailActivity.java    From alpha-wallet-android with MIT License 6 votes vote down vote up
private void initDatePicker() {
    String dateFormat = "dd/MM/yyyy";
    Calendar newCalendar = Calendar.getInstance();
    SimpleDateFormat dateFormatter = new SimpleDateFormat(dateFormat, Locale.ENGLISH);

    datePickerDialog = new DatePickerDialog(this, (view, year, monthOfYear, dayOfMonth) -> {
        Calendar newDate = Calendar.getInstance();
        newDate.set(year, monthOfYear, dayOfMonth);
        expiryDateEditText.setText(dateFormatter.format(newDate.getTime()));
    }, newCalendar.get(Calendar.YEAR), newCalendar.get(Calendar.MONTH), newCalendar.get(Calendar.DAY_OF_MONTH));

    //set default for tomorrow
    long tomorrowStamp = System.currentTimeMillis() + 1000*60*60*24;
    Date tomorrow = new Date(tomorrowStamp);
    expiryDateEditText.setText(dateFormatter.format(tomorrow.getTime()));
}
 
Example #18
Source File: UIApi.java    From quickhybrid-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * 弹出日期选择对话框
 * <p>
 * 参数:
 * title: 标题
 * datetime: 指定日期 yyyy-MM-dd
 * 返回:
 * date: 格式:yyyy-MM-dd
 */
public static void pickDate(final IQuickFragment webLoader, WebView wv, JSONObject param, final Callback callback) {
    final String title = param.optString("title");
    String date = param.optString("datetime");
    final Calendar calendar = Calendar.getInstance();
    if (!TextUtils.isEmpty(date)) {
        calendar.setTime(DateUtil.convertString2Date(date, "yyyy-MM-dd"));
    }
    wv.post(new Runnable() {
        public void run() {
            DialogUtil.pickDate(webLoader.getPageControl().getActivity(), title, calendar, new DatePickerDialog.OnDateSetListener() {
                @Override
                public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                    calendar.set(Calendar.YEAR, year);
                    calendar.set(Calendar.MONTH, monthOfYear);
                    calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
                    String chooseDate = DateUtil.convertDate(calendar.getTime(), "yyyy-MM-dd");
                    Map<String, Object> map = new HashMap<>();
                    map.put("date", chooseDate);
                    callback.applySuccess(map);
                }
            });
        }
    });
}
 
Example #19
Source File: ActivityImportSms.java    From fingen with Apache License 2.0 6 votes vote down vote up
@OnClick({R.id.editTextStartDate, R.id.editTextEndDate})
public void onDateClick(View view) {
    Calendar calendar = Calendar.getInstance();
    switch (view.getId()) {
        case R.id.editTextStartDate:
            calendar.setTime(mStartDate);
            break;
        case R.id.editTextEndDate:
            calendar.setTime(mEndDate);
            break;
    }
    calendar.setTime(mStartDate);
    dateType = view.getId();
    new DatePickerDialog(this,
            this,
            calendar.get(Calendar.YEAR),
            calendar.get(Calendar.MONTH),
            calendar.get(Calendar.DAY_OF_MONTH)
    ).show();
}
 
Example #20
Source File: CompetitionCreatorActivity.java    From 1Rramp-Android with MIT License 6 votes vote down vote up
private void showDatePicker(String msg, final EditText targetInput) {
  final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT+0"));
  int mYear = c.get(Calendar.YEAR);
  int mMonth = c.get(Calendar.MONTH);
  int mDay = c.get(Calendar.DAY_OF_MONTH);
  DatePickerDialog datePickerDialog = new DatePickerDialog(this,
    new DatePickerDialog.OnDateSetListener() {

      @Override
      public void onDateSet(DatePicker view, int year,
                            int monthOfYear, int dayOfMonth) {
        if (targetInput != null) {
          targetInput.setText(String.format(Locale.US, "%02d-%02d-%02d", year, 1 + monthOfYear, dayOfMonth));
        }
      }
    }, mYear, mMonth, mDay);
  datePickerDialog.setMessage(msg);
  datePickerDialog.getDatePicker().setMinDate(System.currentTimeMillis());
  datePickerDialog.show();
}
 
Example #21
Source File: SampleActivity.java    From LocaleChanger with Apache License 2.0 6 votes vote down vote up
@OnClick(R.id.showDatePicker)
void onShowDatePickerClick() {
    Calendar now = Calendar.getInstance();

    DatePickerDialog dialog = new DatePickerDialog(
            SampleActivity.this,
            new DatePickerDialog.OnDateSetListener() {
                @Override
                public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                }
            },
            now.get(Calendar.YEAR),
            now.get(Calendar.MONTH),
            now.get(Calendar.DAY_OF_MONTH));

    dialog.show();
}
 
Example #22
Source File: EventCaptureActivity.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void showNativeCalendar() {
    Calendar calendar = DateUtils.getInstance().getCalendar();
    DatePickerDialog datePickerDialog = new DatePickerDialog(this, (view, year, month, dayOfMonth) -> {
        Calendar chosenDate = Calendar.getInstance();
        chosenDate.set(year, month, dayOfMonth);
        presenter.rescheduleEvent(chosenDate.getTime());
    }, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        datePickerDialog.setButton(DialogInterface.BUTTON_NEUTRAL, getContext().getResources().getString(R.string.change_calendar), (dialog, which) -> {
            datePickerDialog.dismiss();
            showCustomCalendar();
        });
    }

    datePickerDialog.show();
}
 
Example #23
Source File: RuleViewModel.java    From Jockey with Apache License 2.0 5 votes vote down vote up
private void showDateValueDialog() {
    // Calculate the date stored in the reference
    Calendar currentDate = Calendar.getInstance();
    try {
        long timestamp = Long.parseLong(mFactory.getValue());
        currentDate.setTimeInMillis(timestamp * 1000L);
    } catch (NumberFormatException ignored) {
        // If the reference's value isn't valid, just use the current time as the
        // selected date
        currentDate.setTimeInMillis(System.currentTimeMillis());
    }

    DatePickerDialog dateDialog = new DatePickerDialog(mContext,
            (view, year, monthOfYear, dayOfMonth) -> {
                Calendar nextDate = Calendar.getInstance();
                nextDate.set(year, monthOfYear, dayOfMonth);
                mFactory.setValue(Long.toString(nextDate.getTimeInMillis() / 1000L));

                apply();
                notifyPropertyChanged(BR.valueText);
            },
            currentDate.get(Calendar.YEAR),
            currentDate.get(Calendar.MONTH),
            currentDate.get(Calendar.DAY_OF_MONTH));

    dateDialog.show();
}
 
Example #24
Source File: DatePickerDialogFragment.java    From white-label-event-app with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    return new DatePickerDialog(
        getActivity(),
        this,
        year,
        month,
        dayOfMonth
    );
}
 
Example #25
Source File: DatePickerFragmentActivity.java    From coursera-android with MIT License 5 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

	// Set the current date in the DatePickerFragment
	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);

}
 
Example #26
Source File: DatePickerDialogFragment.java    From fastnfitness with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
static public DatePickerDialogFragment newInstance(DatePickerDialog.OnDateSetListener onDateSetListener) {
    DatePickerDialogFragment pickerFragment = new DatePickerDialogFragment();
    pickerFragment.setOnDateSetListener(onDateSetListener);

    //Pass the date in a bundle.
    Bundle bundle = new Bundle();
    pickerFragment.setArguments(bundle);
    return pickerFragment;
}
 
Example #27
Source File: OCM_ChildMenu.java    From GLEXP-Team-onebillion with Apache License 2.0 5 votes vote down vote up
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 #28
Source File: DatePickerDialogFragment.java    From fastnfitness with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    super.onCreateDialog(savedInstanceState);

    Calendar cal = Calendar.getInstance();
    return new DatePickerDialog(getActivity(),
        onDateSetListener,
        cal.get(Calendar.YEAR),
        cal.get(Calendar.MONTH),
        cal.get(Calendar.DAY_OF_MONTH));
}
 
Example #29
Source File: OBSystemsManager.java    From GLEXP-Team-onebillion with Apache License 2.0 5 votes vote down vote up
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 #30
Source File: DilbertFragmentActivity.java    From Simple-Dilbert with Apache License 2.0 5 votes vote down vote up
private void showDatePicker() {
    Calendar c = Calendar.getInstance();
    c.setTime(adapter.getDateForPosition(viewPager.getCurrentItem())
            .toDate());
    DatePickerDialog dialog = new DatePickerDialog(this,
            dilbertOnDateSetListener, c.get(Calendar.YEAR),
            c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH));
    dialog.show();
}