Skip to content

Commit 202cab7

Browse files
Merge pull request #5 from Omega-R/develop
Fixed tint drawable
2 parents b98a409 + 6ccaac2 commit 202cab7

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
buildscript {
44
ext.kotlin_version = '1.2.30'
5-
ext.supportLibraryVersion = '27.1.0'
5+
ext.supportLibraryVersion = '27.1.1'
66
ext.targetSdkVersion = 27
77
ext.compileSdkVersion = 27
88
ext.minSdkVersion = 14
@@ -14,7 +14,7 @@ buildscript {
1414
maven { url 'https://jitpack.io' }
1515
}
1616
dependencies {
17-
classpath 'com.android.tools.build:gradle:3.0.1'
17+
classpath 'com.android.tools.build:gradle:3.1.1'
1818
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1919
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
2020

center_icon_button/src/main/java/com/omega_r/libs/OmegaCenterIconButton.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,21 @@ private void init(Context context, AttributeSet attrs) {
6868
private void updateTint() {
6969
if (tintColor != Color.TRANSPARENT) {
7070
Drawable[] drawables = getCompoundDrawables();
71-
for (Drawable drawable : drawables) {
71+
if (drawables.length != DRAWABLES_LENGTH) return;
72+
73+
Drawable[] wrappedDrawables = new Drawable[DRAWABLES_LENGTH];
74+
for (int i = 0; i < DRAWABLES_LENGTH; i++) {
75+
Drawable drawable = drawables[i];
7276
if (drawable != null) {
7377
Drawable wrappedDrawable = DrawableCompat.wrap(drawable).mutate();
7478
DrawableCompat.setTint(wrappedDrawable, tintColor);
79+
wrappedDrawables[i] = wrappedDrawable;
7580
}
7681
}
77-
if (drawables.length == DRAWABLES_LENGTH) {
78-
setCompoundDrawablesWithIntrinsicBounds(drawables[DRAWABLE_LEFT_POSITION],
79-
drawables[DRAWABLE_TOP_POSITION],
80-
drawables[DRAWABLE_RIGHT_POSITION],
81-
drawables[DRAWABLE_BOTTOM_POSITION]);
82-
}
82+
setCompoundDrawablesWithIntrinsicBounds(wrappedDrawables[DRAWABLE_LEFT_POSITION],
83+
wrappedDrawables[DRAWABLE_TOP_POSITION],
84+
wrappedDrawables[DRAWABLE_RIGHT_POSITION],
85+
wrappedDrawables[DRAWABLE_BOTTOM_POSITION]);
8386
}
8487
}
8588

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

0 commit comments

Comments
 (0)