Skip to content

Commit

Permalink
整理文档
Browse files Browse the repository at this point in the history
  • Loading branch information
yannecer committed Apr 1, 2020
1 parent 4df76f0 commit 2197672
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 87 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
setContentView(R.layout.activity_stretch);

miui10Calendar = findViewById(R.id.miui10Calendar);
miui10Calendar.setMonthStretchEnable(true);
miui10Calendar.setStretchCalendarEnable(true);

List<String> pointList = Arrays.asList("2019-07-01", "2019-07-19", "2019-07-25", "2019-05-23", "2019-01-01", "2018-12-23");

Expand Down
4 changes: 2 additions & 2 deletions ncalendar/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android {
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "4.4.1"
versionName "5.0.0"
}
}

Expand All @@ -28,7 +28,7 @@ publish {
repoName = 'maven'//bintray仓库
groupId = 'com.necer.ncalendar'//jcenter上的路径
artifactId = 'ncalendar'//项目名称
publishVersion = '4.4.1'//版本号
publishVersion = '5.0.0'//版本号
desc = 'NCalendar'
website = 'https://github.com/yannecer/NCalendar'
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public BaseCalendar(@NonNull Context context, @Nullable AttributeSet attributeSe
mStartDate = new LocalDate(mDefaultStartDate);
mEndDate = new LocalDate(mDefaultEndDateDate);

//背景颜色
//背景
if (mAttrs.showNumberBackground) {
mCalendarBackground = new NumBackground(mAttrs.numberBackgroundTextSize, mAttrs.numberBackgroundTextColor, mAttrs.numberBackgroundAlphaColor);
} else if (mAttrs.calendarBackground != null) {
Expand Down
6 changes: 3 additions & 3 deletions ncalendar/src/main/java/com/necer/calendar/ICalendar.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public interface ICalendar {
/**
* 设置选中模式
*
* @param checkModel SINGLE_DEFAULT_CHECKED-单个 默认每页选中 默认模式 每页都会有一个选中
* SINGLE_DEFAULT_UNCHECKED-单个 默认不选中 点击、跳转选中
* @param checkModel SINGLE_DEFAULT_CHECKED-单选 默认每页选中 默认模式 每页都会有一个选中
* SINGLE_DEFAULT_UNCHECKED-单选 默认不选中 点击、跳转选中
* MULTIPLE-多选
*/
void setCheckMode(CheckModel checkModel);
Expand Down Expand Up @@ -204,7 +204,7 @@ public interface ICalendar {


/**
* 获选模式下,初始化时选中的日期
* 多选模式下,初始化时选中的日期
*
* @param dateList 日期几何 yyyy-MM-dd
*/
Expand Down
2 changes: 1 addition & 1 deletion ncalendar/src/main/java/com/necer/calendar/IICalendar.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public interface IICalendar extends ICalendar {
/**
* 设置月状态下 是否可以下拉拉伸
*/
void setMonthStretchEnable(boolean isMonthStretchEnable);
void setStretchCalendarEnable(boolean isMonthStretchEnable);

/**
* 日历月周状态变化回调
Expand Down
21 changes: 11 additions & 10 deletions ncalendar/src/main/java/com/necer/calendar/NCalendar.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public abstract class NCalendar extends FrameLayout implements IICalendar, Neste
protected RectF stretchMonthRect;

private boolean isWeekHoldEnable;//是否需要周状态定
private boolean isMonthStretchEnable;//月日历是否可拉伸
private boolean isStretchCalendarEnable;//月日历是否可拉伸

private boolean isInflateFinish;//是否加载完成,

Expand All @@ -95,6 +95,7 @@ public NCalendar(@NonNull Context context, @Nullable AttributeSet attrs, int def

int duration = this.attrs.animationDuration;
monthHeight = this.attrs.calendarHeight;
isStretchCalendarEnable = this.attrs.stretchCalendarEnable;
stretchMonthHeight = this.attrs.stretchCalendarHeight;

if (monthHeight >= stretchMonthHeight) {
Expand Down Expand Up @@ -211,7 +212,7 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) {

weekCalendar.layout(paddingLeft, 0, measuredWidth - paddingRight, weekHeight);

if (childView.getY() >= monthHeight && isMonthStretchEnable) {
if (childView.getY() >= monthHeight && isStretchCalendarEnable) {
monthCalendar.layout(paddingLeft, 0, measuredWidth - paddingRight, stretchMonthHeight);
} else {
monthCalendar.layout(paddingLeft, 0, measuredWidth - paddingRight, monthHeight);
Expand Down Expand Up @@ -357,7 +358,7 @@ protected void gestureMove(float dy, int[] consumed) {

if (dy > 0 && childViewY == monthHeight && monthCalendarY == 0) {
//setY 起始位置 月->周的过程
if (isMonthStretchEnable && realMonthHeight != monthHeight) {
if (isStretchCalendarEnable && realMonthHeight != monthHeight) {
layoutParams.height = monthHeight;
monthCalendar.setLayoutParams(layoutParams);
}
Expand All @@ -370,7 +371,7 @@ protected void gestureMove(float dy, int[] consumed) {
}
scrolling(dy);

} else if (dy < 0 && childViewY == monthHeight && monthCalendarY == 0 && isMonthStretchEnable) {
} else if (dy < 0 && childViewY == monthHeight && monthCalendarY == 0 && isStretchCalendarEnable) {
//拉伸 起始位置 月->拉伸的过程
float monthOffset = getOffset(-dy, stretchMonthHeight - realMonthHeight);
layoutParams.height = (int) (layoutParams.height + monthOffset);
Expand All @@ -386,7 +387,7 @@ protected void gestureMove(float dy, int[] consumed) {

} else if (dy > 0 && childViewY <= monthHeight && childViewY != weekHeight) {
//setY 持续过程 月->周的过程
if (isMonthStretchEnable && realMonthHeight != monthHeight) {
if (isStretchCalendarEnable && realMonthHeight != monthHeight) {
//由于滑动过程中可能存在从拉伸状态直接滑到周的状态,引起monthCalendar的高度还没有到monthHeight就向上滑动,所以在这里判断一下,高度正常之后才上滑
layoutParams.height = monthHeight;
monthCalendar.setLayoutParams(layoutParams);
Expand All @@ -402,7 +403,7 @@ protected void gestureMove(float dy, int[] consumed) {

} else if (dy < 0 && childViewY <= monthHeight && childViewY >= weekHeight && (!(isWeekHoldEnable && calendarState == CalendarState.WEEK) || consumed == null) && (targetView == null || !targetView.canScrollVertically(-1))) {
//setY 持续过程 周->月的过程
if (isMonthStretchEnable && realMonthHeight != monthHeight) {
if (isStretchCalendarEnable && realMonthHeight != monthHeight) {
layoutParams.height = monthHeight;
monthCalendar.setLayoutParams(layoutParams);
}
Expand All @@ -415,7 +416,7 @@ protected void gestureMove(float dy, int[] consumed) {
}
scrolling(dy);

} else if (dy < 0 && childViewY >= monthHeight && childViewY <= stretchMonthHeight && monthCalendarY == 0 && isMonthStretchEnable) {
} else if (dy < 0 && childViewY >= monthHeight && childViewY <= stretchMonthHeight && monthCalendarY == 0 && isStretchCalendarEnable) {
//拉伸 持续过程 月->拉伸的过程
float monthOffset = getOffset(-dy, stretchMonthHeight - realMonthHeight);
layoutParams.height = (int) (layoutParams.height + monthOffset);
Expand All @@ -429,7 +430,7 @@ protected void gestureMove(float dy, int[] consumed) {
}
scrolling(dy);

} else if (dy > 0 && childViewY >= monthHeight && childViewY <= stretchMonthHeight && monthCalendarY == 0 && isMonthStretchEnable) {
} else if (dy > 0 && childViewY >= monthHeight && childViewY <= stretchMonthHeight && monthCalendarY == 0 && isStretchCalendarEnable) {
//拉伸 持续过程 拉伸->月的过程
float monthOffset = getOffset(-dy, stretchMonthHeight - realMonthHeight);
layoutParams.height = (int) (layoutParams.height + monthOffset);
Expand Down Expand Up @@ -773,8 +774,8 @@ public void setWeekHoldEnable(boolean isWeekHoldEnable) {
}

@Override
public void setMonthStretchEnable(boolean isMonthStretchEnable) {
this.isMonthStretchEnable = isMonthStretchEnable;
public void setStretchCalendarEnable(boolean isMonthStretchEnable) {
this.isStretchCalendarEnable = isMonthStretchEnable;
}

@Override
Expand Down
Loading

0 comments on commit 2197672

Please sign in to comment.