package com.discord.views; import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; import c.a.d.o; import c.a.i.q3; import com.discord.R; import d0.z.d.m; import kotlin.jvm.internal.DefaultConstructorMarker; /* compiled from: TernaryCheckBox.kt */ public final class TernaryCheckBox extends RelativeLayout { public static final a i = new a(null); public final q3 j; public String k; public CharSequence l; public b m; public int n; /* compiled from: TernaryCheckBox.kt */ public static final class a { public a(DefaultConstructorMarker defaultConstructorMarker) { } } /* compiled from: TernaryCheckBox.kt */ public interface b { void onSwitchStatusChanged(int i); } /* compiled from: TernaryCheckBox.kt */ public static final class c implements View.OnClickListener { public final /* synthetic */ TernaryCheckBox i; public final /* synthetic */ String j; public c(TernaryCheckBox ternaryCheckBox, String str) { this.i = ternaryCheckBox; this.j = str; } @Override // android.view.View.OnClickListener public final void onClick(View view) { o.h(this.i.getContext(), this.j, 0, null, 12); } } /* compiled from: TernaryCheckBox.kt */ public static final class d implements View.OnClickListener { public final /* synthetic */ TernaryCheckBox i; public final /* synthetic */ String j; public d(TernaryCheckBox ternaryCheckBox, String str) { this.i = ternaryCheckBox; this.j = str; } @Override // android.view.View.OnClickListener public final void onClick(View view) { o.h(this.i.getContext(), this.j, 0, null, 12); } } /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public TernaryCheckBox(Context context, AttributeSet attributeSet) { super(context, attributeSet); m.checkNotNullParameter(context, "context"); View inflate = LayoutInflater.from(getContext()).inflate(2131558828, (ViewGroup) this, false); addView(inflate); int i2 = 2131362628; FrameLayout frameLayout = (FrameLayout) inflate.findViewById(2131362628); if (frameLayout != null) { i2 = 2131362630; LinearLayout linearLayout = (LinearLayout) inflate.findViewById(2131362630); if (linearLayout != null) { i2 = 2131364195; View findViewById = inflate.findViewById(2131364195); if (findViewById != null) { i2 = 2131364841; View findViewById2 = inflate.findViewById(2131364841); if (findViewById2 != null) { i2 = 2131364843; TextView textView = (TextView) inflate.findViewById(2131364843); if (textView != null) { i2 = 2131364844; TextView textView2 = (TextView) inflate.findViewById(2131364844); if (textView2 != null) { i2 = 2131365320; CheckableImageView checkableImageView = (CheckableImageView) inflate.findViewById(2131365320); if (checkableImageView != null) { i2 = 2131365321; CheckableImageView checkableImageView2 = (CheckableImageView) inflate.findViewById(2131365321); if (checkableImageView2 != null) { i2 = 2131365322; CheckableImageView checkableImageView3 = (CheckableImageView) inflate.findViewById(2131365322); if (checkableImageView3 != null) { q3 q3Var = new q3((LinearLayout) inflate, frameLayout, linearLayout, findViewById, findViewById2, textView, textView2, checkableImageView, checkableImageView2, checkableImageView3); m.checkNotNullExpressionValue(q3Var, "ViewTernaryCheckboxBindi…rom(context), this, true)"); this.j = q3Var; this.n = -1; if (attributeSet != null) { TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.a.TernaryCheckBox, 0, 0); m.checkNotNullExpressionValue(obtainStyledAttributes, "context.obtainStyledAttr…le.TernaryCheckBox, 0, 0)"); try { this.k = obtainStyledAttributes.getString(0); String string = obtainStyledAttributes.getString(1); this.l = string != null ? c.a.k.b.k(string, new Object[0], null, 2) : null; } finally { obtainStyledAttributes.recycle(); } } m.checkNotNullExpressionValue(textView, "binding.settingLabel"); int i3 = 8; textView.setVisibility(this.k != null ? 0 : 8); m.checkNotNullExpressionValue(textView, "binding.settingLabel"); textView.setText(this.k); m.checkNotNullExpressionValue(textView2, "binding.settingSubtext"); textView2.setVisibility(this.l != null ? 0 : i3); m.checkNotNullExpressionValue(textView2, "binding.settingSubtext"); textView2.setText(this.l); checkableImageView3.setOnClickListener(new defpackage.b(0, this)); checkableImageView2.setOnClickListener(new defpackage.b(1, this)); checkableImageView.setOnClickListener(new defpackage.b(2, this)); return; } } } } } } } } } throw new NullPointerException("Missing required view with ID: ".concat(inflate.getResources().getResourceName(i2))); } public static final /* synthetic */ void a(TernaryCheckBox ternaryCheckBox, int i2) { ternaryCheckBox.setSwitchStatus(i2); } private final void setDisabled(String str) { FrameLayout frameLayout = this.j.b; m.checkNotNullExpressionValue(frameLayout, "binding.checkableOffContainer"); frameLayout.setEnabled(true); View view = this.j.f147c; m.checkNotNullExpressionValue(view, "binding.offDisabledOverlay"); view.setVisibility(8); this.j.d.setOnClickListener(new c(this, str)); View view2 = this.j.d; m.checkNotNullExpressionValue(view2, "binding.settingDisabledOverlay"); view2.setVisibility(0); } private final void setOffDisabled(String str) { CheckableImageView checkableImageView = this.j.h; m.checkNotNullExpressionValue(checkableImageView, "binding.ternaryCheckOff"); checkableImageView.setEnabled(false); View view = this.j.d; m.checkNotNullExpressionValue(view, "binding.settingDisabledOverlay"); view.setVisibility(8); this.j.f147c.setOnClickListener(new d(this, str)); View view2 = this.j.f147c; m.checkNotNullExpressionValue(view2, "binding.offDisabledOverlay"); view2.setVisibility(0); } private final void setSwitchStatus(int i2) { this.n = i2; CheckableImageView checkableImageView = this.j.i; m.checkNotNullExpressionValue(checkableImageView, "binding.ternaryCheckOn"); boolean z2 = false; checkableImageView.setChecked(i2 == 1); CheckableImageView checkableImageView2 = this.j.h; m.checkNotNullExpressionValue(checkableImageView2, "binding.ternaryCheckOff"); checkableImageView2.setChecked(i2 == -1); CheckableImageView checkableImageView3 = this.j.g; m.checkNotNullExpressionValue(checkableImageView3, "binding.ternaryCheckNeutral"); if (i2 == 0) { z2 = true; } checkableImageView3.setChecked(z2); b bVar = this.m; if (bVar != null) { bVar.onSwitchStatusChanged(i2); } } public final boolean b() { return this.n == 1; } public final void c() { CheckableImageView checkableImageView = this.j.h; m.checkNotNullExpressionValue(checkableImageView, "binding.ternaryCheckOff"); checkableImageView.setEnabled(true); View view = this.j.f147c; m.checkNotNullExpressionValue(view, "binding.offDisabledOverlay"); view.setVisibility(8); View view2 = this.j.d; m.checkNotNullExpressionValue(view2, "binding.settingDisabledOverlay"); view2.setVisibility(8); } public final void d() { setSwitchStatus(0); } public final void e() { setSwitchStatus(-1); } public final void f() { setSwitchStatus(1); } public final b getOnSwitchStatusChangedListener() { return this.m; } public final int getSwitchStatus() { return this.n; } public final void setDisabled(int i2) { String string = getContext().getString(i2); m.checkNotNullExpressionValue(string, "context.getString(messageRes)"); setDisabled(string); } public final void setLabel(CharSequence charSequence) { TextView textView = this.j.e; m.checkNotNullExpressionValue(textView, "binding.settingLabel"); textView.setText(charSequence); } public final void setOffDisabled(int i2) { String string = getContext().getString(i2); m.checkNotNullExpressionValue(string, "context.getString(messageRes)"); setOffDisabled(string); } public final void setOnSwitchStatusChangedListener(b bVar) { this.m = bVar; } public final void setSubtext(CharSequence charSequence) { TextView textView = this.j.f; m.checkNotNullExpressionValue(textView, "binding.settingSubtext"); CharSequence charSequence2 = null; if (charSequence != null) { charSequence2 = c.a.k.b.k(charSequence, new Object[0], null, 2); } textView.setText(charSequence2); } }