android.graphics.drawable.DrawableWrapper Java Examples
The following examples show how to use
android.graphics.drawable.DrawableWrapper.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DrawableUtils.java From RangeSeekBar with MIT License | 6 votes |
public static boolean canSafelyMutateDrawable(@NonNull Drawable drawable) { if (drawable instanceof DrawableContainer) { // If we have a DrawableContainer, let's traverse it's child array final Drawable.ConstantState state = drawable.getConstantState(); if (state instanceof DrawableContainer.DrawableContainerState) { final DrawableContainer.DrawableContainerState containerState = (DrawableContainer.DrawableContainerState) state; for (final Drawable child : containerState.getChildren()) { if (!canSafelyMutateDrawable(child)) { return false; } } } } else if (drawable instanceof DrawableWrapper) { return canSafelyMutateDrawable( Objects.requireNonNull(((DrawableWrapper) drawable).getDrawable())); } else if (drawable instanceof ScaleDrawable) { return canSafelyMutateDrawable(Objects.requireNonNull(((ScaleDrawable) drawable).getDrawable())); } return true; }