(Drawable drawable, int index)
| 474 | private static Field BitmapDrawable_mColorFilter; |
| 475 | |
| 476 | @SuppressLint("PrivateApi") |
| 477 | private static Drawable getStateDrawable(Drawable drawable, int index) { |
| 478 | if (Build.VERSION.SDK_INT >= 29 && drawable instanceof StateListDrawable) { |
| 479 | return ((StateListDrawable) drawable).getStateDrawable(index); |
| 480 | } else { |
| 481 | if (StateListDrawable_getStateDrawableMethod == null) { |
| 482 | try { |
| 483 | StateListDrawable_getStateDrawableMethod = StateListDrawable.class.getDeclaredMethod("getStateDrawable", int.class); |
| 484 | } catch (Throwable ignore) { |
| 485 | |
| 486 | } |
| 487 | } |
| 488 | if (StateListDrawable_getStateDrawableMethod == null) { |
| 489 | return null; |
| 490 | } |
| 491 | try { |
| 492 | return (Drawable) StateListDrawable_getStateDrawableMethod.invoke(drawable, index); |
| 493 | } catch (Exception ignore) { |
| 494 | |
| 495 | } |
| 496 | return null; |
| 497 | } |
| 498 | } |
| 499 | |
| 500 | public static void setSelectorDrawableColor(Drawable drawable, int color, boolean selected) { |
| 501 | if (drawable instanceof StateListDrawable) { |
no test coverage detected