From 89f9705077c054b541af7da52be832760e2ae2e8 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Fri, 20 Sep 2013 11:32:26 -0700 Subject: Fixing small regression in PageIndicators add page, fixing NPE (Bug 10779956) Change-Id: I7ff711c6fc97987efc57bf023913e33e31ccf140 --- src/com/android/launcher3/CellLayout.java | 65 ++++++++++++++++--------------- 1 file changed, 33 insertions(+), 32 deletions(-) (limited to 'src/com/android/launcher3/CellLayout.java') diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java index 04f4d8154..901f42bdf 100644 --- a/src/com/android/launcher3/CellLayout.java +++ b/src/com/android/launcher3/CellLayout.java @@ -497,32 +497,31 @@ public class CellLayout extends ViewGroup { int height = width; cellToPoint(fra.mCellX, fra.mCellY, mTempLocation); View child = getChildAt(fra.mCellX, fra.mCellY); + if (child != null) { + int centerX = mTempLocation[0] + mCellWidth / 2; + int centerY = mTempLocation[1] + previewOffset / 2 + + child.getPaddingTop() + grid.folderBackgroundOffset; - int centerX = mTempLocation[0] + mCellWidth / 2; - int centerY = mTempLocation[1] + previewOffset / 2 + - child.getPaddingTop() + grid.folderBackgroundOffset; + canvas.save(); + canvas.translate(centerX - width / 2, centerY - height / 2); + d.setBounds(0, 0, width, height); + d.draw(canvas); + canvas.restore(); - canvas.save(); - canvas.translate(centerX - width / 2, centerY - height / 2); - d.setBounds(0, 0, width, height); - d.draw(canvas); - canvas.restore(); + // Draw inner ring + d = FolderRingAnimator.sSharedInnerRingDrawable; + width = (int) (fra.getInnerRingSize() * getChildrenScale()); + height = width; - // Draw inner ring - d = FolderRingAnimator.sSharedInnerRingDrawable; - width = (int) (fra.getInnerRingSize() * getChildrenScale()); - height = width; - cellToPoint(fra.mCellX, fra.mCellY, mTempLocation); - child = getChildAt(fra.mCellX, fra.mCellY); - - centerX = mTempLocation[0] + mCellWidth / 2; - centerY = mTempLocation[1] + previewOffset / 2 + - child.getPaddingTop() + grid.folderBackgroundOffset; - canvas.save(); - canvas.translate(centerX - width / 2, centerY - width / 2); - d.setBounds(0, 0, width, height); - d.draw(canvas); - canvas.restore(); + centerX = mTempLocation[0] + mCellWidth / 2; + centerY = mTempLocation[1] + previewOffset / 2 + + child.getPaddingTop() + grid.folderBackgroundOffset; + canvas.save(); + canvas.translate(centerX - width / 2, centerY - width / 2); + d.setBounds(0, 0, width, height); + d.draw(canvas); + canvas.restore(); + } } if (mFolderLeaveBehindCell[0] >= 0 && mFolderLeaveBehindCell[1] >= 0) { @@ -532,15 +531,17 @@ public class CellLayout extends ViewGroup { cellToPoint(mFolderLeaveBehindCell[0], mFolderLeaveBehindCell[1], mTempLocation); View child = getChildAt(mFolderLeaveBehindCell[0], mFolderLeaveBehindCell[1]); - int centerX = mTempLocation[0] + mCellWidth / 2; - int centerY = mTempLocation[1] + previewOffset / 2 + - child.getPaddingTop() + grid.folderBackgroundOffset; - - canvas.save(); - canvas.translate(centerX - width / 2, centerY - width / 2); - d.setBounds(0, 0, width, height); - d.draw(canvas); - canvas.restore(); + if (child != null) { + int centerX = mTempLocation[0] + mCellWidth / 2; + int centerY = mTempLocation[1] + previewOffset / 2 + + child.getPaddingTop() + grid.folderBackgroundOffset; + + canvas.save(); + canvas.translate(centerX - width / 2, centerY - width / 2); + d.setBounds(0, 0, width, height); + d.draw(canvas); + canvas.restore(); + } } } -- cgit v1.2.3