Skip to content

Commit 94f0812

Browse files
author
dafengluo
committed
develop 完善标记刷新
1 parent 2cf18eb commit 94f0812

File tree

13 files changed

+154
-104
lines changed

13 files changed

+154
-104
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
jcenter()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.3.0'
8+
classpath 'com.android.tools.build:gradle:3.0.0'
99
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
1010

1111
// NOTE: Do not place your application dependencies here; they belong

calendar/build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,25 @@ apply plugin:'com.github.dcendents.android-maven'
44
group='com.github.MagicMashRoom'
55
android {
66
compileSdkVersion 23
7-
buildToolsVersion "25.0.0"
7+
buildToolsVersion '26.0.2'
88

99
defaultConfig {
1010
minSdkVersion 17
1111
targetSdkVersion 23
1212
versionCode 1
1313
versionName "1.0"
1414
}
15+
1516
buildTypes {
1617
release {
1718
minifyEnabled false
1819
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
1920
}
2021
}
22+
23+
lintOptions {
24+
abortOnError false
25+
}
2126
}
2227

2328
dependencies {

calendar/src/main/java/com/ldf/calendar/Utils.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import android.view.ViewConfiguration;
1515
import android.widget.Scroller;
1616

17+
import com.ldf.calendar.component.CalendarAttr;
1718
import com.ldf.calendar.model.CalendarDate;
1819
import com.ldf.calendar.view.MonthPager;
1920

@@ -80,11 +81,11 @@ public static int getDay() {
8081
* @param type 周排列方式 0代表周一作为本周的第一天, 2代表周日作为本周的第一天
8182
* @return int 本月第一天在其周的位置
8283
*/
83-
public static int getFirstDayWeekPosition(int year, int month, int type) {
84+
public static int getFirstDayWeekPosition(int year, int month, CalendarAttr.WeekArrayType type) {
8485
Calendar cal = Calendar.getInstance();
8586
cal.setTime(getDateFromString(year, month));
8687
int week_index = cal.get(Calendar.DAY_OF_WEEK) - 1;
87-
if (type == 1) {
88+
if (type == CalendarAttr.WeekArrayType.Sunday) {
8889
return week_index;
8990
} else {
9091
week_index = cal.get(Calendar.DAY_OF_WEEK) + 5;
@@ -298,17 +299,6 @@ public void run() {
298299
saveTop(child.getTop());
299300
parent.dispatchDependentViewsChanged(child);
300301
ViewCompat.postOnAnimation(child, this);
301-
} else {
302-
MonthPager monthPager = (MonthPager) parent.getChildAt(0);
303-
if (monthPager.getTop() < 0) {
304-
if (monthPager.getTop() + monthPager.getTopMovableDistance() >= 0) {
305-
monthPager.offsetTopAndBottom(-monthPager.getTop()
306-
- monthPager.getTopMovableDistance());
307-
} else {
308-
monthPager.offsetTopAndBottom(-monthPager.getTop());
309-
}
310-
parent.dispatchDependentViewsChanged(child);
311-
}
312302
}
313303
}
314304
});

calendar/src/main/java/com/ldf/calendar/behavior/RecyclerViewBehavior.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, Recycler
6565
boolean isVertical = (nestedScrollAxes & ViewCompat.SCROLL_AXIS_VERTICAL) != 0;
6666
int firstRowVerticalPosition =
6767
(child == null || child.getChildCount() == 0) ? 0 : child.getChildAt(0).getTop();
68-
boolean recycleviewTopStatus = firstRowVerticalPosition >= 0;
68+
boolean recyclerViewTopStatus = firstRowVerticalPosition >= 0;
6969
return isVertical
70-
&& (recycleviewTopStatus || !Utils.isScrollToBottom())
70+
&& (recyclerViewTopStatus || !Utils.isScrollToBottom())
7171
&& child == directTargetChild;
7272
}
7373

@@ -107,8 +107,7 @@ public void onStopNestedScroll(final CoordinatorLayout parent, final RecyclerVie
107107
}
108108

109109
private MonthPager getMonthPager(CoordinatorLayout coordinatorLayout) {
110-
MonthPager monthPager = (MonthPager) coordinatorLayout.getChildAt(0);
111-
return monthPager;
110+
return (MonthPager) coordinatorLayout.getChildAt(0);
112111
}
113112

114113
private void saveTop(int top) {

calendar/src/main/java/com/ldf/calendar/component/CalendarAttr.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ public class CalendarAttr {
1212
private WeekArrayType weekArrayType;
1313

1414
/**
15-
* 日历才去周布局或者月布局:<br/>
16-
* {@link CalendarAttr.CalendayType} 布局类型<br/>
15+
* 日历周布局或者月布局:<br/>
16+
* {@link CalendarType} 布局类型<br/>
1717
*/
18-
private CalendayType calendarType;
18+
private CalendarType calendarType;
1919

2020
/**
2121
* 日期格子高度
@@ -35,11 +35,11 @@ public void setWeekArrayType(WeekArrayType weekArrayType) {
3535
this.weekArrayType = weekArrayType;
3636
}
3737

38-
public CalendayType getCalendarType() {
38+
public CalendarType getCalendarType() {
3939
return calendarType;
4040
}
4141

42-
public void setCalendarType(CalendayType calendarType) {
42+
public void setCalendarType(CalendarType calendarType) {
4343
this.calendarType = calendarType;
4444
}
4545

@@ -63,7 +63,7 @@ public enum WeekArrayType {
6363
Sunday, Monday
6464
}
6565

66-
public enum CalendayType {
66+
public enum CalendarType {
6767
WEEK, MONTH
6868
}
6969
}

calendar/src/main/java/com/ldf/calendar/component/CalendarRenderer.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import android.content.Context;
44
import android.graphics.Canvas;
5-
import android.util.Log;
65

76
import com.ldf.calendar.Const;
87
import com.ldf.calendar.Utils;
@@ -60,28 +59,28 @@ public void onClickDate(int col, int row) {
6059
if (col >= Const.TOTAL_COL || row >= Const.TOTAL_ROW)
6160
return;
6261
if (weeks[row] != null) {
63-
if (attr.getCalendarType() == CalendarAttr.CalendayType.MONTH) {
62+
if (attr.getCalendarType() == CalendarAttr.CalendarType.MONTH) {
6463
if (weeks[row].days[col].getState() == State.CURRENT_MONTH) {
6564
weeks[row].days[col].setState(State.SELECT);
6665
selectedDate = weeks[row].days[col].getDate();
67-
CalendarViewAdapter.saveDate(selectedDate);
66+
CalendarViewAdapter.saveSelectedDate(selectedDate);
6867
onSelectDateListener.onSelectDate(selectedDate);
6968
seedDate = selectedDate;
7069
} else if (weeks[row].days[col].getState() == State.PAST_MONTH) {
7170
selectedDate = weeks[row].days[col].getDate();
72-
CalendarViewAdapter.saveDate(selectedDate);
71+
CalendarViewAdapter.saveSelectedDate(selectedDate);
7372
onSelectDateListener.onSelectOtherMonth(-1);
7473
onSelectDateListener.onSelectDate(selectedDate);
7574
} else if (weeks[row].days[col].getState() == State.NEXT_MONTH) {
7675
selectedDate = weeks[row].days[col].getDate();
77-
CalendarViewAdapter.saveDate(selectedDate);
76+
CalendarViewAdapter.saveSelectedDate(selectedDate);
7877
onSelectDateListener.onSelectOtherMonth(1);
7978
onSelectDateListener.onSelectDate(selectedDate);
8079
}
8180
} else {
8281
weeks[row].days[col].setState(State.SELECT);
8382
selectedDate = weeks[row].days[col].getDate();
84-
CalendarViewAdapter.saveDate(selectedDate);
83+
CalendarViewAdapter.saveSelectedDate(selectedDate);
8584
onSelectDateListener.onSelectDate(selectedDate);
8685
seedDate = selectedDate;
8786
}
@@ -96,7 +95,7 @@ public void onClickDate(int col, int row) {
9695
*/
9796
public void updateWeek(int rowIndex) {
9897
CalendarDate currentWeekLastDay;
99-
if (CalendarViewAdapter.weekArrayType == 1) {
98+
if (attr.getWeekArrayType() == CalendarAttr.WeekArrayType.Sunday) {
10099
currentWeekLastDay = Utils.getSaturday(seedDate);
101100
} else {
102101
currentWeekLastDay = Utils.getSunday(seedDate);
@@ -108,15 +107,15 @@ public void updateWeek(int rowIndex) {
108107
weeks[rowIndex] = new Week(rowIndex);
109108
}
110109
if (weeks[rowIndex].days[i] != null) {
111-
if (date.equals(CalendarViewAdapter.loadDate())) {
110+
if (date.equals(CalendarViewAdapter.loadSelectedDate())) {
112111
weeks[rowIndex].days[i].setState(State.SELECT);
113112
weeks[rowIndex].days[i].setDate(date);
114113
} else {
115114
weeks[rowIndex].days[i].setState(State.CURRENT_MONTH);
116115
weeks[rowIndex].days[i].setDate(date);
117116
}
118117
} else {
119-
if (date.equals(CalendarViewAdapter.loadDate())) {
118+
if (date.equals(CalendarViewAdapter.loadSelectedDate())) {
120119
weeks[rowIndex].days[i] = new Day(State.SELECT, date, rowIndex, i);
121120
} else {
122121
weeks[rowIndex].days[i] = new Day(State.CURRENT_MONTH, date, rowIndex, i);
@@ -137,7 +136,7 @@ private void instantiateMonth() {
137136
int firstDayPosition = Utils.getFirstDayWeekPosition(
138137
seedDate.year,
139138
seedDate.month,
140-
CalendarViewAdapter.weekArrayType);
139+
attr.getWeekArrayType());
141140

142141
int day = 0;
143142
for (int row = 0; row < Const.TOTAL_ROW; row++) {
@@ -175,15 +174,15 @@ private void fillCurrentMonthDate(int day, int row, int col) {
175174
weeks[row] = new Week(row);
176175
}
177176
if (weeks[row].days[col] != null) {
178-
if (date.equals(CalendarViewAdapter.loadDate())) {
177+
if (date.equals(CalendarViewAdapter.loadSelectedDate())) {
179178
weeks[row].days[col].setDate(date);
180179
weeks[row].days[col].setState(State.SELECT);
181180
} else {
182181
weeks[row].days[col].setDate(date);
183182
weeks[row].days[col].setState(State.CURRENT_MONTH);
184183
}
185184
} else {
186-
if (date.equals(CalendarViewAdapter.loadDate())) {
185+
if (date.equals(CalendarViewAdapter.loadSelectedDate())) {
187186
weeks[row].days[col] = new Day(State.SELECT, date, row, col);
188187
} else {
189188
weeks[row].days[col] = new Day(State.CURRENT_MONTH, date, row, col);

0 commit comments

Comments
 (0)