use of com.pangpangzhu.p2papp.test.calendardecorators.DisableDecorator in project GitTest by xiaoxige.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
materialCalendarView = (MaterialCalendarView) findViewById(R.id.materialCalendarView);
disableDecorator = new DisableDecorator(this);
broadDecorator = new BroadDecorator(this);
// 三年前
Calendar mixTime = Calendar.getInstance();
mixTime.add(Calendar.MONTH, -3 * 12);
// 二十年后
Calendar maxTime = Calendar.getInstance();
maxTime.add(Calendar.YEAR, 5);
maxTime.set(Calendar.DAY_OF_MONTH, maxTime.getActualMaximum(Calendar.DAY_OF_MONTH));
materialCalendarView.addDecorators(new DefaultDecorator(this), disableDecorator, broadDecorator, descDecorator, mSelectDecorator);
materialCalendarView.setTopbarVisible(true);
materialCalendarView.setDynamicHeightEnabled(true);
materialCalendarView.setSelectionMode(MaterialCalendarView.SELECTION_MODE_SINGLE);
materialCalendarView.state().edit().setCalendarDisplayMode(CalendarMode.MONTHS).setMinimumDate(mixTime.getTime()).setMaximumDate(maxTime.getTime()).commit();
materialCalendarView.setSelectedDate(CalendarDay.today());
materialCalendarView.invalidateDecorators();
materialCalendarView.setOnDateChangedListener(new OnDateSelectedListener() {
@Override
public void onDateSelected(@NonNull MaterialCalendarView widget, @NonNull CalendarDay date, boolean selected) {
List<CalendarDay> dates = new ArrayList<>();
dates.add(date);
mSelectDecorator.setDays(dates);
descDecorator.setDays(dates);
materialCalendarView.invalidateDecorators();
}
@Override
public void onDisableDateSelected(@NonNull MaterialCalendarView widget, @NonNull CalendarDay date, boolean selected) {
}
});
}
Aggregations