diff --git a/dynamic-utils/src/main/java/com/pranavpandey/android/dynamic/utils/DynamicDrawableUtils.java b/dynamic-utils/src/main/java/com/pranavpandey/android/dynamic/utils/DynamicDrawableUtils.java index 59bf548..34ea1a8 100644 --- a/dynamic-utils/src/main/java/com/pranavpandey/android/dynamic/utils/DynamicDrawableUtils.java +++ b/dynamic-utils/src/main/java/com/pranavpandey/android/dynamic/utils/DynamicDrawableUtils.java @@ -65,14 +65,11 @@ public static void setBackground(@NonNull View view, @Nullable Drawable drawable @Nullable Drawable drawable, boolean wrap, @NonNull ColorFilter colorFilter) { if (drawable != null) { if (wrap) { - drawable = DrawableCompat.wrap(drawable.mutate()); + drawable = drawable.mutate(); } drawable.setColorFilter(colorFilter); - - if (!DynamicVersionUtils.isMarshmallow()) { - drawable.invalidateSelf(); - } + drawable.invalidateSelf(); } return drawable; @@ -97,20 +94,26 @@ public static void setBackground(@NonNull View view, @Nullable Drawable drawable @Nullable Drawable drawable, boolean wrap, @ColorInt int color, @Nullable PorterDuff.Mode mode) { if (drawable != null) { - if (wrap) { - drawable = DrawableCompat.wrap(drawable.mutate()); + if (mode == null) { + mode = PorterDuff.Mode.SRC_IN; } - if (mode != null) { - DrawableCompat.setTintMode(drawable, mode); + // Handle issue with layer drawables. + if (DynamicVersionUtils.isLollipop(true)) { + if (wrap) { + drawable = drawable.mutate(); + drawable.setColorFilter(color, mode); + } } else { - DrawableCompat.setTintMode(drawable, PorterDuff.Mode.SRC_IN); - } - DrawableCompat.setTint(drawable, color); + if (wrap) { + drawable = DrawableCompat.wrap(drawable.mutate()); + } - if (!DynamicVersionUtils.isMarshmallow()) { - drawable.invalidateSelf(); + DrawableCompat.setTintMode(drawable, mode); + DrawableCompat.setTint(drawable, color); } + + drawable.invalidateSelf(); } return drawable; diff --git a/dynamic-utils/src/main/java/com/pranavpandey/android/dynamic/utils/DynamicWindowUtils.java b/dynamic-utils/src/main/java/com/pranavpandey/android/dynamic/utils/DynamicWindowUtils.java index 324faea..748de61 100644 --- a/dynamic-utils/src/main/java/com/pranavpandey/android/dynamic/utils/DynamicWindowUtils.java +++ b/dynamic-utils/src/main/java/com/pranavpandey/android/dynamic/utils/DynamicWindowUtils.java @@ -50,13 +50,8 @@ public class DynamicWindowUtils { if (windowManager != null) { Display display = windowManager.getDefaultDisplay(); - - if (DynamicVersionUtils.isHoneycombMR2()) { - display.getSize(size); - } else { - size.x = display.getWidth(); - size.y = display.getHeight(); - } + size.x = display.getWidth(); + size.y = display.getHeight(); } return size;