Skip to content

Commit

Permalink
Fix mark circle style for selected days
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Hernaiz committed May 19, 2018
1 parent 82a135b commit 3c25631
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ allprojects {
androidTargetSdkVersion = 27
androidCompileSdkVersion = 27
androidVersionCode = 1
androidVersionName = "3.4.0"
androidVersionName = "3.4.1"
}

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,8 @@ private static int getWeekIndex(int weekIndex, Calendar currentCalendar) {
}
}

public interface RobotoCalendarListener {

void onDayClick(Date date);

void onDayLongClick(Date date);

void onRightButtonClick();

void onLeftButtonClick();
public static boolean areInTheSameDay(@NonNull Calendar calendarOne, @NonNull Calendar calendarTwo) {
return calendarOne.get(Calendar.YEAR) == calendarTwo.get(Calendar.YEAR) && calendarOne.get(Calendar.DAY_OF_YEAR) == calendarTwo.get(Calendar.DAY_OF_YEAR);
}

/**
Expand Down Expand Up @@ -268,15 +261,23 @@ public void markCircleImage1(@NonNull Date date) {
calendar.setTime(date);
ImageView circleImage1 = getCircleImage1(calendar);
circleImage1.setVisibility(View.VISIBLE);
DrawableCompat.setTint(circleImage1.getDrawable(), ContextCompat.getColor(context, R.color.roboto_calendar_circle_1));
if (lastSelectedDayCalendar != null && areInTheSameDay(calendar, lastSelectedDayCalendar)) {
DrawableCompat.setTint(circleImage1.getDrawable(), ContextCompat.getColor(context, R.color.roboto_calendar_selected_day_font));
} else {
DrawableCompat.setTint(circleImage1.getDrawable(), ContextCompat.getColor(context, R.color.roboto_calendar_circle_1));
}
}

public void markCircleImage2(@NonNull Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
ImageView circleImage2 = getCircleImage2(calendar);
circleImage2.setVisibility(View.VISIBLE);
DrawableCompat.setTint(circleImage2.getDrawable(), ContextCompat.getColor(context, R.color.roboto_calendar_circle_2));
if (lastSelectedDayCalendar != null && areInTheSameDay(calendar, lastSelectedDayCalendar)) {
DrawableCompat.setTint(circleImage2.getDrawable(), ContextCompat.getColor(context, R.color.roboto_calendar_selected_day_font));
} else {
DrawableCompat.setTint(circleImage2.getDrawable(), ContextCompat.getColor(context, R.color.roboto_calendar_circle_2));
}
}

public void showDateTitle(boolean show) {
Expand Down Expand Up @@ -504,4 +505,15 @@ private View getView(String key, Calendar currentCalendar) {
return rootView.findViewWithTag(key + index);
}

public interface RobotoCalendarListener {

void onDayClick(Date date);

void onDayLongClick(Date date);

void onRightButtonClick();

void onLeftButtonClick();
}

}

0 comments on commit 3c25631

Please sign in to comment.