question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple Decorators with different colours

See original GitHub issue

Hey there,

I want to set the background of some dates to different color. For example I want to set the background of the 20.7.17 and of the 24.7.17 to red and the background of the 26. and 30. to green. I tried to do this with multiple decorators, but they only color the dates in one color. Is there a possibility to do this ?asd

I used addDecorators and my decorator class looks like this:

private final int mColor;
private final HashSet<CalendarDay> dates;
private Context mContext;

EventDecorator(int color, Collection<CalendarDay> dates, Context context) {
    this.mColor = color;
    this.dates = new HashSet<>(dates);
    this.mContext = context;
}

@Override
public boolean shouldDecorate(CalendarDay day) {
    return dates.contains(day);
}

@Override
public void decorate(DayViewFacade view) {
    GradientDrawable drawable = (GradientDrawable) ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.circle, null);
    if (drawable != null) {
        drawable.setColor(mColor);
        view.setBackgroundDrawable(drawable);

    }

}

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Qwincommented, Jul 21, 2017

Hi LeonBre,

I think I might be able to help you out, considering I was stuck myself and had to go through the whole calendar code.

A DayViewDecorator is an interface that has only two methods you need to implement, shouldDecorate(CalendarDay) and decorate(DayViewFacade). shouldDecorate() is called for every date in the calendar to determine if the decorator should be applied to that date. decorate() is called only one time to gather the customizations used for this decorator. This is so we can cache the decorations and efficiently apply them to many days.

As per docs the decorator method only is called ones and is cached after that, the color cannot be different within the same decorator. However creating multiple decorators with each a color should have worked, I did the same with my calendar and it works for me. (Unless I misunderstood you)

Hope this helps.

0reactions
quentin41500commented, Jul 11, 2018

@ka05 you are correct, the issue is related on how the spans are added. Im not a big fan of spans in general due to the limitation of customizing them, but they are more efficient for performance and less prone to weird behavior. If any of you find a way to add the dot spans without having them overlapping each other (and not breaking other spans), please let me know.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Use More Than One Paint Color in a Room
"Color combinations in a room are another gesture of artistry and design and can help tie in or accentuate the room's entire color...
Read more >
How do I make function decorators and chain them together?
Python itself provides several decorators: property , staticmethod , etc. Django uses decorators to manage caching and view permissions. Twisted ...
Read more >
Color Palette Generators for Interior Color Schemes
Pick your perfect interior colors or develop your own interior color scheme with these online color generators and visualizer tools.
Read more >
These Are The 4 Color Rules That Every Interior Design Fan ...
In particular, it uses two shades that are sitting directly opposite each other on the color wheel, meaning you get combinations like blue...
Read more >
These 6 Lessons in Color Will Change the Way You Decorate
“I wanted a lot of white, first of all, and then a mix of blue and orange,” he reveals. The secret? Working with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found