use of com.codetroopers.betterpickers.calendardatepicker.CalendarDatePickerDialogFragment in project android-betterpickers by code-troopers.
the class SampleCalendarDateRange method onResume.
@Override
public void onResume() {
// Example of reattaching to the fragment
super.onResume();
CalendarDatePickerDialogFragment calendarDatePickerDialogFragment = (CalendarDatePickerDialogFragment) getSupportFragmentManager().findFragmentByTag(FRAG_TAG_DATE_PICKER);
if (calendarDatePickerDialogFragment != null) {
calendarDatePickerDialogFragment.setOnDateSetListener(this);
}
}
use of com.codetroopers.betterpickers.calendardatepicker.CalendarDatePickerDialogFragment in project android-betterpickers by code-troopers.
the class SampleCalendarDateRange method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.text_and_button);
mResultTextView = (TextView) findViewById(R.id.text);
Button button = (Button) findViewById(R.id.button);
mResultTextView.setText(R.string.no_value);
button.setText(R.string.calendar_date_picker_set);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DateTime now = DateTime.now();
MonthAdapter.CalendarDay minDate = new MonthAdapter.CalendarDay(now.getYear(), now.getMonthOfYear() - 2, now.getDayOfMonth());
MonthAdapter.CalendarDay maxDate = new MonthAdapter.CalendarDay(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth());
CalendarDatePickerDialogFragment cdp = new CalendarDatePickerDialogFragment().setDateRange(minDate, maxDate).setOnDateSetListener(SampleCalendarDateRange.this);
cdp.show(getSupportFragmentManager(), FRAG_TAG_DATE_PICKER);
}
});
}
use of com.codetroopers.betterpickers.calendardatepicker.CalendarDatePickerDialogFragment in project android-betterpickers by code-troopers.
the class SampleCalendarDateRangeAndDisabledDays method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.text_and_button);
mResultTextView = (TextView) findViewById(R.id.text);
Button button = (Button) findViewById(R.id.button);
mResultTextView.setText(R.string.no_value);
button.setText(R.string.calendar_date_picker_set);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DateTime now = DateTime.now();
MonthAdapter.CalendarDay minDate = new MonthAdapter.CalendarDay(now.getYear(), now.getMonthOfYear() - 2, now.getDayOfMonth());
MonthAdapter.CalendarDay maxDate = new MonthAdapter.CalendarDay(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth());
// Initialize disabled days list
// Disabled days are located at a formatted location in the format "yyyyMMdd"
SparseArray<MonthAdapter.CalendarDay> disabledDays = new SparseArray<>();
Calendar startCal = Calendar.getInstance();
startCal.setTimeInMillis(minDate.getDateInMillis());
Calendar endCal = Calendar.getInstance();
endCal.setTimeInMillis(maxDate.getDateInMillis());
// Add all weekend days within range to disabled days
while (startCal.before(endCal)) {
if (startCal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || startCal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
int key = Utils.formatDisabledDayForKey(startCal.get(Calendar.YEAR), startCal.get(Calendar.MONTH), startCal.get(Calendar.DAY_OF_MONTH));
disabledDays.put(key, new MonthAdapter.CalendarDay(startCal));
}
startCal.add(Calendar.DATE, 1);
}
CalendarDatePickerDialogFragment cdp = new CalendarDatePickerDialogFragment().setDateRange(minDate, maxDate).setDisabledDays(disabledDays).setOnDateSetListener(SampleCalendarDateRangeAndDisabledDays.this);
cdp.show(getSupportFragmentManager(), FRAG_TAG_DATE_PICKER);
}
});
}
use of com.codetroopers.betterpickers.calendardatepicker.CalendarDatePickerDialogFragment in project android-betterpickers by code-troopers.
the class SampleCalendarDateRangeAndDisabledDays method onResume.
@Override
public void onResume() {
// Example of reattaching to the fragment
super.onResume();
CalendarDatePickerDialogFragment calendarDatePickerDialogFragment = (CalendarDatePickerDialogFragment) getSupportFragmentManager().findFragmentByTag(FRAG_TAG_DATE_PICKER);
if (calendarDatePickerDialogFragment != null) {
calendarDatePickerDialogFragment.setOnDateSetListener(this);
}
}
use of com.codetroopers.betterpickers.calendardatepicker.CalendarDatePickerDialogFragment in project android-betterpickers by code-troopers.
the class SampleCalendarDateRangeMax method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.text_and_button);
mResultTextView = (TextView) findViewById(R.id.text);
Button button = (Button) findViewById(R.id.button);
mResultTextView.setText(R.string.no_value);
button.setText(R.string.calendar_date_picker_set);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DateTime now = DateTime.now();
MonthAdapter.CalendarDay maxDate = new MonthAdapter.CalendarDay(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth());
CalendarDatePickerDialogFragment cdp = new CalendarDatePickerDialogFragment().setDateRange(null, maxDate).setOnDateSetListener(SampleCalendarDateRangeMax.this);
cdp.show(getSupportFragmentManager(), FRAG_TAG_DATE_PICKER);
}
});
}
Aggregations