Material-calendarview: DayDecorator with multiple dots

Created on 14 Sep 2015  路  4Comments  路  Source: prolificinteractive/material-calendarview

My goal is to to display multiple coloured dots for different types of events that occur on a particular day, like in the image below:
https://www.dropbox.com/s/yflsbttl0slte4a/calendar.png?dl=0

Even though I can create my own EventDecorator to handle the drawing (that implements DayViewDecorator) there seems to be a flaw in the api design:

//this only allows you to return a boolean to decide whether the decorator view should be drawn or not
@Override
public boolean shouldDecorate(CalendarDay day) {
return dates.contains(day);
}

//when this is eventually called, there is no way for you to know what type/colour of dot to draw
@Override
public void decorate(DayViewFacade view) {
view.addSpan(new DotSpan(7, color));
}

Btw, this may be related to https://github.com/prolificinteractive/material-calendarview/issues/122

Is there a way to solve this ?

Perhaps, if the api also passed back the calendar day to public void decorate(DayViewFacade view) then we could use that to perform our logic?

question

Most helpful comment

I have a task to show text in calendar dates and dots also, but I couldn't find the way to resolve this problem
I don't want multiple dots on one date but I need to show a different color in different Dates with text. if the text is not possible then at least I want to show Span color in different Dates.

How can I deal with this library

https://github.com/prolificinteractive/materialcalendarview/blob/master/docs/DECORATORS.md

I got Dates From server and store in Bean classes and I am converting dates to according library Formate. But the problem is below code.

Please See Below

if(bookingList.get(i).getTimeperiod().equalsIgnoreCase("AM"))
{
String date[] = bookingList.get(i).getDate().split("-");
int year = Integer.parseInt(date[0]);
int monthOfYear = Integer.parseInt(date[1]);
int dayOfMonth = Integer.parseInt(date[2]);
widget.setSelectedDate(CalendarDay.from(year, monthOfYear, dayOfMonth));
widget.addDecorator(new EventDecorator(Color.RED,dates));
}
if(bookingList.get(i).getTimeperiod().equalsIgnoreCase("PM"))
{
String date[] = bookingList.get(i).getDate().split("-");
int year = Integer.parseInt(date[0]);
int monthOfYear = Integer.parseInt(date[1]);
int dayOfMonth = Integer.parseInt(date[2]);
widget.addDecorator(new EventDecorator(Color.BLUE,dates));
}
if(bookingList.get(i).getTimeperiod().equalsIgnoreCase("Full day"))
{
String date[] = bookingList.get(i).getDate().split("-");
int year = Integer.parseInt(date[0]);
int monthOfYear = Integer.parseInt(date[1]);
int dayOfMonth = Integer.parseInt(date[2]);
widget.setSelectedDate(CalendarDay.from(year, monthOfYear, dayOfMonth));
widget.addDecorator(new EventDecorator(Color.YELLOW,dates));
}
According to Code, I got AM, PM, FullDay Strings in JSON and I am changing span color with conditions but At last result of JSON convert my all widget Span color.

All 4 comments

Hey @damianflannery, early on the decorator API allowed you to decorate each day differently, like you are asking for, but it was rather slow and the only way to make it faster was to make it possible to cache decorations. That meant that we couldn't allow decorates to know which dates they were applying decoration to.

What you will have to do is create a new instance of a decorator for each date, or for each combination of dots. You would also need to create your own span to allow for multiple dots. This should still be efficient as long as you don't invalidate decorators frequently, but the burden is on you to make it work.

Someone solved?

I have a task to show text in calendar dates and dots also, but I couldn't find the way to resolve this problem
I don't want multiple dots on one date but I need to show a different color in different Dates with text. if the text is not possible then at least I want to show Span color in different Dates.

How can I deal with this library

https://github.com/prolificinteractive/materialcalendarview/blob/master/docs/DECORATORS.md

I got Dates From server and store in Bean classes and I am converting dates to according library Formate. But the problem is below code.

Please See Below

if(bookingList.get(i).getTimeperiod().equalsIgnoreCase("AM"))
{
String date[] = bookingList.get(i).getDate().split("-");
int year = Integer.parseInt(date[0]);
int monthOfYear = Integer.parseInt(date[1]);
int dayOfMonth = Integer.parseInt(date[2]);
widget.setSelectedDate(CalendarDay.from(year, monthOfYear, dayOfMonth));
widget.addDecorator(new EventDecorator(Color.RED,dates));
}
if(bookingList.get(i).getTimeperiod().equalsIgnoreCase("PM"))
{
String date[] = bookingList.get(i).getDate().split("-");
int year = Integer.parseInt(date[0]);
int monthOfYear = Integer.parseInt(date[1]);
int dayOfMonth = Integer.parseInt(date[2]);
widget.addDecorator(new EventDecorator(Color.BLUE,dates));
}
if(bookingList.get(i).getTimeperiod().equalsIgnoreCase("Full day"))
{
String date[] = bookingList.get(i).getDate().split("-");
int year = Integer.parseInt(date[0]);
int monthOfYear = Integer.parseInt(date[1]);
int dayOfMonth = Integer.parseInt(date[2]);
widget.setSelectedDate(CalendarDay.from(year, monthOfYear, dayOfMonth));
widget.addDecorator(new EventDecorator(Color.YELLOW,dates));
}
According to Code, I got AM, PM, FullDay Strings in JSON and I am changing span color with conditions but At last result of JSON convert my all widget Span color.

mayanksugandhi5 I also wants to bind same values, Any help would be appreciated.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yuanliu666 picture yuanliu666  路  4Comments

fahimk picture fahimk  路  4Comments

chuks picture chuks  路  5Comments

KhanStan99 picture KhanStan99  路  4Comments

Ashtapathy picture Ashtapathy  路  3Comments