diff options
author | Winson Chung <winsonc@google.com> | 2015-05-14 15:38:22 -0700 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2015-05-14 22:56:03 +0000 |
commit | 4ddc340f677e03807139825daa8716f7cbd59a26 (patch) | |
tree | faf1342742f4aa2f1807d7414d9c0f168676c05d | |
parent | f7e85f85d373103e45c9a54df0827efe94417031 (diff) | |
download | android_packages_apps_Trebuchet-4ddc340f677e03807139825daa8716f7cbd59a26.tar.gz android_packages_apps_Trebuchet-4ddc340f677e03807139825daa8716f7cbd59a26.tar.bz2 android_packages_apps_Trebuchet-4ddc340f677e03807139825daa8716f7cbd59a26.zip |
Fixing crash when drawing prediction bar divider.
-rw-r--r-- | src/com/android/launcher3/AppsContainerView.java | 1 | ||||
-rw-r--r-- | src/com/android/launcher3/AppsGridAdapter.java | 14 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/com/android/launcher3/AppsContainerView.java b/src/com/android/launcher3/AppsContainerView.java index 7c1aee228..7694cbddc 100644 --- a/src/com/android/launcher3/AppsContainerView.java +++ b/src/com/android/launcher3/AppsContainerView.java @@ -396,6 +396,7 @@ public class AppsContainerView extends BaseContainerView implements DragSource, inset, 0, inset, 0); mContentView.setBackground(background); mAppsRecyclerView.updateBackgroundPadding(background); + mAdapter.updateBackgroundPadding(background); getRevealView().setBackground(background.getConstantState().newDrawable()); } diff --git a/src/com/android/launcher3/AppsGridAdapter.java b/src/com/android/launcher3/AppsGridAdapter.java index dfbfa01da..d5a411e66 100644 --- a/src/com/android/launcher3/AppsGridAdapter.java +++ b/src/com/android/launcher3/AppsGridAdapter.java @@ -6,6 +6,7 @@ import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.PointF; import android.graphics.Rect; +import android.graphics.drawable.Drawable; import android.os.Handler; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.RecyclerView; @@ -112,9 +113,9 @@ class AppsGridAdapter extends RecyclerView.Adapter<AppsGridAdapter.ViewHolder> { if (shouldDrawItemDivider(holder, items) && !hasDrawnPredictedAppsDivider) { // Draw the divider under the predicted apps - parent.getBackground().getPadding(mTmpBounds); int top = child.getTop() + child.getHeight(); - c.drawLine(mTmpBounds.left, top, parent.getWidth() - mTmpBounds.right, top, + c.drawLine(mBackgroundPadding.left, top, + parent.getWidth() - mBackgroundPadding.right, top, mPredictedAppsDividerPaint); hasDrawnPredictedAppsDivider = true; @@ -265,6 +266,7 @@ class AppsGridAdapter extends RecyclerView.Adapter<AppsGridAdapter.ViewHolder> { private View.OnTouchListener mTouchListener; private View.OnClickListener mIconClickListener; private View.OnLongClickListener mIconLongClickListener; + @Thunk final Rect mBackgroundPadding = new Rect(); @Thunk int mPredictionBarHeight; @Thunk int mAppsPerRow; @Thunk boolean mIsRtl; @@ -341,6 +343,14 @@ class AppsGridAdapter extends RecyclerView.Adapter<AppsGridAdapter.ViewHolder> { } /** + * Notifies the adapter of the background padding so that it can draw things correctly in the + * item decorator. + */ + public void updateBackgroundPadding(Drawable background) { + background.getPadding(mBackgroundPadding); + } + + /** * Returns the grid layout manager. */ public GridLayoutManager getLayoutManager() { |