diff options
| author | Fabrice Di Meglio <fdimeglio@google.com> | 2013-06-18 14:09:07 -0700 |
|---|---|---|
| committer | Fabrice Di Meglio <fdimeglio@google.com> | 2013-06-18 14:09:07 -0700 |
| commit | d6d543977da14adb3ef9322a0b7ec3fdd027a55e (patch) | |
| tree | af5b111631b95ba02db9e1f5f8ba0b05b9ecf635 /core/java/android/widget/ScrollView.java | |
| parent | d6befbdd17f528d87e313b3665b248b670f8615c (diff) | |
Fix bug #9463581 NPE observed while launching News&Weather app from all apps tray
- dont suppose that there will always be one child
Change-Id: I51c5cdf06294af25c992cfbaacabbc29dd1b9ad3
Diffstat (limited to 'core/java/android/widget/ScrollView.java')
| -rw-r--r-- | core/java/android/widget/ScrollView.java | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/core/java/android/widget/ScrollView.java b/core/java/android/widget/ScrollView.java index b764c98843fb..90aa464fcdd8 100644 --- a/core/java/android/widget/ScrollView.java +++ b/core/java/android/widget/ScrollView.java @@ -1472,16 +1472,16 @@ public class ScrollView extends FrameLayout { } mChildToScrollTo = null; - // There is only one child - final View child = getChildAt(0); - final int childHeight = child.getMeasuredHeight(); if (!hasLayout()) { - final int scrollRange = Math.max(0, - childHeight - (b - t - mPaddingBottom - mPaddingTop)); if (mSavedState != null) { mScrollY = mSavedState.scrollPosition; mSavedState = null; } // mScrollY default value is "0" + + final int childHeight = (getChildCount() > 0) ? getChildAt(0).getMeasuredHeight() : 0; + final int scrollRange = Math.max(0, + childHeight - (b - t - mPaddingBottom - mPaddingTop)); + // Don't forget to clamp if (mScrollY > scrollRange) { mScrollY = scrollRange; |
