Merge "Fix bug #12066726 java.lang.NullPointerException at android.widget.CalendarView.onScroll(CalendarView.java:1216) - DO NOT MERGE" into klp-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
1ff2df6194
@@ -1210,35 +1210,38 @@ public class CalendarView extends FrameLayout {
|
|||||||
child = (WeekView) view.getChildAt(offset);
|
child = (WeekView) view.getChildAt(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find out which month we're moving into
|
if (child != null) {
|
||||||
int month;
|
// Find out which month we're moving into
|
||||||
if (mIsScrollingUp) {
|
int month;
|
||||||
month = child.getMonthOfFirstWeekDay();
|
|
||||||
} else {
|
|
||||||
month = child.getMonthOfLastWeekDay();
|
|
||||||
}
|
|
||||||
|
|
||||||
// And how it relates to our current highlighted month
|
|
||||||
int monthDiff;
|
|
||||||
if (mCurrentMonthDisplayed == 11 && month == 0) {
|
|
||||||
monthDiff = 1;
|
|
||||||
} else if (mCurrentMonthDisplayed == 0 && month == 11) {
|
|
||||||
monthDiff = -1;
|
|
||||||
} else {
|
|
||||||
monthDiff = month - mCurrentMonthDisplayed;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only switch months if we're scrolling away from the currently
|
|
||||||
// selected month
|
|
||||||
if ((!mIsScrollingUp && monthDiff > 0) || (mIsScrollingUp && monthDiff < 0)) {
|
|
||||||
Calendar firstDay = child.getFirstDay();
|
|
||||||
if (mIsScrollingUp) {
|
if (mIsScrollingUp) {
|
||||||
firstDay.add(Calendar.DAY_OF_MONTH, -DAYS_PER_WEEK);
|
month = child.getMonthOfFirstWeekDay();
|
||||||
} else {
|
} else {
|
||||||
firstDay.add(Calendar.DAY_OF_MONTH, DAYS_PER_WEEK);
|
month = child.getMonthOfLastWeekDay();
|
||||||
|
}
|
||||||
|
|
||||||
|
// And how it relates to our current highlighted month
|
||||||
|
int monthDiff;
|
||||||
|
if (mCurrentMonthDisplayed == 11 && month == 0) {
|
||||||
|
monthDiff = 1;
|
||||||
|
} else if (mCurrentMonthDisplayed == 0 && month == 11) {
|
||||||
|
monthDiff = -1;
|
||||||
|
} else {
|
||||||
|
monthDiff = month - mCurrentMonthDisplayed;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only switch months if we're scrolling away from the currently
|
||||||
|
// selected month
|
||||||
|
if ((!mIsScrollingUp && monthDiff > 0) || (mIsScrollingUp && monthDiff < 0)) {
|
||||||
|
Calendar firstDay = child.getFirstDay();
|
||||||
|
if (mIsScrollingUp) {
|
||||||
|
firstDay.add(Calendar.DAY_OF_MONTH, -DAYS_PER_WEEK);
|
||||||
|
} else {
|
||||||
|
firstDay.add(Calendar.DAY_OF_MONTH, DAYS_PER_WEEK);
|
||||||
|
}
|
||||||
|
setMonthDisplayed(firstDay);
|
||||||
}
|
}
|
||||||
setMonthDisplayed(firstDay);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mPreviousScrollPosition = currScroll;
|
mPreviousScrollPosition = currScroll;
|
||||||
mPreviousScrollState = mCurrentScrollState;
|
mPreviousScrollState = mCurrentScrollState;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user