Merge change 2361 into donut

* changes:
  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.
This commit is contained in:
Android (Google) Code Review
2009-05-22 14:49:19 -07:00

View File

@@ -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);