(Drawable drawable, int color, boolean selected)
| 498 | } |
| 499 | |
| 500 | public static void setSelectorDrawableColor(Drawable drawable, int color, boolean selected) { |
| 501 | if (drawable instanceof StateListDrawable) { |
| 502 | try { |
| 503 | Drawable state; |
| 504 | if (selected) { |
| 505 | state = getStateDrawable(drawable, 0); |
| 506 | if (state instanceof ShapeDrawable) { |
| 507 | ((ShapeDrawable) state).getPaint().setColor(color); |
| 508 | } else { |
| 509 | state.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY)); |
| 510 | } |
| 511 | state = getStateDrawable(drawable, 1); |
| 512 | } else { |
| 513 | state = getStateDrawable(drawable, 2); |
| 514 | } |
| 515 | if (state instanceof ShapeDrawable) { |
| 516 | ((ShapeDrawable) state).getPaint().setColor(color); |
| 517 | } else { |
| 518 | state.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY)); |
| 519 | } |
| 520 | } catch (Exception | LinkageError ignore) { |
| 521 | } |
| 522 | } else if (drawable instanceof RippleDrawable) { |
| 523 | RippleDrawable rippleDrawable = (RippleDrawable) drawable; |
| 524 | if (selected) { |
| 525 | rippleDrawable.setColor(new ColorStateList( |
| 526 | new int[][]{StateSet.WILD_CARD}, |
| 527 | new int[]{color} |
| 528 | )); |
| 529 | } else { |
| 530 | if (rippleDrawable.getNumberOfLayers() > 0) { |
| 531 | Drawable drawable1 = rippleDrawable.getDrawable(0); |
| 532 | if (drawable1 instanceof ShapeDrawable) { |
| 533 | ((ShapeDrawable) drawable1).getPaint().setColor(color); |
| 534 | } else { |
| 535 | drawable1.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY)); |
| 536 | } |
| 537 | } |
| 538 | } |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | public static class RippleRadMaskDrawable extends Drawable { |
| 543 | private Path path = new Path(); |
no test coverage detected