218 lines
11 KiB
Java
218 lines
11 KiB
Java
package com.discord.views;
|
|
|
|
import android.content.Context;
|
|
import android.content.res.ColorStateList;
|
|
import android.content.res.TypedArray;
|
|
import android.graphics.PorterDuff;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.util.AttributeSet;
|
|
import android.view.LayoutInflater;
|
|
import android.widget.FrameLayout;
|
|
import android.widget.ProgressBar;
|
|
import androidx.annotation.ColorInt;
|
|
import c.a.i.c2;
|
|
import com.discord.R;
|
|
import com.google.android.material.button.MaterialButton;
|
|
import d0.z.d.m;
|
|
/* compiled from: LoadingButton.kt */
|
|
public final class LoadingButton extends FrameLayout {
|
|
public final c2 i;
|
|
public float j;
|
|
public CharSequence k;
|
|
public Drawable l;
|
|
|
|
/* JADX INFO: Can't fix incorrect switch cases order, some code will duplicate */
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
/* JADX WARNING: Code restructure failed: missing block: B:38:0x0121, code lost:
|
|
if (r0.equals("textEnd") != false) goto L_0x0125;
|
|
*/
|
|
/* JADX WARNING: Removed duplicated region for block: B:42:0x0132 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:45:0x0143 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:46:0x0146 */
|
|
public LoadingButton(Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet, 0);
|
|
int color;
|
|
int i = 4;
|
|
m.checkNotNullParameter(context, "context");
|
|
LayoutInflater.from(context).inflate(2131558765, this);
|
|
int i2 = 2131363854;
|
|
MaterialButton materialButton = (MaterialButton) findViewById(2131363854);
|
|
if (materialButton != null) {
|
|
i2 = 2131363855;
|
|
ProgressBar progressBar = (ProgressBar) findViewById(2131363855);
|
|
if (progressBar != null) {
|
|
c2 c2Var = new c2(this, materialButton, progressBar);
|
|
m.checkNotNullExpressionValue(c2Var, "ViewLoadingButtonBinding…ater.from(context), this)");
|
|
this.i = c2Var;
|
|
this.j = 0.2f;
|
|
setClickable(true);
|
|
setFocusable(true);
|
|
if (attributeSet != null) {
|
|
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.a.LoadingButton, 0, 0);
|
|
m.checkNotNullExpressionValue(obtainStyledAttributes, "context.obtainStyledAttr…able.LoadingButton, 0, 0)");
|
|
try {
|
|
String string = obtainStyledAttributes.getString(8);
|
|
setText(string);
|
|
this.k = string;
|
|
ColorStateList colorStateList = obtainStyledAttributes.getColorStateList(9);
|
|
if (colorStateList != null) {
|
|
materialButton.setTextColor(colorStateList);
|
|
}
|
|
ColorStateList colorStateList2 = obtainStyledAttributes.getColorStateList(0);
|
|
if (colorStateList2 != null) {
|
|
m.checkNotNullExpressionValue(materialButton, "binding.loadingButtonButton");
|
|
materialButton.setBackgroundTintList(colorStateList2);
|
|
}
|
|
float dimension = obtainStyledAttributes.getDimension(10, -1.0f);
|
|
if (dimension > ((float) 0)) {
|
|
materialButton.setTextSize(0, dimension);
|
|
}
|
|
m.checkNotNullExpressionValue(materialButton, "binding.loadingButtonButton");
|
|
int dimensionPixelSize = obtainStyledAttributes.getDimensionPixelSize(6, materialButton.getPaddingTop());
|
|
m.checkNotNullExpressionValue(materialButton, "binding.loadingButtonButton");
|
|
int paddingLeft = materialButton.getPaddingLeft();
|
|
m.checkNotNullExpressionValue(materialButton, "binding.loadingButtonButton");
|
|
int paddingRight = materialButton.getPaddingRight();
|
|
m.checkNotNullExpressionValue(materialButton, "binding.loadingButtonButton");
|
|
materialButton.setPadding(paddingLeft, dimensionPixelSize, paddingRight, materialButton.getPaddingBottom());
|
|
m.checkNotNullExpressionValue(materialButton, "binding.loadingButtonButton");
|
|
int dimensionPixelSize2 = obtainStyledAttributes.getDimensionPixelSize(5, materialButton.getPaddingBottom());
|
|
m.checkNotNullExpressionValue(materialButton, "binding.loadingButtonButton");
|
|
int paddingLeft2 = materialButton.getPaddingLeft();
|
|
m.checkNotNullExpressionValue(materialButton, "binding.loadingButtonButton");
|
|
int paddingTop = materialButton.getPaddingTop();
|
|
m.checkNotNullExpressionValue(materialButton, "binding.loadingButtonButton");
|
|
materialButton.setPadding(paddingLeft2, paddingTop, materialButton.getPaddingRight(), dimensionPixelSize2);
|
|
if (obtainStyledAttributes.getBoolean(1, false)) {
|
|
m.checkNotNullExpressionValue(materialButton, "binding.loadingButtonButton");
|
|
materialButton.setStateListAnimator(null);
|
|
}
|
|
Drawable drawable = obtainStyledAttributes.getDrawable(3);
|
|
this.l = drawable;
|
|
if (drawable != null) {
|
|
m.checkNotNullExpressionValue(materialButton, "binding.loadingButtonButton");
|
|
materialButton.setIcon(drawable);
|
|
}
|
|
String string2 = obtainStyledAttributes.getString(4);
|
|
m.checkNotNullExpressionValue(materialButton, "binding.loadingButtonButton");
|
|
if (string2 != null) {
|
|
switch (string2.hashCode()) {
|
|
case -1417863058:
|
|
break;
|
|
case -1048657099:
|
|
if (string2.equals("textStart")) {
|
|
i = 2;
|
|
break;
|
|
}
|
|
break;
|
|
case 100571:
|
|
if (string2.equals("end")) {
|
|
i = 3;
|
|
break;
|
|
}
|
|
break;
|
|
case 109757538:
|
|
if (string2.equals("start")) {
|
|
i = 1;
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
materialButton.setIconGravity(i);
|
|
color = obtainStyledAttributes.getColor(7, Integer.MAX_VALUE);
|
|
if (color != Integer.MAX_VALUE) {
|
|
setProgressBarColor(color);
|
|
}
|
|
this.j = obtainStyledAttributes.getFloat(2, this.j);
|
|
setAlpha(!isEnabled() ? 1.0f : this.j);
|
|
return;
|
|
}
|
|
i = 0;
|
|
materialButton.setIconGravity(i);
|
|
color = obtainStyledAttributes.getColor(7, Integer.MAX_VALUE);
|
|
if (color != Integer.MAX_VALUE) {
|
|
}
|
|
this.j = obtainStyledAttributes.getFloat(2, this.j);
|
|
setAlpha(!isEnabled() ? 1.0f : this.j);
|
|
return;
|
|
} finally {
|
|
obtainStyledAttributes.recycle();
|
|
}
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
throw new NullPointerException("Missing required view with ID: ".concat(getResources().getResourceName(i2)));
|
|
}
|
|
|
|
private final void setProgressBarColor(@ColorInt int i) {
|
|
ProgressBar progressBar = this.i.f71c;
|
|
m.checkNotNullExpressionValue(progressBar, "binding.loadingButtonProgress");
|
|
progressBar.getIndeterminateDrawable().setColorFilter(i, PorterDuff.Mode.SRC_IN);
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void setBackgroundColor(@ColorInt int i) {
|
|
MaterialButton materialButton = this.i.b;
|
|
m.checkNotNullExpressionValue(materialButton, "binding.loadingButtonButton");
|
|
materialButton.setBackgroundTintList(ColorStateList.valueOf(i));
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void setEnabled(boolean z2) {
|
|
super.setEnabled(z2);
|
|
MaterialButton materialButton = this.i.b;
|
|
m.checkNotNullExpressionValue(materialButton, "binding.loadingButtonButton");
|
|
materialButton.setEnabled(z2);
|
|
setAlpha(isEnabled() ? 1.0f : this.j);
|
|
}
|
|
|
|
public final void setIconVisibility(boolean z2) {
|
|
if (z2) {
|
|
MaterialButton materialButton = this.i.b;
|
|
m.checkNotNullExpressionValue(materialButton, "binding.loadingButtonButton");
|
|
materialButton.setIcon(this.l);
|
|
return;
|
|
}
|
|
MaterialButton materialButton2 = this.i.b;
|
|
m.checkNotNullExpressionValue(materialButton2, "binding.loadingButtonButton");
|
|
materialButton2.setIcon(null);
|
|
}
|
|
|
|
public final void setIsLoading(boolean z2) {
|
|
if (z2) {
|
|
setClickable(false);
|
|
MaterialButton materialButton = this.i.b;
|
|
m.checkNotNullExpressionValue(materialButton, "binding.loadingButtonButton");
|
|
this.k = materialButton.getText().toString();
|
|
MaterialButton materialButton2 = this.i.b;
|
|
m.checkNotNullExpressionValue(materialButton2, "binding.loadingButtonButton");
|
|
materialButton2.setText((CharSequence) null);
|
|
MaterialButton materialButton3 = this.i.b;
|
|
m.checkNotNullExpressionValue(materialButton3, "binding.loadingButtonButton");
|
|
materialButton3.setIcon(null);
|
|
ProgressBar progressBar = this.i.f71c;
|
|
m.checkNotNullExpressionValue(progressBar, "binding.loadingButtonProgress");
|
|
progressBar.setVisibility(0);
|
|
return;
|
|
}
|
|
setClickable(true);
|
|
MaterialButton materialButton4 = this.i.b;
|
|
m.checkNotNullExpressionValue(materialButton4, "binding.loadingButtonButton");
|
|
materialButton4.setText(this.k);
|
|
MaterialButton materialButton5 = this.i.b;
|
|
m.checkNotNullExpressionValue(materialButton5, "binding.loadingButtonButton");
|
|
materialButton5.setIcon(this.l);
|
|
ProgressBar progressBar2 = this.i.f71c;
|
|
m.checkNotNullExpressionValue(progressBar2, "binding.loadingButtonProgress");
|
|
progressBar2.setVisibility(8);
|
|
}
|
|
|
|
public final void setText(CharSequence charSequence) {
|
|
this.k = charSequence;
|
|
MaterialButton materialButton = this.i.b;
|
|
m.checkNotNullExpressionValue(materialButton, "binding.loadingButtonButton");
|
|
materialButton.setText(charSequence);
|
|
}
|
|
}
|