Skip to content

Commit b2cdcfd

Browse files
author
roman_tcaregorodtcev
committed
Fixed review 2
1 parent 4381e1f commit b2cdcfd

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

app/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
android:drawableRight="@drawable/ic_android_black_24dp"
2424
android:text="Great"
2525
android:textSize="14sp"
26-
app:drawableSize="40sp"
26+
app:drawableSize="40dp"
2727
android:theme="@style/AccentButtonStyle" />
2828

2929
<com.omega_r.libs.OmegaCenterIconButton

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import android.util.AttributeSet;
1111

1212
import androidx.annotation.ColorInt;
13-
import androidx.annotation.DrawableRes;
1413
import androidx.annotation.NonNull;
1514
import androidx.annotation.Nullable;
1615
import androidx.appcompat.widget.AppCompatButton;
@@ -83,16 +82,23 @@ private void updateDrawables() {
8382
if (mTintColor != Color.TRANSPARENT) {
8483
wrappedDrawable = getTintedDrawable(wrappedDrawable);
8584
}
86-
if (mDrawableSize != -1) {
85+
if (mDrawableSize > 0) {
8786
wrappedDrawable = updateDrawableBounds(wrappedDrawable);
8887
}
8988
wrappedDrawables[i] = wrappedDrawable;
9089
}
9190
}
92-
setCompoundDrawables(wrappedDrawables[DRAWABLE_LEFT_POSITION],
93-
wrappedDrawables[DRAWABLE_TOP_POSITION],
94-
wrappedDrawables[DRAWABLE_RIGHT_POSITION],
95-
wrappedDrawables[DRAWABLE_BOTTOM_POSITION]);
91+
if (mDrawableSize > 0) {
92+
setCompoundDrawables(wrappedDrawables[DRAWABLE_LEFT_POSITION],
93+
wrappedDrawables[DRAWABLE_TOP_POSITION],
94+
wrappedDrawables[DRAWABLE_RIGHT_POSITION],
95+
wrappedDrawables[DRAWABLE_BOTTOM_POSITION]);
96+
} else {
97+
setCompoundDrawablesWithIntrinsicBounds(wrappedDrawables[DRAWABLE_LEFT_POSITION],
98+
wrappedDrawables[DRAWABLE_TOP_POSITION],
99+
wrappedDrawables[DRAWABLE_RIGHT_POSITION],
100+
wrappedDrawables[DRAWABLE_BOTTOM_POSITION]);
101+
}
96102
}
97103
}
98104

0 commit comments

Comments
 (0)