Multiple Decorators with different colours
See original GitHub issueHey 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:
- Created 6 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
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.
@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.