Skip to content

Commit ea67bb2

Browse files
author
Antonio Altieri
committed
Set event dot color
1 parent 1869901 commit ea67bb2

File tree

5 files changed

+37
-1
lines changed

5 files changed

+37
-1
lines changed

collapsiblecalendarview2/src/main/java/com/shrikanthravi/collapsiblecalendarview/data/CalendarAdapter.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.shrikanthravi.collapsiblecalendarview.data;
22

33
import android.content.Context;
4+
import android.graphics.Color;
5+
import android.graphics.PorterDuff;
46
import android.view.LayoutInflater;
57
import android.view.View;
68
import android.widget.ImageView;
@@ -125,6 +127,7 @@ public void refresh() {
125127
&& day.getMonth() == event.getMonth()
126128
&& day.getDay() == event.getDay()) {
127129
imgEventTag.setVisibility(View.VISIBLE);
130+
imgEventTag.setColorFilter(event.getColor(),PorterDuff.Mode.SRC_ATOP);
128131
}
129132
}
130133

collapsiblecalendarview2/src/main/java/com/shrikanthravi/collapsiblecalendarview/data/Event.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,21 @@ public class Event {
88
private int mYear;
99
private int mMonth;
1010
private int mDay;
11+
private int mColor;
1112

1213
public Event(int year, int month, int day){
1314
this.mYear = year;
1415
this.mMonth = month;
1516
this.mDay = day;
1617
}
1718

19+
public Event(int year, int month, int day, int color){
20+
this.mYear = year;
21+
this.mMonth = month;
22+
this.mDay = day;
23+
this.mColor=color;
24+
}
25+
1826
public int getMonth(){
1927
return mMonth;
2028
}
@@ -27,4 +35,7 @@ public int getDay(){
2735
return mDay;
2836
}
2937

38+
public int getColor() {
39+
return mColor;
40+
}
3041
}

collapsiblecalendarview2/src/main/java/com/shrikanthravi/collapsiblecalendarview/widget/CollapsibleCalendar.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,13 @@ public void setAdapter(CalendarAdapter adapter) {
306306
}
307307

308308
public void addEventTag(int numYear, int numMonth, int numDay) {
309-
mAdapter.addEvent(new Event(numYear, numMonth, numDay));
309+
mAdapter.addEvent(new Event(numYear, numMonth, numDay,getEventColor()));
310+
311+
reload();
312+
}
313+
314+
public void addEventTag(int numYear, int numMonth, int numDay,int color) {
315+
mAdapter.addEvent(new Event(numYear, numMonth, numDay,color));
310316

311317
reload();
312318
}

collapsiblecalendarview2/src/main/java/com/shrikanthravi/collapsiblecalendarview/widget/UICalendar.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public abstract class UICalendar extends LinearLayout {
8282
private int mButtonRightDrawableTintColor=Color.BLACK;
8383

8484
private int mExpandIconColor = Color.BLACK;
85+
private int mEventColor=Color.BLACK;
8586

8687
public UICalendar(Context context) {
8788
this(context, null);
@@ -141,6 +142,9 @@ protected void setAttributes(TypedArray attrs) {
141142
setTextColor(attrs.getColor(R.styleable.UICalendar_textColor, mTextColor));
142143
setPrimaryColor(attrs.getColor(R.styleable.UICalendar_primaryColor, mPrimaryColor));
143144

145+
setEventColor(attrs.getColor(R.styleable.UICalendar_eventColor, mEventColor));
146+
147+
144148
setTodayItemTextColor(attrs.getColor(
145149
R.styleable.UICalendar_todayItem_textColor, mTodayItemTextColor));
146150
Drawable todayItemBackgroundDrawable =
@@ -265,6 +269,15 @@ public void setPrimaryColor(int primaryColor) {
265269
mLayoutRoot.setBackgroundColor(mPrimaryColor);
266270
}
267271

272+
private void setEventColor(int eventColor) {
273+
this.mEventColor = eventColor;
274+
redraw();
275+
276+
}
277+
public int getEventColor() {
278+
return mEventColor;
279+
}
280+
268281
public int getTodayItemTextColor() {
269282
return mTodayItemTextColor;
270283
}

collapsiblecalendarview2/src/main/res/values/attrs.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
<attr name="textColor" format="color" />
3535
<attr name="primaryColor" format="color" />
3636

37+
<attr name="eventColor" format="color" />
38+
39+
3740
<attr name="todayItem_textColor" format="color" />
3841
<attr name="todayItem_background" format="integer" />
3942

0 commit comments

Comments
 (0)