diff options
author | Michael Jurka <mikejurka@google.com> | 2010-09-02 17:19:20 -0700 |
---|---|---|
committer | Michael Jurka <mikejurka@google.com> | 2010-09-02 17:25:33 -0700 |
commit | c4fb9173e73c0092a089512734c0d7df13189014 (patch) | |
tree | 1430251d636551a9dddab370a513a257c9367563 /src | |
parent | 5f2aa4efeeb8b0133d891715d71553138d9f9ca7 (diff) | |
download | android_packages_apps_Trebuchet-c4fb9173e73c0092a089512734c0d7df13189014.tar.gz android_packages_apps_Trebuchet-c4fb9173e73c0092a089512734c0d7df13189014.tar.bz2 android_packages_apps_Trebuchet-c4fb9173e73c0092a089512734c0d7df13189014.zip |
Fix crash when clicking "Games" or "Downloaded"
tabs in All Apps.
Change-Id: I832376368a07d65543d142790c8876e16c65067a
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher2/PagedView.java | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java index 8e0203b8a..48f42a1ca 100644 --- a/src/com/android/launcher2/PagedView.java +++ b/src/com/android/launcher2/PagedView.java @@ -367,34 +367,36 @@ public abstract class PagedView extends ViewGroup { // As an optimization, this code assumes that all pages have the same width as the 0th // page. - final int pageWidth = getChildAt(0).getMeasuredWidth(); final int pageCount = getChildCount(); - final int screenWidth = getMeasuredWidth(); - int x = getRelativeChildOffset(0) + pageWidth; - int leftScreen = 0; - int rightScreen = 0; - while (x <= mScrollX) { - leftScreen++; - x += pageWidth; - // replace above line with this if you don't assume all pages have same width as 0th - // page: - // x += getChildAt(leftScreen).getMeasuredWidth(); - } - rightScreen = leftScreen; - while (x < mScrollX + screenWidth) { - rightScreen++; - x += pageWidth; - // replace above line with this if you don't assume all pages have same width as 0th - // page: - //if (rightScreen < pageCount) { - // x += getChildAt(rightScreen).getMeasuredWidth(); - //} - } - rightScreen = Math.min(getChildCount() - 1, rightScreen); + if (pageCount > 0) { + final int pageWidth = getChildAt(0).getMeasuredWidth(); + final int screenWidth = getMeasuredWidth(); + int x = getRelativeChildOffset(0) + pageWidth; + int leftScreen = 0; + int rightScreen = 0; + while (x <= mScrollX) { + leftScreen++; + x += pageWidth; + // replace above line with this if you don't assume all pages have same width as 0th + // page: + // x += getChildAt(leftScreen).getMeasuredWidth(); + } + rightScreen = leftScreen; + while (x < mScrollX + screenWidth) { + rightScreen++; + x += pageWidth; + // replace above line with this if you don't assume all pages have same width as 0th + // page: + //if (rightScreen < pageCount) { + // x += getChildAt(rightScreen).getMeasuredWidth(); + //} + } + rightScreen = Math.min(getChildCount() - 1, rightScreen); - final long drawingTime = getDrawingTime(); - for (int i = leftScreen; i <= rightScreen; i++) { - drawChild(canvas, getChildAt(i), drawingTime); + final long drawingTime = getDrawingTime(); + for (int i = leftScreen; i <= rightScreen; i++) { + drawChild(canvas, getChildAt(i), drawingTime); + } } } |