diff options
| author | 2016-03-28 21:21:44 +0000 | |
|---|---|---|
| committer | 2016-03-28 21:21:45 +0000 | |
| commit | 4edfdd55cf0459c0d02b073ac38053b20060ec2f (patch) | |
| tree | f27e92b36ae422af99969b4e89170131a555a1e3 | |
| parent | 12bf75f35406f49ab531a9bea9847663ef20d62e (diff) | |
| parent | e66be622f66b5770b686da608bbf3577261c1d72 (diff) | |
Merge "Fix NPE while using mLayerPaint" into nyc-dev
| -rw-r--r-- | core/java/android/view/View.java | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 83c6e9e1ab83..4e6735acf1e1 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -16855,9 +16855,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } else { // use layer paint to draw the bitmap, merging the two alphas, but also restore int layerPaintAlpha = mLayerPaint != null ? mLayerPaint.getAlpha() : 255; - mLayerPaint.setAlpha((int) (alpha * layerPaintAlpha)); + if (mLayerPaint == null && alpha < 1) { + mLayerPaint = new Paint(); + mLayerPaint.setAlpha((int) (alpha * layerPaintAlpha)); + } canvas.drawBitmap(cache, 0.0f, 0.0f, mLayerPaint); - mLayerPaint.setAlpha(layerPaintAlpha); + if (mLayerPaint != null) { + mLayerPaint.setAlpha(layerPaintAlpha); + } } } |