package qr; import android.annotation.SuppressLint; import android.app.Activity; import android.content.Context; import android.os.Build; import android.text.Editable; import android.text.TextWatcher; import android.view.KeyEvent; import android.view.View; import android.view.Window; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; import android.widget.ImageView; import android.widget.TextView; import bj2.h; import com.google.android.gms.common.GoogleApiAvailabilityLight; import com.tencent.ugc.videoprocessor.watermark.data.AnimatedPasterJsonConfig; import com.uber.autodispose.d; import com.uber.autodispose.y; import com.xingin.alpha.R$id; import com.xingin.alpha.R$string; import com.xingin.alpha.goods.search.input.AlphaGoodsSearchInputView; import com.xingin.android.mixim.msg.MsgType; import com.xingin.ui.round.SelectRoundFrameLayout; import dw2.r; import java.lang.reflect.Method; import java.util.Objects; import kotlin.Metadata; import kotlin.Unit; import kotlin.jvm.functions.Function0; import kotlin.jvm.internal.Intrinsics; import kotlin.jvm.internal.Lambda; import kotlin.text.StringsKt__StringsKt; import sy.f0; import sy.q1; import tu0.s; @Metadata(bv = {}, d1 = {"\u00002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\t\n\u0002\u0018\u0002\n\u0002\b\n\u0018\u00002\b\u0012\u0004\u0012\u00020\u00020\u0001B\u000f\u0012\u0006\u0010\u001d\u001a\u00020\u0002¢\u0006\u0004\b\u001e\u0010\u001fJ\b\u0010\u0004\u001a\u00020\u0003H\u0014J\u000e\u0010\u0007\u001a\u00020\u00032\u0006\u0010\u0006\u001a\u00020\u0005J\u000e\u0010\n\u001a\u00020\u00032\u0006\u0010\t\u001a\u00020\bJ\b\u0010\u000b\u001a\u00020\u0003H\u0007J\f\u0010\r\u001a\b\u0012\u0004\u0012\u00020\u00030\fJ\f\u0010\u000e\u001a\b\u0012\u0004\u0012\u00020\u00030\fJ\u000e\u0010\u0010\u001a\u00020\u00032\u0006\u0010\u000f\u001a\u00020\u0005J\b\u0010\u0011\u001a\u00020\u0003H\u0002J\b\u0010\u0012\u001a\u00020\u0003H\u0002J\b\u0010\u0013\u001a\u00020\u0003H\u0002J\b\u0010\u0014\u001a\u00020\u0003H\u0002J\u0010\u0010\u0015\u001a\u00020\u00032\u0006\u0010\u000f\u001a\u00020\u0005H\u0002R\u001d\u0010\u0017\u001a\b\u0012\u0004\u0012\u00020\u00050\u00168\u0006¢\u0006\f\n\u0004\b\u0017\u0010\u0018\u001a\u0004\b\u0019\u0010\u001aR\u001d\u0010\u001b\u001a\b\u0012\u0004\u0012\u00020\u00050\u00168\u0006¢\u0006\f\n\u0004\b\u001b\u0010\u0018\u001a\u0004\b\u001c\u0010\u001a¨\u0006 "}, d2 = {"Lqr/l;", "Ltu0/s;", "Lcom/xingin/alpha/goods/search/input/AlphaGoodsSearchInputView;", "", "didLoad", "", xs0.b.KV_KEY_HINT, "B", "", "isResultPage", GoogleApiAvailabilityLight.TRACKING_SOURCE_NOTIFICATION, "r", "Ldw2/r;", "l", "m", MsgType.TYPE_TEXT, "D", "x", "A", "y", "v", "C", "Ldx2/b;", "editTextChangeEvent", "Ldx2/b;", "t", "()Ldx2/b;", "searchEvent", "u", qo2.a.COPY_LINK_TYPE_VIEW, "<init>", "(Lcom/xingin/alpha/goods/search/input/AlphaGoodsSearchInputView;)V", "alpha_library_release"}, k = 1, mv = {1, 6, 0}) /* compiled from: AlphaGoodsSearchInputPresenter.kt */ public final class l extends s<AlphaGoodsSearchInputView> { /* renamed from: a reason: collision with root package name */ public long f123271a; /* renamed from: b reason: collision with root package name */ public final dx2.b<String> f123272b; /* renamed from: c reason: collision with root package name */ public final dx2.b<String> f123273c; /* renamed from: d reason: collision with root package name */ public final b f123274d; /* renamed from: e reason: collision with root package name */ public final View.OnFocusChangeListener f123275e; @Metadata(d1 = {"\u0000\b\n\u0000\n\u0002\u0010\u0002\n\u0000\u0010\u0000\u001a\u00020\u0001H\n¢\u0006\u0002\b\u0002"}, d2 = {"<anonymous>", "", "invoke"}, k = 3, mv = {1, 6, 0}, xi = 48) /* compiled from: AlphaGoodsSearchInputPresenter.kt */ public static final class a extends Lambda implements Function0<Unit> { /* renamed from: a reason: collision with root package name */ public final /* synthetic */ l f123276a; /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public a(l lVar) { super(0); this.f123276a = lVar; } @Override // kotlin.jvm.functions.Function0 public final void invoke() { ((EditText) l.j(this.f123276a)._$_findCachedViewById(R$id.b3a)).setText(""); } } @Metadata(bv = {}, d1 = {"\u0000!\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\r\n\u0002\u0010\b\n\u0002\b\u0007*\u0001\u0000\b\n\u0018\u00002\u00020\u0001J\u0012\u0010\u0005\u001a\u00020\u00042\b\u0010\u0003\u001a\u0004\u0018\u00010\u0002H\u0016J*\u0010\u000b\u001a\u00020\u00042\b\u0010\u0003\u001a\u0004\u0018\u00010\u00062\u0006\u0010\b\u001a\u00020\u00072\u0006\u0010\t\u001a\u00020\u00072\u0006\u0010\n\u001a\u00020\u0007H\u0016J*\u0010\r\u001a\u00020\u00042\b\u0010\u0003\u001a\u0004\u0018\u00010\u00062\u0006\u0010\b\u001a\u00020\u00072\u0006\u0010\f\u001a\u00020\u00072\u0006\u0010\t\u001a\u00020\u0007H\u0016¨\u0006\u000e"}, d2 = {"qr/l$b", "Landroid/text/TextWatcher;", "Landroid/text/Editable;", "s", "", "afterTextChanged", "", "", "start", AnimatedPasterJsonConfig.CONFIG_COUNT, "after", "beforeTextChanged", "before", "onTextChanged", "alpha_library_release"}, k = 1, mv = {1, 6, 0}) /* compiled from: AlphaGoodsSearchInputPresenter.kt */ public static final class b implements TextWatcher { /* renamed from: a reason: collision with root package name */ public final /* synthetic */ l f123277a; /* renamed from: b reason: collision with root package name */ public final /* synthetic */ AlphaGoodsSearchInputView f123278b; public b(l lVar, AlphaGoodsSearchInputView alphaGoodsSearchInputView) { this.f123277a = lVar; this.f123278b = alphaGoodsSearchInputView; } public void afterTextChanged(Editable editable) { } public void beforeTextChanged(CharSequence charSequence, int i10, int i14, int i15) { } public void onTextChanged(CharSequence charSequence, int i10, int i14, int i15) { if (System.currentTimeMillis() - this.f123277a.f123271a <= 100) { if (!(charSequence == null || charSequence.length() == 0)) { return; } } this.f123277a.f123271a = System.currentTimeMillis(); this.f123277a.t().a(this.f123278b.getToolBarText()); this.f123278b.n0(); } } /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public l(AlphaGoodsSearchInputView alphaGoodsSearchInputView) { super(alphaGoodsSearchInputView); Intrinsics.checkNotNullParameter(alphaGoodsSearchInputView, qo2.a.COPY_LINK_TYPE_VIEW); dx2.b<String> b24 = dx2.b.b2(); Intrinsics.checkNotNullExpressionValue(b24, "create()"); this.f123272b = b24; dx2.b<String> b25 = dx2.b.b2(); Intrinsics.checkNotNullExpressionValue(b25, "create()"); this.f123273c = b25; this.f123274d = new b(this, alphaGoodsSearchInputView); this.f123275e = new f(alphaGoodsSearchInputView, this); } public static final /* synthetic */ AlphaGoodsSearchInputView j(l lVar) { return (AlphaGoodsSearchInputView) lVar.getView(); } public static final void o(l lVar, Unit unit) { Intrinsics.checkNotNullParameter(lVar, "this$0"); lVar.y(); } public static final void p(Throwable th3) { } public static final boolean q(l lVar, TextView textView, int i10, KeyEvent keyEvent) { Intrinsics.checkNotNullParameter(lVar, "this$0"); if (i10 != 3) { return false; } String obj = StringsKt__StringsKt.trim((CharSequence) ((EditText) ((AlphaGoodsSearchInputView) lVar.getView())._$_findCachedViewById(R$id.b3a)).getText().toString()).toString(); if (obj.length() == 0) { f0.c(f0.f131631a, R$string.ao3, 0, 2, null); return true; } lVar.v(); lVar.f123273c.a(obj); return true; } public static final void s(AlphaGoodsSearchInputView alphaGoodsSearchInputView, l lVar, View view, boolean z14) { Intrinsics.checkNotNullParameter(alphaGoodsSearchInputView, "$view"); Intrinsics.checkNotNullParameter(lVar, "this$0"); if (z14) { alphaGoodsSearchInputView.n0(); Object systemService = alphaGoodsSearchInputView.getContext().getApplicationContext().getSystemService("input_method"); Objects.requireNonNull(systemService, "null cannot be cast to non-null type android.view.inputmethod.InputMethodManager"); ((InputMethodManager) systemService).showSoftInput((EditText) alphaGoodsSearchInputView._$_findCachedViewById(R$id.b3a), 1); } else if (Build.VERSION.SDK_INT > 29) { lVar.r(); } else { Object systemService2 = alphaGoodsSearchInputView.getContext().getApplicationContext().getSystemService("input_method"); Objects.requireNonNull(systemService2, "null cannot be cast to non-null type android.view.inputmethod.InputMethodManager"); ((InputMethodManager) systemService2).hideSoftInputFromWindow(((EditText) alphaGoodsSearchInputView._$_findCachedViewById(R$id.b3a)).getWindowToken(), 0); } } public static final void w(l lVar) { Intrinsics.checkNotNullParameter(lVar, "this$0"); int i10 = R$id.b3a; if (((EditText) ((AlphaGoodsSearchInputView) lVar.getView())._$_findCachedViewById(i10)).hasFocus()) { ((EditText) ((AlphaGoodsSearchInputView) lVar.getView())._$_findCachedViewById(i10)).clearFocus(); } t10.s.a(((AlphaGoodsSearchInputView) lVar.getView()).getContext()); } public static final void z(l lVar) { Intrinsics.checkNotNullParameter(lVar, "this$0"); int i10 = R$id.b3a; if (!((EditText) ((AlphaGoodsSearchInputView) lVar.getView())._$_findCachedViewById(i10)).hasFocus()) { ((EditText) ((AlphaGoodsSearchInputView) lVar.getView())._$_findCachedViewById(i10)).requestFocus(); } Context context = ((AlphaGoodsSearchInputView) lVar.getView()).getContext(); EditText editText = (EditText) ((AlphaGoodsSearchInputView) lVar.getView())._$_findCachedViewById(i10); Intrinsics.checkNotNullExpressionValue(editText, "view.etInput"); t10.s.c(context, editText); } public final void A() { int i10 = R$id.b3a; ((EditText) ((AlphaGoodsSearchInputView) getView())._$_findCachedViewById(i10)).setOnFocusChangeListener(null); ((EditText) ((AlphaGoodsSearchInputView) getView())._$_findCachedViewById(i10)).removeTextChangedListener(this.f123274d); } public final void B(String str) { Intrinsics.checkNotNullParameter(str, xs0.b.KV_KEY_HINT); ((EditText) ((AlphaGoodsSearchInputView) getView())._$_findCachedViewById(R$id.b3a)).setHint(str); } public final void C(String str) { int i10 = R$id.b3a; ((EditText) ((AlphaGoodsSearchInputView) getView())._$_findCachedViewById(i10)).setText(str); if (str.length() > 0) { this.f123272b.a(str); ((EditText) ((AlphaGoodsSearchInputView) getView())._$_findCachedViewById(i10)).setSelection(str.length()); } } public final void D(String str) { Intrinsics.checkNotNullParameter(str, MsgType.TYPE_TEXT); if (!Intrinsics.areEqual(((EditText) ((AlphaGoodsSearchInputView) getView())._$_findCachedViewById(R$id.b3a)).getText().toString(), str)) { A(); C(str); x(); } ((AlphaGoodsSearchInputView) getView()).n0(); v(); } @Override // tu0.n public void didLoad() { super.didLoad(); x(); y(); Object n14 = h.h((SelectRoundFrameLayout) ((AlphaGoodsSearchInputView) getView())._$_findCachedViewById(R$id.b9r), 0, 1, null).n(d.b(this)); Intrinsics.checkExpressionValueIsNotNull(n14, "this.`as`(AutoDispose.autoDisposable(provider))"); ((y) n14).a(new h(this), i.f123268a); ((EditText) ((AlphaGoodsSearchInputView) getView())._$_findCachedViewById(R$id.b3a)).setOnEditorActionListener(new g(this)); ImageView imageView = (ImageView) ((AlphaGoodsSearchInputView) getView())._$_findCachedViewById(R$id.ivDelete); Intrinsics.checkNotNullExpressionValue(imageView, "view.ivDelete"); q1.S(imageView, 0, new a(this), 1, null); } public final r<Unit> l() { return h.h((ImageView) ((AlphaGoodsSearchInputView) getView())._$_findCachedViewById(R$id.ivBack), 0, 1, null); } public final r<Unit> m() { return h.h((TextView) ((AlphaGoodsSearchInputView) getView())._$_findCachedViewById(R$id.fvo), 0, 1, null); } public final void n(boolean z14) { if (z14) { bj2.l.q((ImageView) ((AlphaGoodsSearchInputView) getView())._$_findCachedViewById(R$id.ivBack)); bj2.l.b((TextView) ((AlphaGoodsSearchInputView) getView())._$_findCachedViewById(R$id.fvo)); return; } bj2.l.b((ImageView) ((AlphaGoodsSearchInputView) getView())._$_findCachedViewById(R$id.ivBack)); bj2.l.q((TextView) ((AlphaGoodsSearchInputView) getView())._$_findCachedViewById(R$id.fvo)); } @SuppressLint({"BlockedPrivateApi"}) public final void r() { try { Context context = ((AlphaGoodsSearchInputView) getView()).getContext(); if (context != null) { Window window = ((Activity) context).getWindow(); Method method = window.getClass().getMethod("getInsetsController", new Class[0]); method.setAccessible(true); Object invoke = method.invoke(window, new Object[0]); Method declaredMethod = invoke.getClass().getDeclaredMethod("hide", Integer.TYPE); declaredMethod.setAccessible(true); declaredMethod.invoke(invoke, 8); return; } throw new NullPointerException("null cannot be cast to non-null type android.app.Activity"); } catch (Exception e14) { e14.printStackTrace(); Object systemService = ((AlphaGoodsSearchInputView) getView()).getContext().getApplicationContext().getSystemService("input_method"); Objects.requireNonNull(systemService, "null cannot be cast to non-null type android.view.inputmethod.InputMethodManager"); ((InputMethodManager) systemService).hideSoftInputFromWindow(((EditText) ((AlphaGoodsSearchInputView) getView())._$_findCachedViewById(R$id.b3a)).getWindowToken(), 0); } } public final dx2.b<String> t() { return this.f123272b; } public final dx2.b<String> u() { return this.f123273c; } public final void v() { ((SelectRoundFrameLayout) ((AlphaGoodsSearchInputView) getView())._$_findCachedViewById(R$id.b9r)).post(new k(this)); } public final void x() { int i10 = R$id.b3a; ((EditText) ((AlphaGoodsSearchInputView) getView())._$_findCachedViewById(i10)).setOnFocusChangeListener(this.f123275e); ((EditText) ((AlphaGoodsSearchInputView) getView())._$_findCachedViewById(i10)).addTextChangedListener(this.f123274d); } public final void y() { ((SelectRoundFrameLayout) ((AlphaGoodsSearchInputView) getView())._$_findCachedViewById(R$id.b9r)).post(new j(this)); } }