Fixed canteen legend icons

This commit is contained in:
Sebastian Seedorf
2019-10-20 15:31:27 +02:00
parent ab6d81ec8b
commit d8f60635fb

View File

@@ -9,6 +9,7 @@ import android.util.AttributeSet;
import androidx.appcompat.widget.AppCompatTextView;
import de.sebse.fuplanner.R;
import de.sebse.fuplanner.tools.logging.Logger;
public class TextViewDrawableSize extends AppCompatTextView {
@@ -17,29 +18,21 @@ public class TextViewDrawableSize extends AppCompatTextView {
public TextViewDrawableSize(Context context) {
super(context);
init(context, null, 0, 0);
init(context, null, 0);
}
public TextViewDrawableSize(Context context, AttributeSet attrs) {
super(context, attrs);
init(context, attrs, 0, 0);
init(context, attrs, 0);
}
public TextViewDrawableSize(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context, attrs, defStyleAttr, 0);
init(context, attrs, defStyleAttr);
}
/*@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public TextViewDrawableSize(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr);
init(context, attrs, defStyleAttr);
//super(context, attrs, defStyleAttr, defStyleRes);
//init(context, attrs, defStyleAttr, defStyleRes);
}*/
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.TextViewDrawableSize, defStyleAttr, defStyleRes);
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.TextViewDrawableSize, defStyleAttr, 0);
try {
mDrawableWidth = array.getDimensionPixelSize(R.styleable.TextViewDrawableSize_compoundDrawableWidth, -1);
@@ -54,7 +47,7 @@ public class TextViewDrawableSize extends AppCompatTextView {
}
private void initCompoundDrawableSize() {
Drawable[] drawables = getCompoundDrawables();
Drawable[] drawables = getCompoundDrawablesRelative();
for (Drawable drawable : drawables) {
if (drawable == null) {
continue;
@@ -75,7 +68,6 @@ public class TextViewDrawableSize extends AppCompatTextView {
}
if (mDrawableHeight > 0) {
// save scale factor of image
if (drawableHeight > mDrawableHeight) {
drawableHeight = mDrawableHeight;
drawableWidth = drawableHeight / scaleFactor;
@@ -87,6 +79,6 @@ public class TextViewDrawableSize extends AppCompatTextView {
drawable.setBounds(realBounds);
}
setCompoundDrawables(drawables[0], drawables[1], drawables[2], drawables[3]);
setCompoundDrawablesRelative(drawables[0], drawables[1], drawables[2], drawables[3]);
}
}