From b6888167d39bbfdb3e26e12f267c6d1abc6ce2b2 Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Fri, 22 May 2009 14:09:29 -0700 Subject: Fixes #1872506. Prevents NPE in ListView. When the opaque property changes at runtime, it is possible to end up in a situation in which the divider's Paint instance has not been instanciated. This change simples uses a final Paint that is guaranteed to not be null. --- core/java/android/widget/ListView.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/core/java/android/widget/ListView.java b/core/java/android/widget/ListView.java index 6686f75..e96ab20 100644 --- a/core/java/android/widget/ListView.java +++ b/core/java/android/widget/ListView.java @@ -134,7 +134,7 @@ public class ListView extends AbsListView { // used for temporary calculations. private final Rect mTempRect = new Rect(); - private Paint mDividerPaint; + private final Paint mDividerPaint = new Paint(); // the single allocated result per list view; kinda cheesey but avoids // allocating these thingies too often. @@ -2824,9 +2824,6 @@ public class ListView extends AbsListView { final boolean opaque = (color >>> 24) == 0xFF; mIsCacheColorOpaque = opaque; if (opaque) { - if (mDividerPaint == null) { - mDividerPaint = new Paint(); - } mDividerPaint.setColor(color); } super.setCacheColorHint(color); -- cgit v1.1