Implement AnimatedImageDrawable.getColorFilter
Test: CTS: Ie9766f24164d6b035944b1fe82c2d285482ad1d2
Change-Id: I7f2cb0da918ae67c7a5906a478012fa25678294c
diff --git a/graphics/java/android/graphics/drawable/AnimatedImageDrawable.java b/graphics/java/android/graphics/drawable/AnimatedImageDrawable.java
index 86e6fa8..598807d 100644
--- a/graphics/java/android/graphics/drawable/AnimatedImageDrawable.java
+++ b/graphics/java/android/graphics/drawable/AnimatedImageDrawable.java
@@ -83,6 +83,8 @@
private Runnable mRunnable;
+ private ColorFilter mColorFilter;
+
/**
* Pass this to {@link #setLoopCount} to loop infinitely.
*
@@ -276,9 +278,18 @@
throw new IllegalStateException("called setColorFilter on empty AnimatedImageDrawable");
}
- long nativeFilter = colorFilter == null ? 0 : colorFilter.getNativeInstance();
- nSetColorFilter(mState.mNativePtr, nativeFilter);
- invalidateSelf();
+ if (colorFilter != mColorFilter) {
+ mColorFilter = colorFilter;
+ long nativeFilter = colorFilter == null ? 0 : colorFilter.getNativeInstance();
+ nSetColorFilter(mState.mNativePtr, nativeFilter);
+ invalidateSelf();
+ }
+ }
+
+ @Override
+ @Nullable
+ public ColorFilter getColorFilter() {
+ return mColorFilter;
}
@Override