I have implemented calendarview using android prolific material calendarview external library in my android application. Now I have to add multiple dot indicators below some dates to indicate number of events in each date. I tried but only got single dot below date. Please help
Here are my calendar fragment and decorator classes:
public class CalendarFragment extends Fragment {
private View v;
private List<Schedule> schedules = new ArrayList<Schedule>( );
private MaterialCalendarView calendarView;
public CalendarFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
try {
v = inflater.inflate(R.layout.fragment_calendar, container, false);
initViews();
schedules = ScheduleDAO.getInstance().getScheduleListWithId();
highlightDates(schedules);
} catch (ParseException e) {
e.printStackTrace();
}
return v;
}
private void highlightDates(List<Schedule>scheduleList) throws ParseException {
for (int position = 0;position<scheduleList.size();position++)
{
Schedule schedule = scheduleList.get(position);
if (schedule.getSessionStatus().equals("Incomplete")){
int color = R.color.colorPrimaryDark;
CurrentDayDecorator decorator = new CurrentDayDecorator(new Date(schedule.getScheduledDate()),color);
calendarView.addDecorator(decorator);
}else {
int color = R.color.lightgray;
CurrentDayDecorator decorator = new CurrentDayDecorator(new Date(schedule.getScheduledDate()),color);
calendarView.addDecorator(decorator);
}
}
}
private void initViews() {
calendarView = v.findViewById(R.id.calendarView);
}
}
Decorator class
public class CurrentDayDecorator implements DayViewDecorator {
private final int color;
private final CalendarDay day;
public CurrentDayDecorator(Date date,int color) {
this.color = color;
this.day = CalendarDay.from(date);
}
@Override
public boolean shouldDecorate(CalendarDay day) {
if (this.day.equals(day)){
return true;
}
return false;
}
@Override
public void decorate(DayViewFacade view) {
view.addSpan(new DotSpan(3,color));
}
}