diff options
| -rw-r--r-- | core/java/android/view/PointerIcon.java | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/core/java/android/view/PointerIcon.java b/core/java/android/view/PointerIcon.java index 13b9c4518711..f5f4fd9f7042 100644 --- a/core/java/android/view/PointerIcon.java +++ b/core/java/android/view/PointerIcon.java @@ -480,11 +480,19 @@ public final class PointerIcon implements Parcelable { mBitmapFrames = new Bitmap[frames - 1]; final int width = drawable.getIntrinsicWidth(); final int height = drawable.getIntrinsicHeight(); + final boolean isVectorAnimation = drawable instanceof VectorDrawable; + mDrawNativeDropShadow = isVectorAnimation; for (int i = 1; i < frames; ++i) { Drawable drawableFrame = animationDrawable.getFrame(i); - if (!(drawableFrame instanceof BitmapDrawable)) { + if (!(drawableFrame instanceof BitmapDrawable) + && !(drawableFrame instanceof VectorDrawable)) { throw new IllegalArgumentException("Frame of an animated pointer icon " - + "must refer to a bitmap drawable."); + + "must refer to a bitmap drawable or vector drawable."); + } + if (isVectorAnimation != (drawableFrame instanceof VectorDrawable)) { + throw new IllegalArgumentException("The drawable of the " + i + "-th frame " + + "is a different type from the others. All frames should be the " + + "same type."); } if (drawableFrame.getIntrinsicWidth() != width || drawableFrame.getIntrinsicHeight() != height) { @@ -492,8 +500,11 @@ public final class PointerIcon implements Parcelable { + "is different. All frames should have the exact same size and " + "share the same hotspot."); } - BitmapDrawable bitmapDrawableFrame = (BitmapDrawable) drawableFrame; - mBitmapFrames[i - 1] = getBitmapFromDrawable(bitmapDrawableFrame); + if (isVectorAnimation) { + drawableFrame = getBitmapDrawableFromVectorDrawable(resources, + (VectorDrawable) drawableFrame); + } + mBitmapFrames[i - 1] = getBitmapFromDrawable((BitmapDrawable) drawableFrame); } } } |