497 lines
20 KiB
Java
497 lines
20 KiB
Java
package com.discord.views.steps;
|
|
|
|
import android.content.Context;
|
|
import android.util.AttributeSet;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.ImageView;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.RelativeLayout;
|
|
import android.widget.TextView;
|
|
import androidx.annotation.LayoutRes;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
|
import androidx.viewpager2.widget.ViewPager2;
|
|
import c.a.i.o3;
|
|
import com.discord.app.AppFragment;
|
|
import com.discord.views.LoadingButton;
|
|
import com.google.android.material.button.MaterialButton;
|
|
import d0.z.d.m;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
/* compiled from: StepsView.kt */
|
|
public final class StepsView extends RelativeLayout {
|
|
public static final /* synthetic */ int i = 0;
|
|
public final o3 j;
|
|
public d k;
|
|
public ViewPager2.OnPageChangeCallback l;
|
|
|
|
/* compiled from: java-style lambda group */
|
|
public static final class a implements View.OnClickListener {
|
|
public final /* synthetic */ int i;
|
|
public final /* synthetic */ int j;
|
|
public final /* synthetic */ Object k;
|
|
public final /* synthetic */ Object l;
|
|
|
|
public a(int i, int i2, Object obj, Object obj2) {
|
|
this.i = i;
|
|
this.j = i2;
|
|
this.k = obj;
|
|
this.l = obj2;
|
|
}
|
|
|
|
@Override // android.view.View.OnClickListener
|
|
public final void onClick(View view) {
|
|
int i = this.i;
|
|
if (i == 0) {
|
|
Function1<View, Unit> function1 = ((b) ((List) this.l).get(this.j)).d;
|
|
if (function1 != null) {
|
|
m.checkNotNullExpressionValue(view, "it");
|
|
function1.invoke(view);
|
|
return;
|
|
}
|
|
ViewPager2 viewPager2 = ((StepsView) this.k).j.g;
|
|
m.checkNotNullExpressionValue(viewPager2, "binding.stepsViewpager");
|
|
int currentItem = viewPager2.getCurrentItem();
|
|
d dVar = ((StepsView) this.k).k;
|
|
if (dVar == null || currentItem != dVar.getItemCount() - 1) {
|
|
ViewPager2 viewPager22 = ((StepsView) this.k).j.g;
|
|
m.checkNotNullExpressionValue(viewPager22, "binding.stepsViewpager");
|
|
ViewPager2 viewPager23 = ((StepsView) this.k).j.g;
|
|
m.checkNotNullExpressionValue(viewPager23, "binding.stepsViewpager");
|
|
viewPager22.setCurrentItem(viewPager23.getCurrentItem() + 1);
|
|
}
|
|
} else if (i == 1) {
|
|
Function1<View, Unit> function12 = ((b) ((List) this.k).get(this.j)).f;
|
|
if (function12 != null) {
|
|
m.checkNotNullExpressionValue(view, "it");
|
|
function12.invoke(view);
|
|
return;
|
|
}
|
|
((Function0) this.l).mo1invoke();
|
|
} else {
|
|
throw null;
|
|
}
|
|
}
|
|
}
|
|
|
|
/* compiled from: StepsView.kt */
|
|
public static abstract class b {
|
|
public final int a;
|
|
public final int b;
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public final int f2141c;
|
|
public final Function1<View, Unit> d;
|
|
public final Function1<View, Unit> e;
|
|
public final Function1<View, Unit> f;
|
|
public final boolean g;
|
|
public final boolean h;
|
|
public final boolean i;
|
|
|
|
/* compiled from: StepsView.kt */
|
|
public static final class a extends b {
|
|
public final Class<? extends Fragment> j;
|
|
public final int k;
|
|
public final int l;
|
|
public final int m;
|
|
public final Function1<View, Unit> n;
|
|
public final Function1<View, Unit> o;
|
|
public final Function1<View, Unit> p;
|
|
public final boolean q;
|
|
public final boolean r;
|
|
|
|
/* renamed from: s reason: collision with root package name */
|
|
public final boolean f2142s;
|
|
|
|
/* JADX WARNING: Illegal instructions before constructor call */
|
|
public a(Class cls, int i, int i2, int i3, Function1 function1, Function1 function12, Function1 function13, boolean z2, boolean z3, boolean z4, int i4) {
|
|
super(r13, r14, r15, null, null, r8, r7, r6, r5, null);
|
|
int i5 = (i4 & 2) != 0 ? 2131891519 : i;
|
|
int i6 = (i4 & 4) != 0 ? 2131886809 : i2;
|
|
int i7 = (i4 & 8) != 0 ? 2131888181 : i3;
|
|
int i8 = i4 & 16;
|
|
int i9 = i4 & 32;
|
|
Function1 function14 = (i4 & 64) != 0 ? null : function13;
|
|
boolean z5 = (i4 & 128) != 0 ? true : z2;
|
|
boolean z6 = (i4 & 256) != 0 ? true : z3;
|
|
boolean z7 = (i4 & 512) != 0 ? true : z4;
|
|
m.checkNotNullParameter(cls, "fragment");
|
|
this.j = cls;
|
|
this.k = i5;
|
|
this.l = i6;
|
|
this.m = i7;
|
|
this.n = null;
|
|
this.o = null;
|
|
this.p = function14;
|
|
this.q = z5;
|
|
this.r = z6;
|
|
this.f2142s = z7;
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof a)) {
|
|
return false;
|
|
}
|
|
a aVar = (a) obj;
|
|
return m.areEqual(this.j, aVar.j) && this.k == aVar.k && this.l == aVar.l && this.m == aVar.m && m.areEqual(this.n, aVar.n) && m.areEqual(this.o, aVar.o) && m.areEqual(this.p, aVar.p) && this.q == aVar.q && this.r == aVar.r && this.f2142s == aVar.f2142s;
|
|
}
|
|
|
|
public int hashCode() {
|
|
Class<? extends Fragment> cls = this.j;
|
|
int i = 0;
|
|
int hashCode = (((((((cls != null ? cls.hashCode() : 0) * 31) + this.k) * 31) + this.l) * 31) + this.m) * 31;
|
|
Function1<View, Unit> function1 = this.n;
|
|
int hashCode2 = (hashCode + (function1 != null ? function1.hashCode() : 0)) * 31;
|
|
Function1<View, Unit> function12 = this.o;
|
|
int hashCode3 = (hashCode2 + (function12 != null ? function12.hashCode() : 0)) * 31;
|
|
Function1<View, Unit> function13 = this.p;
|
|
if (function13 != null) {
|
|
i = function13.hashCode();
|
|
}
|
|
int i2 = (hashCode3 + i) * 31;
|
|
boolean z2 = this.q;
|
|
int i3 = 1;
|
|
if (z2) {
|
|
z2 = true;
|
|
}
|
|
int i4 = z2 ? 1 : 0;
|
|
int i5 = z2 ? 1 : 0;
|
|
int i6 = z2 ? 1 : 0;
|
|
int i7 = (i2 + i4) * 31;
|
|
boolean z3 = this.r;
|
|
if (z3) {
|
|
z3 = true;
|
|
}
|
|
int i8 = z3 ? 1 : 0;
|
|
int i9 = z3 ? 1 : 0;
|
|
int i10 = z3 ? 1 : 0;
|
|
int i11 = (i7 + i8) * 31;
|
|
boolean z4 = this.f2142s;
|
|
if (!z4) {
|
|
i3 = z4 ? 1 : 0;
|
|
}
|
|
return i11 + i3;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder K = c.d.b.a.a.K("FragmentStep(fragment=");
|
|
K.append(this.j);
|
|
K.append(", nextText=");
|
|
K.append(this.k);
|
|
K.append(", cancelText=");
|
|
K.append(this.l);
|
|
K.append(", doneText=");
|
|
K.append(this.m);
|
|
K.append(", onNext=");
|
|
K.append(this.n);
|
|
K.append(", onCancel=");
|
|
K.append(this.o);
|
|
K.append(", onDone=");
|
|
K.append(this.p);
|
|
K.append(", canNext=");
|
|
K.append(this.q);
|
|
K.append(", canCancel=");
|
|
K.append(this.r);
|
|
K.append(", allowScroll=");
|
|
return c.d.b.a.a.F(K, this.f2142s, ")");
|
|
}
|
|
}
|
|
|
|
/* compiled from: StepsView.kt */
|
|
/* renamed from: com.discord.views.steps.StepsView$b$b reason: collision with other inner class name */
|
|
public static final class C0183b extends b {
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof C0183b)) {
|
|
return false;
|
|
}
|
|
Objects.requireNonNull((C0183b) obj);
|
|
return m.areEqual(null, null) && m.areEqual(null, null) && m.areEqual(null, null);
|
|
}
|
|
|
|
public int hashCode() {
|
|
return (((((((((((((((((0 * 31) + 0) * 31) + 0) * 31) + 0) * 31) + 0) * 31) + 0) * 31) + 0) * 31) + 0) * 31) + 0) * 31) + 0;
|
|
}
|
|
|
|
public String toString() {
|
|
return "ViewStep(layoutId=0, nextText=0, cancelText=0, doneText=0, onNext=null, onCancel=null, onDone=null, canNext=false, canCancel=false, allowScroll=false)";
|
|
}
|
|
}
|
|
|
|
public b(int i, int i2, int i3, Function1 function1, Function1 function12, Function1 function13, boolean z2, boolean z3, boolean z4, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this.a = i;
|
|
this.b = i2;
|
|
this.f2141c = i3;
|
|
this.d = function1;
|
|
this.e = function12;
|
|
this.f = function13;
|
|
this.g = z2;
|
|
this.h = z3;
|
|
this.i = z4;
|
|
}
|
|
}
|
|
|
|
/* compiled from: StepsView.kt */
|
|
public static final class c extends AppFragment {
|
|
public c(@LayoutRes int i) {
|
|
super(i);
|
|
}
|
|
}
|
|
|
|
/* compiled from: StepsView.kt */
|
|
public static final class d extends FragmentStateAdapter {
|
|
public List<? extends b> a;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public d(Fragment fragment, List<? extends b> list) {
|
|
super(fragment);
|
|
m.checkNotNullParameter(fragment, "fragment");
|
|
m.checkNotNullParameter(list, "steps");
|
|
this.a = list;
|
|
}
|
|
|
|
@Override // androidx.viewpager2.adapter.FragmentStateAdapter
|
|
public Fragment createFragment(int i) {
|
|
b bVar = (b) this.a.get(i);
|
|
if (bVar instanceof b.a) {
|
|
Object newInstance = ((b.a) bVar).j.newInstance();
|
|
m.checkNotNullExpressionValue(newInstance, "currentStep.fragment.newInstance()");
|
|
return (Fragment) newInstance;
|
|
} else if (!(bVar instanceof b.C0183b)) {
|
|
return new Fragment();
|
|
} else {
|
|
Objects.requireNonNull((b.C0183b) bVar);
|
|
return new c(0);
|
|
}
|
|
}
|
|
|
|
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
|
public int getItemCount() {
|
|
return this.a.size();
|
|
}
|
|
}
|
|
|
|
/* compiled from: StepsView.kt */
|
|
public static final class e extends ViewPager2.OnPageChangeCallback {
|
|
public final /* synthetic */ StepsView a;
|
|
public final /* synthetic */ Function1 b;
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public final /* synthetic */ Function0 f2143c;
|
|
|
|
public e(StepsView stepsView, Function1 function1, Function0 function0) {
|
|
this.a = stepsView;
|
|
this.b = function1;
|
|
this.f2143c = function0;
|
|
}
|
|
|
|
@Override // androidx.viewpager2.widget.ViewPager2.OnPageChangeCallback
|
|
public void onPageSelected(int i) {
|
|
this.b.invoke(Integer.valueOf(i));
|
|
StepsView stepsView = this.a;
|
|
Function0<Unit> function0 = this.f2143c;
|
|
int i2 = StepsView.i;
|
|
stepsView.c(i, function0);
|
|
}
|
|
}
|
|
|
|
/* compiled from: StepsView.kt */
|
|
public static final class f implements View.OnClickListener {
|
|
public final /* synthetic */ Function0 i;
|
|
|
|
public f(Function0 function0) {
|
|
this.i = function0;
|
|
}
|
|
|
|
@Override // android.view.View.OnClickListener
|
|
public final void onClick(View view) {
|
|
this.i.mo1invoke();
|
|
}
|
|
}
|
|
|
|
/* compiled from: StepsView.kt */
|
|
public static final class g implements View.OnClickListener {
|
|
public final /* synthetic */ StepsView i;
|
|
public final /* synthetic */ List j;
|
|
public final /* synthetic */ int k;
|
|
public final /* synthetic */ Function0 l;
|
|
|
|
public g(StepsView stepsView, List list, int i, Function0 function0) {
|
|
this.i = stepsView;
|
|
this.j = list;
|
|
this.k = i;
|
|
this.l = function0;
|
|
}
|
|
|
|
@Override // android.view.View.OnClickListener
|
|
public final void onClick(View view) {
|
|
Function1<View, Unit> function1 = ((b) this.j.get(this.k)).e;
|
|
if (function1 != null) {
|
|
m.checkNotNullExpressionValue(view, "it");
|
|
function1.invoke(view);
|
|
return;
|
|
}
|
|
ViewPager2 viewPager2 = this.i.j.g;
|
|
m.checkNotNullExpressionValue(viewPager2, "binding.stepsViewpager");
|
|
if (viewPager2.getCurrentItem() == 0) {
|
|
this.l.mo1invoke();
|
|
return;
|
|
}
|
|
ViewPager2 viewPager22 = this.i.j.g;
|
|
m.checkNotNullExpressionValue(viewPager22, "binding.stepsViewpager");
|
|
ViewPager2 viewPager23 = this.i.j.g;
|
|
m.checkNotNullExpressionValue(viewPager23, "binding.stepsViewpager");
|
|
viewPager22.setCurrentItem(viewPager23.getCurrentItem() - 1);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public StepsView(Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet, 0);
|
|
m.checkNotNullParameter(context, "context");
|
|
m.checkNotNullParameter(context, "context");
|
|
View inflate = LayoutInflater.from(context).inflate(2131558826, (ViewGroup) this, false);
|
|
addView(inflate);
|
|
int i2 = 2131365181;
|
|
LinearLayout linearLayout = (LinearLayout) inflate.findViewById(2131365181);
|
|
if (linearLayout != null) {
|
|
i2 = 2131365182;
|
|
TextView textView = (TextView) inflate.findViewById(2131365182);
|
|
if (textView != null) {
|
|
i2 = 2131365183;
|
|
ImageView imageView = (ImageView) inflate.findViewById(2131365183);
|
|
if (imageView != null) {
|
|
i2 = 2131365184;
|
|
LoadingButton loadingButton = (LoadingButton) inflate.findViewById(2131365184);
|
|
if (loadingButton != null) {
|
|
i2 = 2131365185;
|
|
MaterialButton materialButton = (MaterialButton) inflate.findViewById(2131365185);
|
|
if (materialButton != null) {
|
|
i2 = 2131365186;
|
|
ViewPager2 viewPager2 = (ViewPager2) inflate.findViewById(2131365186);
|
|
if (viewPager2 != null) {
|
|
o3 o3Var = new o3((RelativeLayout) inflate, linearLayout, textView, imageView, loadingButton, materialButton, viewPager2);
|
|
m.checkNotNullExpressionValue(o3Var, "ViewStepsBinding.inflate…rom(context), this, true)");
|
|
this.j = o3Var;
|
|
setIsLoading(false);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw new NullPointerException("Missing required view with ID: ".concat(inflate.getResources().getResourceName(i2)));
|
|
}
|
|
|
|
public final void a(d dVar, Function0<Unit> function0, Function1<? super Integer, Unit> function1) {
|
|
m.checkNotNullParameter(dVar, "adapter");
|
|
m.checkNotNullParameter(function0, "onClose");
|
|
m.checkNotNullParameter(function1, "onPageSelected");
|
|
this.k = dVar;
|
|
ViewPager2 viewPager2 = this.j.g;
|
|
m.checkNotNullExpressionValue(viewPager2, "binding.stepsViewpager");
|
|
viewPager2.setAdapter(this.k);
|
|
ViewPager2.OnPageChangeCallback onPageChangeCallback = this.l;
|
|
if (onPageChangeCallback != null) {
|
|
this.j.g.unregisterOnPageChangeCallback(onPageChangeCallback);
|
|
}
|
|
ViewPager2 viewPager22 = this.j.g;
|
|
e eVar = new e(this, function1, function0);
|
|
this.l = eVar;
|
|
viewPager22.registerOnPageChangeCallback(eVar);
|
|
c(0, function0);
|
|
}
|
|
|
|
public final void b(int i2) {
|
|
if (i2 >= 0) {
|
|
d dVar = this.k;
|
|
if (i2 < (dVar != null ? dVar.getItemCount() : 0)) {
|
|
ViewPager2 viewPager2 = this.j.g;
|
|
m.checkNotNullExpressionValue(viewPager2, "binding.stepsViewpager");
|
|
viewPager2.setCurrentItem(i2);
|
|
}
|
|
}
|
|
}
|
|
|
|
public final void c(int i2, Function0<Unit> function0) {
|
|
List<? extends b> list;
|
|
this.j.d.setOnClickListener(new f(function0));
|
|
d dVar = this.k;
|
|
if (dVar != null && (list = dVar.a) != null) {
|
|
ViewPager2 viewPager2 = this.j.g;
|
|
m.checkNotNullExpressionValue(viewPager2, "binding.stepsViewpager");
|
|
viewPager2.setUserInputEnabled(((b) list.get(i2)).i);
|
|
TextView textView = this.j.f135c;
|
|
m.checkNotNullExpressionValue(textView, "binding.stepsCancel");
|
|
textView.setText(getContext().getString(((b) list.get(i2)).b));
|
|
this.j.e.setText(getContext().getString(((b) list.get(i2)).f2141c));
|
|
MaterialButton materialButton = this.j.f;
|
|
m.checkNotNullExpressionValue(materialButton, "binding.stepsNext");
|
|
materialButton.setText(getContext().getString(((b) list.get(i2)).a));
|
|
int i3 = 0;
|
|
this.j.f.setOnClickListener(new a(0, i2, this, list));
|
|
this.j.f135c.setOnClickListener(new g(this, list, i2, function0));
|
|
boolean z2 = true;
|
|
this.j.e.setOnClickListener(new a(1, i2, list, function0));
|
|
d dVar2 = this.k;
|
|
boolean z3 = dVar2 != null && i2 == dVar2.getItemCount() - 1;
|
|
MaterialButton materialButton2 = this.j.f;
|
|
m.checkNotNullExpressionValue(materialButton2, "binding.stepsNext");
|
|
materialButton2.setVisibility(!z3 && ((b) list.get(i2)).g ? 0 : 8);
|
|
TextView textView2 = this.j.f135c;
|
|
m.checkNotNullExpressionValue(textView2, "binding.stepsCancel");
|
|
textView2.setVisibility(!z3 && ((b) list.get(i2)).h ? 0 : 8);
|
|
LoadingButton loadingButton = this.j.e;
|
|
m.checkNotNullExpressionValue(loadingButton, "binding.stepsDone");
|
|
loadingButton.setVisibility(z3 ? 0 : 8);
|
|
LinearLayout linearLayout = this.j.b;
|
|
m.checkNotNullExpressionValue(linearLayout, "binding.stepsButtonContainer");
|
|
MaterialButton materialButton3 = this.j.f;
|
|
m.checkNotNullExpressionValue(materialButton3, "binding.stepsNext");
|
|
if (!(materialButton3.getVisibility() == 0)) {
|
|
TextView textView3 = this.j.f135c;
|
|
m.checkNotNullExpressionValue(textView3, "binding.stepsCancel");
|
|
if (!(textView3.getVisibility() == 0)) {
|
|
LoadingButton loadingButton2 = this.j.e;
|
|
m.checkNotNullExpressionValue(loadingButton2, "binding.stepsDone");
|
|
if (!(loadingButton2.getVisibility() == 0)) {
|
|
z2 = false;
|
|
}
|
|
}
|
|
}
|
|
if (!z2) {
|
|
i3 = 8;
|
|
}
|
|
linearLayout.setVisibility(i3);
|
|
}
|
|
}
|
|
|
|
public final void setIsDoneButtonEnabled(boolean z2) {
|
|
LoadingButton loadingButton = this.j.e;
|
|
m.checkNotNullExpressionValue(loadingButton, "binding.stepsDone");
|
|
loadingButton.setEnabled(z2);
|
|
}
|
|
|
|
public final void setIsLoading(boolean z2) {
|
|
this.j.e.setIsLoading(z2);
|
|
}
|
|
|
|
public final void setIsNextButtonEnabled(boolean z2) {
|
|
MaterialButton materialButton = this.j.f;
|
|
m.checkNotNullExpressionValue(materialButton, "binding.stepsNext");
|
|
materialButton.setEnabled(z2);
|
|
}
|
|
}
|