what-the-bank/sources/com/scb/phone/view/custom/common/DefaultButton.java

132 lines
4.0 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.scb.phone.view.custom.common;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.scb.phone.R;
import o.C15715hv;
import o.nMh;
@Deprecated
/* loaded from: classes5.dex */
public class DefaultButton extends RelativeLayout {
private int a;
private Drawable b;
private boolean c;
private Drawable d;
private Drawable e;
private int f;
private int g;
private String h;
private String j;
@BindView
ImageView mIconImageView;
@BindView
ImageView mIconImageViewRight;
@BindView
View mRippleView;
@BindView
TextView mTextView;
public DefaultButton(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, C15715hv.jbe.CustomButtonOptions, 0, 0);
this.j = obtainStyledAttributes.getString(6);
this.f = obtainStyledAttributes.getDimensionPixelSize(8, 0);
this.h = obtainStyledAttributes.getString(1);
this.g = obtainStyledAttributes.getColor(7, nMh.getColor(context, R.color.f14042131100912));
this.d = obtainStyledAttributes.getDrawable(2);
this.e = obtainStyledAttributes.getDrawable(3);
this.a = obtainStyledAttributes.getColor(4, nMh.getColor(context, R.color.f14042131100912));
this.b = obtainStyledAttributes.getDrawable(5);
this.c = obtainStyledAttributes.getBoolean(0, true);
obtainStyledAttributes.recycle();
((LayoutInflater) context.getSystemService("layout_inflater")).inflate(R.layout.2131558988, (ViewGroup) this, true);
ButterKnife.c(this);
setClickable(true);
String str = this.j;
if (str != null) {
this.mTextView.setText(str);
}
this.mTextView.setTextColor(this.g);
int i = this.f;
if (i != 0) {
this.mTextView.setTextSize(0, i);
}
if (!TextUtils.isEmpty(this.h)) {
this.mTextView.setTypeface(Typeface.createFromAsset(getContext().getAssets(), this.h));
}
Drawable drawable = this.b;
if (drawable != null) {
this.mRippleView.setBackground(drawable);
}
if (this.d != null) {
this.mIconImageView.setVisibility(0);
this.mIconImageView.setImageDrawable(this.d);
this.mIconImageView.setColorFilter(this.a);
} else {
this.mIconImageView.setVisibility(8);
}
if (this.e != null) {
this.mIconImageViewRight.setVisibility(0);
this.mIconImageViewRight.setImageDrawable(this.e);
this.mIconImageViewRight.setColorFilter(this.a);
} else {
this.mIconImageViewRight.setVisibility(8);
}
setButtonEnabled(this.c);
}
public DefaultButton(Context context) {
this(context, null);
}
public DefaultButton(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i, 0);
}
public void setTextColor(int i) {
this.g = i;
this.mTextView.setTextColor(i);
}
public void setText(String str) {
this.j = str;
this.mTextView.setText(str);
}
public void setTextAllCaps(boolean z) {
this.mTextView.setAllCaps(z);
}
public void setRipple(Drawable drawable) {
if (drawable != null) {
this.mRippleView.setBackground(drawable);
}
}
public void setButtonEnabled(boolean z) {
setEnabled(z);
if (z) {
setAlpha(1.0f);
} else {
setAlpha(0.6f);
}
}
}