package c.a.a.d; import android.content.Context; import android.os.Bundle; import android.view.View; import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.TextView; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentViewModelLazyKt; import c.a.a.d.f; import c.a.d.h0; import c.a.d.j0; import c.a.i.v0; import com.discord.app.AppDialog; import com.discord.app.AppViewFlipper; import com.discord.app.AppViewModel; import com.discord.models.domain.ModelSubscription; import com.discord.utilities.color.ColorCompat; import com.discord.utilities.premium.PremiumGuildSubscriptionUtils; import com.discord.utilities.rx.ObservableExtensionsKt; import com.discord.utilities.time.TimeUtils; import com.discord.utilities.view.extensions.ViewExtensions; import com.discord.utilities.viewbinding.FragmentViewBindingDelegate; import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt; import com.discord.views.LoadingButton; import com.google.android.material.button.MaterialButton; import d0.g; import d0.z.d.a0; import d0.z.d.k; import d0.z.d.m; import d0.z.d.o; import java.text.DateFormat; import java.util.Objects; import kotlin.Lazy; import kotlin.Unit; import kotlin.jvm.functions.Function0; import kotlin.jvm.functions.Function1; import kotlin.jvm.internal.DefaultConstructorMarker; import kotlin.reflect.KProperty; import rx.Observable; /* compiled from: PremiumGuildSubscriptionCancelDialog.kt */ public final class a extends AppDialog { public static final /* synthetic */ KProperty[] i = {c.d.b.a.a.W(a.class, "binding", "getBinding()Lcom/discord/databinding/PremiumGuildSubscriptionCancelDialogBinding;", 0)}; public static final b j = new b(null); public final FragmentViewBindingDelegate k = FragmentViewBindingDelegateKt.viewBinding$default(this, c.i, null, 2, null); public final Lazy l; public final Lazy m; /* compiled from: java-style lambda group */ /* renamed from: c.a.a.d.a$a reason: collision with other inner class name */ public static final class View$OnClickListenerC0009a implements View.OnClickListener { public final /* synthetic */ int i; public final /* synthetic */ Object j; public View$OnClickListenerC0009a(int i, Object obj) { this.i = i; this.j = obj; } @Override // android.view.View.OnClickListener public final void onClick(View view) { int i = this.i; if (i == 0) { f fVar = (f) ((a) this.j).l.getValue(); f.c viewState = fVar.getViewState(); if ((viewState instanceof f.c.C0013f) || (viewState instanceof f.c.a)) { return; } if ((viewState instanceof f.c.e) || (viewState instanceof f.c.d) || (viewState instanceof f.c.b)) { fVar.updateViewState(new f.c.C0012c(null, 1)); } } else if (i == 1) { f fVar2 = (f) ((a) this.j).l.getValue(); f.c viewState2 = fVar2.getViewState(); if ((viewState2 instanceof f.c.C0013f) || (viewState2 instanceof f.c.a)) { return; } if ((viewState2 instanceof f.c.e) || (viewState2 instanceof f.c.d)) { f.c viewState3 = fVar2.getViewState(); ModelSubscription modelSubscription = viewState3 instanceof f.c.e ? ((f.c.e) viewState3).f : viewState3 instanceof f.c.d ? ((f.c.d) viewState3).f : null; if (modelSubscription != null) { fVar2.updateViewState(new f.c.a(modelSubscription)); ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(PremiumGuildSubscriptionUtils.INSTANCE.cancelSubscriptionSlot(fVar2.m, fVar2.j, modelSubscription, fVar2.k), fVar2, null, 2, null), f.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new g(fVar2, modelSubscription), 62, (Object) null); } } else if (viewState2 instanceof f.c.b) { fVar2.updateViewState(new f.c.C0012c(null, 1)); } } else { throw null; } } } /* compiled from: PremiumGuildSubscriptionCancelDialog.kt */ public static final class b { public b(DefaultConstructorMarker defaultConstructorMarker) { } } /* compiled from: PremiumGuildSubscriptionCancelDialog.kt */ public static final /* synthetic */ class c extends k implements Function1 { public static final c i = new c(); public c() { super(1, v0.class, "bind", "bind(Landroid/view/View;)Lcom/discord/databinding/PremiumGuildSubscriptionCancelDialogBinding;", 0); } /* Return type fixed from 'java.lang.Object' to match base method */ /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */ @Override // kotlin.jvm.functions.Function1 public v0 invoke(View view) { View view2 = view; m.checkNotNullParameter(view2, "p1"); int i2 = 2131361894; ProgressBar progressBar = (ProgressBar) view2.findViewById(2131361894); if (progressBar != null) { i2 = 2131364030; LinearLayout linearLayout = (LinearLayout) view2.findViewById(2131364030); if (linearLayout != null) { i2 = 2131364257; TextView textView = (TextView) view2.findViewById(2131364257); if (textView != null) { i2 = 2131364258; LoadingButton loadingButton = (LoadingButton) view2.findViewById(2131364258); if (loadingButton != null) { i2 = 2131364259; TextView textView2 = (TextView) view2.findViewById(2131364259); if (textView2 != null) { i2 = 2131364260; AppViewFlipper appViewFlipper = (AppViewFlipper) view2.findViewById(2131364260); if (appViewFlipper != null) { i2 = 2131364261; TextView textView3 = (TextView) view2.findViewById(2131364261); if (textView3 != null) { i2 = 2131364262; MaterialButton materialButton = (MaterialButton) view2.findViewById(2131364262); if (materialButton != null) { return new v0((LinearLayout) view2, progressBar, linearLayout, textView, loadingButton, textView2, appViewFlipper, textView3, materialButton); } } } } } } } } throw new NullPointerException("Missing required view with ID: ".concat(view2.getResources().getResourceName(i2))); } } /* compiled from: PremiumGuildSubscriptionCancelDialog.kt */ public static final class d extends o implements Function1 { public final /* synthetic */ a this$0; /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public d(a aVar) { super(1); this.this$0 = aVar; } /* Return type fixed from 'java.lang.Object' to match base method */ /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */ @Override // kotlin.jvm.functions.Function1 public Unit invoke(f.c cVar) { f.c cVar2 = cVar; a aVar = this.this$0; m.checkNotNullExpressionValue(cVar2, "it"); KProperty[] kPropertyArr = a.i; TextView textView = aVar.g().d; m.checkNotNullExpressionValue(textView, "binding.premiumGuildSubscriptionCancelError"); int i = 8; textView.setVisibility(cVar2.a ? 0 : 8); MaterialButton materialButton = aVar.g().g; m.checkNotNullExpressionValue(materialButton, "binding.premiumGuildSubscriptionCancelNevermind"); if (cVar2.b) { i = 0; } materialButton.setVisibility(i); MaterialButton materialButton2 = aVar.g().g; m.checkNotNullExpressionValue(materialButton2, "binding.premiumGuildSubscriptionCancelNevermind"); ViewExtensions.setEnabledAndAlpha$default(materialButton2, cVar2.f35c, 0.0f, 2, null); aVar.setCancelable(cVar2.e); aVar.g().f165c.setIsLoading(cVar2.d); AppViewFlipper appViewFlipper = aVar.g().e; m.checkNotNullExpressionValue(appViewFlipper, "binding.premiumGuildSubscriptionCancelFlipper"); appViewFlipper.setDisplayedChild(!(cVar2 instanceof f.c.C0013f) ? 1 : 0); if (cVar2 instanceof f.c.e) { TimeUtils timeUtils = TimeUtils.INSTANCE; f.c.e eVar = (f.c.e) cVar2; String currentPeriodEnd = eVar.f.getCurrentPeriodEnd(); Context requireContext = aVar.requireContext(); m.checkNotNullExpressionValue(requireContext, "requireContext()"); String renderUtcDate$default = TimeUtils.renderUtcDate$default(timeUtils, currentPeriodEnd, requireContext, (String) null, (DateFormat) null, 0, 28, (Object) null); if (eVar.g) { TextView textView2 = aVar.g().b; m.checkNotNullExpressionValue(textView2, "binding.premiumGuildSubscriptionCancelBody"); c.a.l.b.n(textView2, 2131892071, new Object[]{renderUtcDate$default}, null, 4); } else { TextView textView3 = aVar.g().b; m.checkNotNullExpressionValue(textView3, "binding.premiumGuildSubscriptionCancelBody"); c.a.l.b.n(textView3, 2131892070, new Object[]{renderUtcDate$default}, null, 4); } aVar.g().f165c.setBackgroundColor(ColorCompat.getColor(aVar, 2131100324)); } else if (cVar2 instanceof f.c.b) { TextView textView4 = aVar.g().f; m.checkNotNullExpressionValue(textView4, "binding.premiumGuildSubscriptionCancelHeader"); textView4.setText(aVar.getString(2131892082)); TextView textView5 = aVar.g().b; m.checkNotNullExpressionValue(textView5, "binding.premiumGuildSubscriptionCancelBody"); TimeUtils timeUtils2 = TimeUtils.INSTANCE; String currentPeriodEnd2 = ((f.c.b) cVar2).f.getCurrentPeriodEnd(); Context requireContext2 = aVar.requireContext(); m.checkNotNullExpressionValue(requireContext2, "requireContext()"); c.a.l.b.n(textView5, 2131892083, new Object[]{TimeUtils.renderUtcDate$default(timeUtils2, currentPeriodEnd2, requireContext2, (String) null, (DateFormat) null, 0, 28, (Object) null)}, null, 4); aVar.g().f165c.setText(aVar.getString(2131891666)); aVar.g().f165c.setBackgroundColor(ColorCompat.getThemedColor(aVar, 2130969007)); } else if (cVar2 instanceof f.c.C0012c) { Integer num = ((f.c.C0012c) cVar2).f; if (num != null) { c.a.d.o.g(aVar.requireContext(), num.intValue(), 0, null, 12); } aVar.dismiss(); } return Unit.a; } } /* compiled from: PremiumGuildSubscriptionCancelDialog.kt */ public static final class e extends o implements Function0 { public final /* synthetic */ a this$0; /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public e(a aVar) { super(0); this.this$0 = aVar; } /* Return type fixed from 'java.lang.Object' to match base method */ @Override // kotlin.jvm.functions.Function0 /* renamed from: invoke */ public Long mo1invoke() { Bundle arguments = this.this$0.getArguments(); Long valueOf = arguments != null ? Long.valueOf(arguments.getLong("extra_slot_id")) : null; Objects.requireNonNull(valueOf, "null cannot be cast to non-null type com.discord.models.domain.PremiumGuildSubscriptionSlotId /* = kotlin.Long */"); return Long.valueOf(valueOf.longValue()); } } /* compiled from: PremiumGuildSubscriptionCancelDialog.kt */ public static final class f extends o implements Function0> { public final /* synthetic */ a this$0; /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public f(a aVar) { super(0); this.this$0 = aVar; } /* Return type fixed from 'java.lang.Object' to match base method */ @Override // kotlin.jvm.functions.Function0 /* renamed from: invoke */ public AppViewModel mo1invoke() { return new f(((Number) this.this$0.m.getValue()).longValue(), null, null, null, null, 30); } } public a() { super(2131558637); f fVar = new f(this); h0 h0Var = new h0(this); this.l = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(f.class), new m(2, h0Var), new j0(fVar)); this.m = g.lazy(new e(this)); } public final v0 g() { return (v0) this.k.getValue((Fragment) this, i[0]); } @Override // com.discord.app.AppDialog public void onViewBound(View view) { m.checkNotNullParameter(view, "view"); super.onViewBound(view); g().g.setOnClickListener(new View$OnClickListenerC0009a(0, this)); g().f165c.setOnClickListener(new View$OnClickListenerC0009a(1, this)); } @Override // com.discord.app.AppDialog public void onViewBoundOrOnResume() { super.onViewBoundOrOnResume(); Observable s2 = ((f) this.l.getValue()).observeViewState().s(); m.checkNotNullExpressionValue(s2, "viewModel\n .obser… .distinctUntilChanged()"); ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle(s2, this), a.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new d(this), 62, (Object) null); } }