Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Apr 12, 2017
1 parent acbb883 commit 170170c
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ public void onClickDate(int year, int month, int day) {
wcvCalendar.setOnCalendarClickListener(null);
int weeks = CalendarUtils.getWeeksAgo(mCurrentSelectYear, mCurrentSelectMonth, mCurrentSelectDay, year, month, day);
resetCurrentSelectDate(year, month, day);
int position = wcvCalendar.getCurrentItem() + weeks;
if (weeks != 0) {
int position = wcvCalendar.getCurrentItem() + weeks;
wcvCalendar.setCurrentItem(position, false);
}
resetWeekView();
resetWeekView(position);
wcvCalendar.setOnCalendarClickListener(mWeekCalendarClickListener);
}

Expand All @@ -160,15 +160,16 @@ private void computeCurrentRowsIsSix(int year, int month) {
}
}

private void resetWeekView() {
private void resetWeekView(int position) {
WeekView weekView = wcvCalendar.getCurrentWeekView();
if (weekView != null) {
weekView.setSelectYearMonth(mCurrentSelectYear, mCurrentSelectMonth, mCurrentSelectDay);
weekView.invalidate();
} else {
WeekView newWeekView = wcvCalendar.getWeekAdapter().instanceWeekView(wcvCalendar.getCurrentItem());
WeekView newWeekView = wcvCalendar.getWeekAdapter().instanceWeekView(position);
newWeekView.setSelectYearMonth(mCurrentSelectYear, mCurrentSelectMonth, mCurrentSelectDay);
newWeekView.invalidate();
wcvCalendar.setCurrentItem(position);
}
if (mOnCalendarClickListener != null) {
mOnCalendarClickListener.onClickDate(mCurrentSelectYear, mCurrentSelectMonth, mCurrentSelectDay);
Expand Down

0 comments on commit 170170c

Please sign in to comment.