Java Code Examples for android.graphics.drawable.Drawable#getState()
The following examples show how to use
android.graphics.drawable.Drawable#getState() .
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: SkinCompatDrawableUtils.java From Android-skin-support with MIT License | 5 votes |
/** * VectorDrawable has an issue on API 21 where it sometimes doesn't create its tint filter. * Fixed by toggling it's state to force a filter creation. */ private static void fixVectorDrawableTinting(final Drawable drawable) { final int[] originalState = drawable.getState(); if (originalState == null || originalState.length == 0) { // The drawable doesn't have a state, so set it to be checked drawable.setState(SkinCompatThemeUtils.CHECKED_STATE_SET); } else { // Else the drawable does have a state, so clear it drawable.setState(SkinCompatThemeUtils.EMPTY_STATE_SET); } // Now set the original state drawable.setState(originalState); }
Example 2
Source File: SkinCompatDrawableUtils.java From Android-skin-support with MIT License | 5 votes |
/** * VectorDrawable has an issue on API 21 where it sometimes doesn't create its tint filter. * Fixed by toggling it's state to force a filter creation. */ private static void fixVectorDrawableTinting(final Drawable drawable) { final int[] originalState = drawable.getState(); if (originalState == null || originalState.length == 0) { // The drawable doesn't have a state, so set it to be checked drawable.setState(SkinCompatThemeUtils.CHECKED_STATE_SET); } else { // Else the drawable does have a state, so clear it drawable.setState(SkinCompatThemeUtils.EMPTY_STATE_SET); } // Now set the original state drawable.setState(originalState); }
Example 3
Source File: DrawableUtils.java From RangeSeekBar with MIT License | 5 votes |
private static void fixVectorDrawableTinting(final Drawable drawable) { final int[] originalState = drawable.getState(); if (originalState == null || originalState.length == 0) { drawable.setState(ThemeUtils.CHECKED_STATE_SET); } else { drawable.setState(ThemeUtils.EMPTY_STATE_SET); } drawable.setState(originalState); }
Example 4
Source File: ExpirableBitmapDrawable.java From osmdroid with Apache License 2.0 | 5 votes |
public static int getState(final Drawable pTile) { for(final int statusItem : pTile.getState()) { for (final int statusReference : settableStatuses) { if (statusItem == statusReference) { return statusItem; } } } return defaultStatus; }
Example 5
Source File: BitmapUtils.java From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License | 4 votes |
public static boolean isCacheDrawableExpired(Drawable drawable) { if (drawable != null && drawable.getState() == EXPIRED) { return true; } return false; }