diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2014-03-06 00:45:47 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-03-06 00:45:47 +0000 |
commit | 9c9185348ad2487aad043c565fe221b4a56ef0b9 (patch) | |
tree | cefeb9341e3b2d7d1bed19862cd43df6e7b54136 | |
parent | dfb76305c78ac596cf025e3410a04bd8221cfeab (diff) | |
parent | db3e77825d339cbe8840486bffbf7e03a53c1c4c (diff) | |
download | frameworks_base-9c9185348ad2487aad043c565fe221b4a56ef0b9.zip frameworks_base-9c9185348ad2487aad043c565fe221b4a56ef0b9.tar.gz frameworks_base-9c9185348ad2487aad043c565fe221b4a56ef0b9.tar.bz2 |
am db3e7782: am 71c3a3d9: am 6c3a45d7: am 57f8a4b4: am 1ff2df61: Merge "Fix bug #12066726 java.lang.NullPointerException at android.widget.CalendarView.onScroll(CalendarView.java:1216) - DO NOT MERGE" into klp-dev
* commit 'db3e77825d339cbe8840486bffbf7e03a53c1c4c':
Fix bug #12066726 java.lang.NullPointerException at android.widget.CalendarView.onScroll(CalendarView.java:1216) - DO NOT MERGE
-rw-r--r-- | core/java/android/widget/CalendarView.java | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/core/java/android/widget/CalendarView.java b/core/java/android/widget/CalendarView.java index 0957ab4..e90b460 100644 --- a/core/java/android/widget/CalendarView.java +++ b/core/java/android/widget/CalendarView.java @@ -1210,35 +1210,38 @@ public class CalendarView extends FrameLayout { child = (WeekView) view.getChildAt(offset); } - // Find out which month we're moving into - int month; - if (mIsScrollingUp) { - 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 (child != null) { + // Find out which month we're moving into + int month; if (mIsScrollingUp) { - firstDay.add(Calendar.DAY_OF_MONTH, -DAYS_PER_WEEK); + month = child.getMonthOfFirstWeekDay(); } 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; mPreviousScrollState = mCurrentScrollState; } |