diff --git a/README.md b/README.md
index 6e46319..0ff0b51 100644
--- a/README.md
+++ b/README.md
@@ -9,11 +9,122 @@
[APK下载](https://w-5.net/YPqDk)
## 功能
+* 默认显示6个月信息
* 连续选择
* 设置不可选项
* 自动调换开始和结束位置
* 回调和get获取选择的日期信息
+## 方法
+* addUnableDays(int days);
+设置今天之后不可点击选择的天数
+
+* resetState();
+取消所有选中,但是不会取消不可点击的天数,可以使用
+```addUnableDays(0);```
+
+* 回调
+```
+setOnCalendarChange(new CalendarView.OnCalendarChange() {
+ @Override
+ public void onStart(DayBean dayBean) {
+ }
+
+ @Override
+ public void onEnd(DayBean dayBean) {
+ }
+
+ @Override
+ public void onDays(int day) {
+ super.onDays(day);
+ }
+ });
+```
+>DayBean
+```
+public class DayBean {
+ private boolean isTodayDay;
+ private int month;
+ private int year;
+ private int day;
+
+ public DayBean() {
+ }
+
+ public boolean isTodayDay() {
+ return isTodayDay;
+ }
+
+ public void setTodayDay(boolean todayDay) {
+ isTodayDay = todayDay;
+ }
+
+ public int getMonth() {
+ return month;
+ }
+
+ public void setMonth(int month) {
+ this.month = month;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ public int getDay() {
+ return day;
+ }
+
+ public void setDay(int day) {
+ this.day = day;
+ }
+
+ @Override
+ public String toString() {
+ return year + "-" + month + "-" + day;
+ }
+
+ public Calendar getCalendar() {
+ return CalendarUtils.getCurreCalendar(year, month - 1, day);
+ }
+}
+```
+
+* get方法
+
+```
+ /**
+ * 获取开始日期
+ *
+ * @return
+ */
+ public SelectBean getSelectStartDays() {
+ return startSelectBean;
+ }
+
+ /**
+ * 获取结束日期
+ *
+ * @return
+ */
+ public SelectBean getSelectEndDays() {
+ return endSelectBean;
+ }
+
+ /**
+ * 获取选择天数
+ *
+ * @return
+ */
+ public int getSelectDays() {
+ return selectDays;
+ }
+```
+
## 使用
### Gradle
@@ -49,3 +160,15 @@ dependencies {
0.1.0
```
+
+## 混淆
+```
+-keep class com.chad.library.adapter.** {
+*;
+}
+-keep public class * extends com.chad.library.adapter.base.BaseQuickAdapter
+-keep public class * extends com.chad.library.adapter.base.BaseViewHolder
+-keepclassmembers class **$** extends com.chad.library.adapter.base.BaseViewHolder {
+ (...);
+}
+```
diff --git a/app/build.gradle b/app/build.gradle
index 6f33c6d..ebebe7d 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -6,7 +6,7 @@ android {
defaultConfig {
applicationId "com.muzi.verticalcalendar"
minSdkVersion 19
- targetSdkVersion 27
+ targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -27,5 +27,7 @@ dependencies {
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
- compile project(':library')
+// compile project(':library')
+ compile 'com.github.mzyq:VerticalCalendar:0.1.0'
}
+
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
index 9786e21..f3ab3b7 100644
--- a/app/proguard-rules.pro
+++ b/app/proguard-rules.pro
@@ -23,3 +23,27 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
+
+-keep class com.chad.library.adapter.** {
+*;
+}
+-keep public class * extends com.chad.library.adapter.base.BaseQuickAdapter
+-keep public class * extends com.chad.library.adapter.base.BaseViewHolder
+-keepclassmembers class **$** extends com.chad.library.adapter.base.BaseViewHolder {
+ (...);
+}
+-keep class **.R$* {*;}
+-keep class android.support.** {*;}
+-keepclasseswithmembers class * { # 保持自定义控件类不被混淆
+ public (android.content.Context, android.util.AttributeSet);
+}
+-keepclasseswithmembers class * {# 保持自定义控件类不被混淆
+ public (android.content.Context, android.util.AttributeSet, int);
+}
+-keepclassmembers class * extends android.app.Activity { # 保持自定义控件类不被混淆
+ public void *(android.view.View);
+}
+-keep class com.muzi.library.bean.**{
+ *;
+}
+-dontoptimize
diff --git a/app/src/main/java/com/muzi/verticalcalendar/MainActivity.java b/app/src/main/java/com/muzi/verticalcalendar/MainActivity.java
index f0dce80..d0a981a 100644
--- a/app/src/main/java/com/muzi/verticalcalendar/MainActivity.java
+++ b/app/src/main/java/com/muzi/verticalcalendar/MainActivity.java
@@ -5,7 +5,6 @@
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
-import android.widget.Toast;
import com.muzi.library.CalendarView;
import com.muzi.library.bean.DayBean;
@@ -36,22 +35,20 @@ public void onClick(View v) {
calendarView.addUnableDays(Integer.parseInt(editText.getText().toString().trim()));
}
});
+ calendarView.resetState();
calendarView.setOnCalendarChange(new CalendarView.OnCalendarChange() {
@Override
public void onStart(DayBean dayBean) {
-
}
@Override
public void onEnd(DayBean dayBean) {
-
}
@Override
public void onDays(int day) {
super.onDays(day);
- Toast.makeText(MainActivity.this, "选择了:" + day + "天", Toast.LENGTH_SHORT).show();
}
});
}
diff --git a/library/proguard-rules.pro b/library/proguard-rules.pro
index 9786e21..b1d47fb 100644
--- a/library/proguard-rules.pro
+++ b/library/proguard-rules.pro
@@ -23,3 +23,12 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
+-keepclasseswithmembers class * {
+ public (android.content.Context);
+}
+-keepclasseswithmembers class * {
+ public (android.content.Context, android.util.AttributeSet);
+}
+-keepclasseswithmembers class * {
+ public (android.content.Context, android.util.AttributeSet, int);
+}
\ No newline at end of file
diff --git a/library/src/main/java/com/muzi/library/CalendarView.java b/library/src/main/java/com/muzi/library/CalendarView.java
index 9b16796..79e9f04 100644
--- a/library/src/main/java/com/muzi/library/CalendarView.java
+++ b/library/src/main/java/com/muzi/library/CalendarView.java
@@ -168,7 +168,7 @@ private void initCalendarList() {
//是否是today
if (CalendarUtils.equalsCalendar(curreCalendar, todayCalendar)) {
- dayBean.setCurreDay(true);
+ dayBean.setTodayDay(true);
dayBean.setContent(getContext().getString(R.string.today));
}
@@ -462,8 +462,9 @@ private void handleListener() {
if (startSelectBean != null && endSelectBean != null) {
selectDays = CalendarUtils.differentDays(startSelectBean.getDayBean().getCalendar(),
endSelectBean.getDayBean().getCalendar());
+ selectDays++;
if (onCalendarChange != null) {
- onCalendarChange.onDays(selectDays + 1);
+ onCalendarChange.onDays(selectDays);
}
} else {
selectDays = 0;
diff --git a/library/src/main/java/com/muzi/library/bean/DayBean.java b/library/src/main/java/com/muzi/library/bean/DayBean.java
index ceed6d8..183d6bf 100644
--- a/library/src/main/java/com/muzi/library/bean/DayBean.java
+++ b/library/src/main/java/com/muzi/library/bean/DayBean.java
@@ -15,7 +15,7 @@ public class DayBean implements Cloneable {
/**
* 是否今天
*/
- private boolean isCurreDay;
+ private boolean isTodayDay;
/**
* 补全空白
*/
@@ -45,12 +45,12 @@ public DayBean(boolean isEmpty) {
this.isEmpty = isEmpty;
}
- public boolean isCurreDay() {
- return isCurreDay;
+ public boolean isTodayDay() {
+ return isTodayDay;
}
- public void setCurreDay(boolean curreDay) {
- isCurreDay = curreDay;
+ public void setTodayDay(boolean todayDay) {
+ isTodayDay = todayDay;
}
public String getWeek() {