diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..97626ba --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 7158618..802ea7b 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -43,6 +43,9 @@ + + C:\Users\Administrator\AppData\Roaming\Subversion + diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/java/com/loonggg/weekcalendar/test/MainActivity.java b/app/src/main/java/com/loonggg/weekcalendar/test/MainActivity.java index 05cb066..2b74dc0 100644 --- a/app/src/main/java/com/loonggg/weekcalendar/test/MainActivity.java +++ b/app/src/main/java/com/loonggg/weekcalendar/test/MainActivity.java @@ -36,5 +36,12 @@ public void onDateClick(String time) { } }); + weekCalendar.setOnCurrentMonthDateListener(new WeekCalendar.OnCurrentMonthDateListener() { + @Override + public void onCallbackMonthDate(String year, String month) { + Toast.makeText(MainActivity.this, year + "-" + month, Toast.LENGTH_SHORT).show(); + } + }); + } } diff --git a/weekcalendarlib/src/main/java/com/loonggg/weekcalendar/view/WeekCalendar.java b/weekcalendarlib/src/main/java/com/loonggg/weekcalendar/view/WeekCalendar.java index beabb7f..51d9970 100644 --- a/weekcalendarlib/src/main/java/com/loonggg/weekcalendar/view/WeekCalendar.java +++ b/weekcalendarlib/src/main/java/com/loonggg/weekcalendar/view/WeekCalendar.java @@ -57,6 +57,7 @@ public class WeekCalendar extends LinearLayout { private float daysTextSize, weekTextSize; private Drawable daysSelectedBackground, nextArrowBg, preArrowBg, cornerMarkBg; private List selectDateList = null; + private OnCurrentMonthDateListener onCurrentMonthDateListener; public WeekCalendar(Context context) { super(context); @@ -126,6 +127,9 @@ private void initDatas() { private void getWholeMonthDatas(CalendarData data) { calendarDatas = WeekCalendarUtil.getWholeMonthDay(data);//获取某天所在的整个月的数据(包含用于显示的上个月的天数和下个月的天数) weeks = WeekCalendarUtil.getWholeWeeks(calendarDatas);//获取当月有几个星期,以及每一星期对应的数据星期数据 + if (onCurrentMonthDateListener != null) { + onCurrentMonthDateListener.onCallbackMonthDate(String.valueOf(data.year), String.valueOf(data.month)); + } mTvYearMouth.setText(String.format("%s年%s月", String.valueOf(data.year), String.valueOf(data.month))); } @@ -386,6 +390,22 @@ public interface OnDateClickListener { void onDateClick(String time); } + /** + * 回调当前显示的年月 + */ + public interface OnCurrentMonthDateListener { + void onCallbackMonthDate(String year, String month); + } + + /** + * 设置显示当前月份的回调接口方法 + * + * @param onCurrentMonthDateListener + */ + public void setOnCurrentMonthDateListener(OnCurrentMonthDateListener onCurrentMonthDateListener) { + this.onCurrentMonthDateListener = onCurrentMonthDateListener; + } + /** * 设置回调接口 */