package c.a.y; import android.animation.Animator; import android.animation.AnimatorInflater; import android.content.Context; import android.content.res.Configuration; import android.text.Editable; import android.view.LayoutInflater; import android.view.View; import android.widget.EditText; import android.widget.TextView; import androidx.recyclerview.widget.RecyclerView; import c.a.i.s0; import com.airbnb.lottie.parser.AnimatableValueParser; import com.discord.api.channel.Channel; import com.discord.app.AppComponent; import com.discord.utilities.mg_recycler.MGRecyclerAdapter; import com.discord.utilities.rx.ObservableExtensionsKt; import com.discord.utilities.view.extensions.ViewExtensions; import com.discord.utilities.view.text.TextWatcher; import com.discord.widgets.user.search.WidgetGlobalSearchAdapter; import com.discord.widgets.user.search.WidgetGlobalSearchModel; import com.google.android.material.textfield.TextInputLayout; import d0.z.d.m; import d0.z.d.o; import java.util.ArrayList; import java.util.List; import kotlin.Unit; import kotlin.jvm.functions.Function0; import kotlin.jvm.functions.Function1; import rx.Observable; import rx.subjects.BehaviorSubject; /* compiled from: OverlayVoiceSelectorBubbleDialog.kt */ public final class y extends k implements AppComponent { public final BehaviorSubject A = BehaviorSubject.l0(""); public String B; /* renamed from: y reason: collision with root package name */ public s0 f242y; /* renamed from: z reason: collision with root package name */ public final WidgetGlobalSearchAdapter f243z; /* compiled from: OverlayVoiceSelectorBubbleDialog.kt */ public static final class a implements View.OnClickListener { public final /* synthetic */ y i; public a(y yVar) { this.i = yVar; } @Override // android.view.View.OnClickListener public final void onClick(View view) { this.i.g(); } } /* compiled from: OverlayVoiceSelectorBubbleDialog.kt */ public static final class b extends o implements Function1 { public final /* synthetic */ y this$0; /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public b(y yVar) { super(1); this.this$0 = yVar; } /* 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(Editable editable) { Editable editable2 = editable; m.checkNotNullParameter(editable2, "editable"); this.this$0.A.onNext(editable2.toString()); return Unit.a; } } /* compiled from: OverlayVoiceSelectorBubbleDialog.kt */ public static final class c implements j0.k.b { public static final c i = new c(); /* 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 // j0.k.b public String call(String str) { return '!' + str; } } /* compiled from: OverlayVoiceSelectorBubbleDialog.kt */ public static final class d extends o implements Function1 { public final /* synthetic */ y this$0; /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public d(y yVar) { super(1); this.this$0 = yVar; } /* 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(WidgetGlobalSearchModel widgetGlobalSearchModel) { WidgetGlobalSearchModel widgetGlobalSearchModel2 = widgetGlobalSearchModel; m.checkNotNullParameter(widgetGlobalSearchModel2, "it"); y yVar = this.this$0; TextView textView = yVar.f242y.d; m.checkNotNullExpressionValue(textView, "binding.emptyResults"); int i = 8; textView.setVisibility(widgetGlobalSearchModel2.getData().isEmpty() ? 0 : 8); RecyclerView recyclerView = yVar.f242y.f; m.checkNotNullExpressionValue(recyclerView, "binding.resultsRv"); if (!widgetGlobalSearchModel2.getData().isEmpty()) { i = 0; } recyclerView.setVisibility(i); WidgetGlobalSearchAdapter widgetGlobalSearchAdapter = yVar.f243z; widgetGlobalSearchAdapter.setOnUpdated(new w(yVar, widgetGlobalSearchModel2)); List data = widgetGlobalSearchModel2.getData(); ArrayList arrayList = new ArrayList(); for (Object obj : data) { Channel channel = ((WidgetGlobalSearchModel.ItemDataPayload) obj).getChannel(); if (channel != null && AnimatableValueParser.C1(channel)) { arrayList.add(obj); } } widgetGlobalSearchAdapter.setData(arrayList); widgetGlobalSearchAdapter.setOnSelectedListener(new x(yVar, widgetGlobalSearchModel2)); return Unit.a; } } /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public y(Context context) { super(context); m.checkNotNullParameter(context, "context"); getWindowLayoutParams().flags &= -9; s0 a2 = s0.a(LayoutInflater.from(getContext()), this, true); m.checkNotNullExpressionValue(a2, "OverlayVoiceChannelSelec…rom(context), this, true)"); this.f242y = a2; RecyclerView recyclerView = this.f242y.f; m.checkNotNullExpressionValue(recyclerView, "binding.resultsRv"); this.f243z = new WidgetGlobalSearchAdapter(recyclerView); } @Override // c.a.y.k public Animator getClosingAnimator() { Animator loadAnimator = AnimatorInflater.loadAnimator(getContext(), 2130837533); loadAnimator.setTarget(this.f242y.f153c); m.checkNotNullExpressionValue(loadAnimator, "AnimatorInflater.loadAni…binding.dialogCard)\n }"); return loadAnimator; } public final void h() { this.f242y.b.setOnClickListener(new a(this)); TextInputLayout textInputLayout = this.f242y.e; m.checkNotNullExpressionValue(textInputLayout, "binding.overlayChannelSearch"); ViewExtensions.setText(textInputLayout, this.B); TextInputLayout textInputLayout2 = this.f242y.e; m.checkNotNullExpressionValue(textInputLayout2, "binding.overlayChannelSearch"); EditText editText = textInputLayout2.getEditText(); if (editText != null) { editText.addTextChangedListener(new TextWatcher(null, null, new b(this), 3, null)); } WidgetGlobalSearchAdapter widgetGlobalSearchAdapter = this.f243z; RecyclerView recyclerView = this.f242y.f; m.checkNotNullExpressionValue(recyclerView, "binding.resultsRv"); widgetGlobalSearchAdapter.setRecycler(recyclerView); MGRecyclerAdapter.Companion.configure(this.f243z); WidgetGlobalSearchModel.Companion companion = WidgetGlobalSearchModel.Companion; Observable F = this.A.F(c.i); m.checkNotNullExpressionValue(F, "filterPublisher.map { \"!$it\" }"); ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui(companion.getForNav(F), this, this.f243z), y.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new d(this), 62, (Object) null); } @Override // android.view.View, android.view.ViewGroup public void onAttachedToWindow() { super.onAttachedToWindow(); h(); Animator loadAnimator = AnimatorInflater.loadAnimator(getContext(), 2130837534); loadAnimator.setTarget(this.f242y.f153c); loadAnimator.start(); } @Override // com.discord.overlay.views.OverlayDialog, com.discord.overlay.views.OverlayBubbleWrap, android.view.View public void onConfigurationChanged(Configuration configuration) { super.onConfigurationChanged(configuration); getUnsubscribeSignal().onNext(null); removeAllViewsInLayout(); s0 a2 = s0.a(LayoutInflater.from(getContext()), this, true); m.checkNotNullExpressionValue(a2, "OverlayVoiceChannelSelec…rom(context), this, true)"); this.f242y = a2; h(); } }