Temporary fix for background invalidation
Not a complete solution, since we could be more efficient, but enough
to have both background display lists and proper invalidation.
Change-Id: I0216a104948c0930760275bb2b98318b0a4487e7
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 4b6f2b0..2ccca37 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -15359,18 +15359,16 @@
public void invalidateDrawable(Drawable drawable) {
if (verifyDrawable(drawable)) {
if (drawable == mBackground && mBackgroundDisplayList != null) {
- // If we're using a background display list, we only need to
- // invalidate the display list and notify the parent to redraw.
+ // We'll need to redraw the display list.
mBackgroundDisplayList.clear();
- invalidateViewProperty(true, false);
- } else {
- final Rect dirty = drawable.getBounds();
- final int scrollX = mScrollX;
- final int scrollY = mScrollY;
-
- invalidate(dirty.left + scrollX, dirty.top + scrollY,
- dirty.right + scrollX, dirty.bottom + scrollY);
}
+
+ final Rect dirty = drawable.getBounds();
+ final int scrollX = mScrollX;
+ final int scrollY = mScrollY;
+
+ invalidate(dirty.left + scrollX, dirty.top + scrollY,
+ dirty.right + scrollX, dirty.bottom + scrollY);
}
}
@@ -15382,6 +15380,7 @@
* @param when the time at which the action must occur. Uses the
* {@link SystemClock#uptimeMillis} timebase.
*/
+ @Override
public void scheduleDrawable(Drawable who, Runnable what, long when) {
if (verifyDrawable(who) && what != null) {
final long delay = when - SystemClock.uptimeMillis();
@@ -15401,6 +15400,7 @@
* @param who the recipient of the action
* @param what the action to cancel
*/
+ @Override
public void unscheduleDrawable(Drawable who, Runnable what) {
if (verifyDrawable(who) && what != null) {
if (mAttachInfo != null) {
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 3be23b7..65b79fc 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -4814,6 +4814,8 @@
@Override
public void invalidateDrawable(Drawable drawable) {
+ boolean handled = false;
+
if (verifyDrawable(drawable)) {
final Rect dirty = drawable.getBounds();
int scrollX = mScrollX;
@@ -4831,6 +4833,7 @@
scrollX += mPaddingLeft;
scrollY += compoundPaddingTop + (vspace - drawables.mDrawableHeightLeft) / 2;
+ handled = true;
} else if (drawable == drawables.mDrawableRight) {
final int compoundPaddingTop = getCompoundPaddingTop();
final int compoundPaddingBottom = getCompoundPaddingBottom();
@@ -4838,6 +4841,7 @@
scrollX += (mRight - mLeft - mPaddingRight - drawables.mDrawableSizeRight);
scrollY += compoundPaddingTop + (vspace - drawables.mDrawableHeightRight) / 2;
+ handled = true;
} else if (drawable == drawables.mDrawableTop) {
final int compoundPaddingLeft = getCompoundPaddingLeft();
final int compoundPaddingRight = getCompoundPaddingRight();
@@ -4845,6 +4849,7 @@
scrollX += compoundPaddingLeft + (hspace - drawables.mDrawableWidthTop) / 2;
scrollY += mPaddingTop;
+ handled = true;
} else if (drawable == drawables.mDrawableBottom) {
final int compoundPaddingLeft = getCompoundPaddingLeft();
final int compoundPaddingRight = getCompoundPaddingRight();
@@ -4852,11 +4857,18 @@
scrollX += compoundPaddingLeft + (hspace - drawables.mDrawableWidthBottom) / 2;
scrollY += (mBottom - mTop - mPaddingBottom - drawables.mDrawableSizeBottom);
+ handled = true;
}
}
- invalidate(dirty.left + scrollX, dirty.top + scrollY,
- dirty.right + scrollX, dirty.bottom + scrollY);
+ if (handled) {
+ invalidate(dirty.left + scrollX, dirty.top + scrollY,
+ dirty.right + scrollX, dirty.bottom + scrollY);
+ }
+ }
+
+ if (!handled) {
+ super.invalidateDrawable(drawable);
}
}