Skip to content

Commit b3fa4a7

Browse files
author
Shrikanth Ravi
authored
Merge pull request #12 from Asdamp/master
Change event dots color
2 parents 1869901 + 4436ae6 commit b3fa4a7

File tree

7 files changed

+47
-1
lines changed

7 files changed

+47
-1
lines changed

app/src/main/java/com/shrikanthravi/collapsiblecalendarview/MainActivity.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
package com.shrikanthravi.collapsiblecalendarview;
22

3+
import android.graphics.Color;
34
import android.support.v7.app.AppCompatActivity;
45
import android.os.Bundle;
56
import android.view.View;
67

78
import com.shrikanthravi.collapsiblecalendarview.widget.CollapsibleCalendar;
89
import com.shrikanthravi.collapsiblecalendarview.widget.UICalendar;
910

11+
import java.util.Calendar;
12+
import java.util.Date;
13+
import java.util.GregorianCalendar;
14+
1015

1116
public class MainActivity extends AppCompatActivity {
1217

@@ -18,6 +23,10 @@ protected void onCreate(Bundle savedInstanceState) {
1823
getWindow().setStatusBarColor(getResources().getColor(R.color.google_red));
1924

2025
CollapsibleCalendar collapsibleCalendar = findViewById(R.id.collapsibleCalendarView);
26+
Calendar today=new GregorianCalendar();
27+
collapsibleCalendar.addEventTag(today.get(Calendar.YEAR),today.get(Calendar.MONTH),today.get(Calendar.DAY_OF_MONTH));
28+
today.add(Calendar.DATE,1);
29+
collapsibleCalendar.addEventTag(today.get(Calendar.YEAR),today.get(Calendar.MONTH),today.get(Calendar.DAY_OF_MONTH),Color.BLUE);
2130

2231
System.out.println("Testing date "+collapsibleCalendar.getSelectedDay().getDay()+"/"+collapsibleCalendar.getSelectedDay().getMonth()+"/"+collapsibleCalendar.getSelectedDay().getYear());
2332
collapsibleCalendar.setCalendarListener(new CollapsibleCalendar.CalendarListener() {

app/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@
1818
app:buttonLeft_drawableTintColor="@android:color/white"
1919
app:buttonRight_drawableTintColor="@android:color/white"
2020
app:expandIconColor="@android:color/white"
21+
app:eventColor="@android:color/white"
2122
></com.shrikanthravi.collapsiblecalendarview.widget.CollapsibleCalendar>
2223
</RelativeLayout>

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)