Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
Update configuration for gradle and gradle wrapper
  • Loading branch information
jonatansalas committed May 7, 2017
1 parent b253bfd commit 904259b
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 26 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ apply plugin: 'checkstyle'

android {
compileSdkVersion 25
buildToolsVersion "23.0.3"
buildToolsVersion "25.0.2"

defaultConfig {
applicationId "io.blackbox_vision.materialcalendarview.sample"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,16 @@ public boolean onNavigationItemSelected(MenuItem item) {
public void prepareTextView() {
textView.setText(String.format("Today is %s", formatDate(DATE_TEMPLATE, new Date(System.currentTimeMillis()))));
}

@Override
public void prepareCalendarView() {
Calendar disabledCal = Calendar.getInstance();
disabledCal.set(Calendar.DATE, disabledCal.get(Calendar.DATE) - 1);

calendarView.setFirstDayOfWeek(Calendar.MONDAY)
calendarView.setFirstDayOfWeek(Calendar.SUNDAY)
.setOnDateClickListener(this::onDateClick)
.setOnMonthChangeListener(this::onMonthChange)
.setOnDateLongClickListener(this::onDateLongClick)
.setOnMonthTitleClickListener(this::onMonthTitleClick)
.setDisabledDate(disabledCal.getTime());
.setOnMonthTitleClickListener(this::onMonthTitleClick);

if (calendarView.isMultiSelectDayEnabled()) {
calendarView.setOnMultipleDaySelectedListener((month, dates) -> {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'me.tatarka:gradle-retrolambda:3.2.3'
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
org.gradle.parallel=true
org.gradle.daemon=true;
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
2 changes: 1 addition & 1 deletion materialcalendarview/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ apply plugin: 'checkstyle'

android {
compileSdkVersion 25
buildToolsVersion "23.0.3"
buildToolsVersion "25.0.2"

defaultConfig {
minSdkVersion 11
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,9 @@ private void drawAdapterView() {
} else
disabledDay.setDay(-121); //random number for check

for (int i = 0; i < days.size(); i++) {
int size = days.size();

for (int i = 0; i < size; i++) {
Day day = days.get(i);

int fixedIndex = i + 1;
Expand Down Expand Up @@ -604,30 +606,31 @@ private void clearDayViewSelection(Date currentDate) {
}
}

public DayView findViewByDate(@NonNull Date dateToFind) {
Calendar calendar = Calendar.getInstance(Locale.getDefault());
calendar.setTime(dateToFind);
return (DayView) getView(getContext().getString(R.string.day_of_month_text), calendar);
public DayView findViewByDate(@NonNull Date date) {
final Calendar calendar = Calendar.getInstance(Locale.getDefault());
calendar.setTime(date);

return getView(getContext().getString(R.string.day_of_month_text), calendar);
}

private DayView findViewByCalendar(@NonNull Calendar calendarToFind) {
return (DayView) getView(getContext().getString(R.string.day_of_month_text), calendarToFind);
private DayView findViewByCalendar(@NonNull Calendar calendar) {
return getView(getContext().getString(R.string.day_of_month_text), calendar);
}

private int getDayIndexByDate(Calendar calendar) {
private int getDayIndexByDate(@NonNull Calendar calendar) {
int monthOffset = CalendarUtils.getMonthOffset(calendar, firstDayOfWeek);
int currentDay = calendar.get(Calendar.DAY_OF_MONTH);

return currentDay + monthOffset;
}

private View getView(String key, Calendar currentCalendar) {
private DayView getView(String key, Calendar currentCalendar) {
final int index = getDayIndexByDate(currentCalendar);
return view.findViewWithTag(key + index);
return (DayView) view.findViewWithTag(key + index);
}

public void update(Calendar c) {
calendar = c;
public void update(@NonNull Calendar calender) {
calendar = calender;
calendar.setFirstDayOfWeek(firstDayOfWeek);

calculateWeekEnds();
Expand Down Expand Up @@ -655,9 +658,9 @@ private boolean containsFlag(int flagSet, int flag) {
return (flagSet | flag) == flagSet;
}

private void drawCurrentDay(@NonNull Date todayDate) {
private void drawCurrentDay(@NonNull Date date) {
Calendar calendar = Calendar.getInstance(Locale.getDefault());
calendar.setTime(todayDate);
calendar.setTime(date);

if (CalendarUtils.isToday(calendar)) {
final DayView dayOfMonth = findViewByCalendar(calendar);
Expand All @@ -671,10 +674,10 @@ private void drawCurrentDay(@NonNull Date todayDate) {
}
}

public void markDateAsSelected(Date currentDate) {
public void markDateAsSelected(@NonNull Date date) {
Calendar currentCalendar = Calendar.getInstance(Locale.getDefault());
currentCalendar.setFirstDayOfWeek(firstDayOfWeek);
currentCalendar.setTime(currentDate);
currentCalendar.setTime(date);

// Clear previous marks
if (!isMultiSelectDayEnabled) {
Expand All @@ -699,7 +702,7 @@ public void markDateAsSelected(Date currentDate) {
}

// Store current values as last values
setLastSelectedDay(currentDate);
setLastSelectedDay(date);

// Mark current day as selected
DayView view = findViewByCalendar(currentCalendar);
Expand Down

0 comments on commit 904259b

Please sign in to comment.