package com.ss.android.ugc.aweme.find.ui;

import X.070;
import X.0Bv;
import X.0CH;
import X.0E3;
import X.0Q5;
import X.0Q6;
import X.2HN;
import X.2K7;
import X.2Pr;
import X.2UX;
import X.2cN;
import X.2nK;
import X.2xd;
import X.2yg;
import X.3Ok;
import X.4Dd;
import X.5Am;
import X.5An;
import X.5vY;
import X.5wO;
import X.7he;
import X.8gF;
import X.Aid;
import X.Alx;
import X.B1N;
import X.B8T;
import X.C0295Crj;
import X.C0435Cwt;
import X.C0643D4t;
import X.C1345DVt;
import X.C3471EFn;
import X.C3621ELh;
import X.C3622ELi;
import X.C3623ELj;
import X.C3665EMz;
import X.C3668ENc;
import X.C3872EUy;
import X.C3873EUz;
import X.C3886EVm;
import X.C3887EVn;
import X.C3888EVo;
import X.C3889EVp;
import X.C3890EVq;
import X.C3918EWs;
import X.C4034EaU;
import X.C5640F0y;
import X.D1G;
import X.DRZ;
import X.DUS;
import X.DUT;
import X.DV9;
import X.DVU;
import X.EK0;
import X.EK2;
import X.EK3;
import X.EK6;
import X.EK9;
import X.EKA;
import X.EKQ;
import X.EKY;
import X.EKZ;
import X.ESC;
import X.EVX;
import X.EVZ;
import X.EWG;
import X.EWI;
import X.EWJ;
import X.EX4;
import X.F1O;
import X.F6Z;
import X.KEM;
import X.Lpl;
import X.LsC;
import X.LsD;
import X.LsE;
import X.LsF;
import X.Lsh;
import X.M12;
import X.Mjy;
import X.Mk2;
import X.Mk3;
import X.OQM;
import X.OQg;
import X.OQh;
import X.PHD;
import X.Qeg;
import X.Qsn;
import X.SNU;
import X.SV6;
import X.SX3;
import X.SXD;
import X.SY7;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.SparseArray;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import androidx.recyclerview.widget.RecyclerView;
import com.bytedance.apm.agent.v2.instrumentation.ActivityAgent;
import com.bytedance.covode.number.Covode;
import com.bytedance.jedi.arch.JediViewModel;
import com.bytedance.jedi.arch.lifecycleAwareLazy;
import com.bytedance.router.arg.RouteArgExtension;
import com.bytedance.sysoptimizer.EnterTransitionCrashOptimizer;
import com.ss.android.ugc.aweme.find.viewmodel.FindFriendsViewModel;
import com.ss.android.ugc.aweme.keyword.SearchKeywordPresenter;
import com.ss.android.ugc.aweme.profile.model.User;
import com.ss.android.ugc.aweme.services.function.FunctionSupportService;
import com.ss.android.ugc.aweme.services.function.IFunctionKey;
import com.ss.android.ugc.aweme.views.WrapLinearLayoutManager;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import kotlin.h.b.n;

public final class FindFriendsActivity extends SNU implements 0Q6, B1N<Aid>, 5vY {
    public final Aid LIZ = new Aid();
    public final Mjy LIZIZ;
    public final SearchKeywordPresenter LIZJ;
    public EX4 LIZLLL;
    public final lifecycleAwareLazy LJ;
    public final C0295Crj LJFF;
    public final C0295Crj LJI;
    public final C0295Crj LJII;
    public final C0295Crj LJIIIIZZ;
    public SparseArray LJIIIZ;

    static {
        Covode.recordClassIndex(80504);
    }

    private final String LJIIJ() {
        return (String) this.LJII.getValue();
    }

    public final FindFriendsViewModel LIZLLL() {
        return (FindFriendsViewModel) this.LJ.getValue();
    }

    public final C3471EFn LJ() {
        return (C3471EFn) this.LJFF.getValue();
    }

    public final WrapLinearLayoutManager LJFF() {
        return (WrapLinearLayoutManager) this.LJI.getValue();
    }

    public final C3890EVq LJI() {
        return (C3890EVq) this.LJIIIIZZ.getValue();
    }

    public final void _$_clearFindViewByIdCache() {
        SparseArray sparseArray = this.LJIIIZ;
        if (sparseArray != null) {
            sparseArray.clear();
        }
    }

    public final View _$_findCachedViewById(int i) {
        if (this.LJIIIZ == null) {
            this.LJIIIZ = new SparseArray();
        }
        View view = (View) this.LJIIIZ.get(i);
        if (view != null) {
            return view;
        }
        View findViewById = findViewById(i);
        this.LJIIIZ.put(i, findViewById);
        return findViewById;
    }

    public final String getBtmPageCode() {
        return "b2793";
    }

    public final boolean getUniqueOnlyGlobal() {
        return true;
    }

    /* JADX WARNING: type inference failed for: r0v0, types: [com.ss.android.ugc.aweme.find.ui.FindFriendsActivity, X.SNU, android.app.Activity] */
    public final void onPause() {
        8gF.LIZJ(this);
        FindFriendsActivity.super.onPause();
    }

    /* JADX WARNING: type inference failed for: r0v0, types: [com.ss.android.ugc.aweme.find.ui.FindFriendsActivity, X.SNU, android.app.Activity] */
    public final void onStart() {
        8gF.LIZ(this);
        FindFriendsActivity.super.onStart();
    }

    public final void onWindowFocusChanged(boolean z) {
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.find.ui.FindFriendsActivity", "onWindowFocusChanged", true);
        FindFriendsActivity.super.onWindowFocusChanged(z);
    }

    public final /* bridge */ /* synthetic */ 0Bv be_() {
        return this.LIZ;
    }

    public final /* bridge */ /* synthetic */ 5An getReceiver() {
        return this;
    }

    public final String aB_() {
        return 0Q5.LIZ(this);
    }

    public final Map<String, String> aE_() {
        M12.LIZ(this);
        return null;
    }

    public final 0CH getLifecycleOwner() {
        5wO.LIZJ(this);
        return this;
    }

    /* JADX WARNING: type inference failed for: r0v0, types: [X.DUz] */
    /* JADX WARNING: Multi-variable type inference failed */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final X.C1325DUz getLifecycleOwnerHolder() {
        /*
            r1 = this;
            X.5wO.LIZ(r1)
            r0 = r1
            return r0
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.find.ui.FindFriendsActivity.getLifecycleOwnerHolder():X.DUz");
    }

    /* JADX WARNING: type inference failed for: r0v0, types: [X.DUy<X.DVU>] */
    /* JADX WARNING: Multi-variable type inference failed */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final X.C1324DUy<X.DVU> getReceiverHolder() {
        /*
            r1 = this;
            X.5wO.LIZIZ(r1)
            r0 = r1
            return r0
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.find.ui.FindFriendsActivity.getReceiverHolder():X.DUy");
    }

    public static boolean LJIIJJI() {
        try {
            return 2K7.LIZ.LIZJ();
        } catch (Exception unused) {
            return false;
        }
    }

    /* JADX WARNING: type inference failed for: r1v0, types: [android.content.Context] */
    /* JADX WARNING: Multi-variable type inference failed */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final void LJIIIIZZ() {
        /*
            r2 = this;
            r1 = r2
            java.lang.String r0 = "//friends/contacts"
            com.bytedance.router.SmartRoute r1 = com.bytedance.router.SmartRouter.buildRoute(r1, r0)
            r0 = 536870912(0x20000000, float:1.0842022E-19)
            r1.addFlags(r0)
            r1.open()
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.find.ui.FindFriendsActivity.LJIIIIZZ():void");
    }

    public final void finish() {
        withState(LIZLLL(), new EKZ(this));
    }

    /* JADX WARNING: type inference failed for: r1v0, types: [android.content.Context] */
    /* JADX WARNING: Multi-variable type inference failed */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final void LJIIIZ() {
        /*
            r3 = this;
            r1 = r3
            android.content.Intent r2 = new android.content.Intent
            java.lang.Class<com.ss.android.ugc.aweme.friends.ui.InviteUserListActivity> r0 = com.ss.android.ugc.aweme.friends.ui.InviteUserListActivity.class
            r2.<init>(r1, r0)
            java.lang.String r1 = "type"
            r0 = 3
            r2.putExtra(r1, r0)
            java.lang.String r0 = ""
            kotlin.h.b.n.LIZIZ(r2, r0)
            r0 = 536870912(0x20000000, float:1.0842022E-19)
            r2.setFlags(r0)
            X.3i8.LIZ(r2, r3)
            r3.startActivity(r2)
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.find.ui.FindFriendsActivity.LJIIIZ():void");
    }

    /* JADX WARNING: type inference failed for: r3v0, types: [com.ss.android.ugc.aweme.find.ui.FindFriendsActivity, X.SNU, android.app.Activity] */
    public final void onResume() {
        8gF.LIZIZ(this);
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.find.ui.FindFriendsActivity", "onResume", true);
        FindFriendsActivity.super.onResume();
        LIZLLL().LIZIZ();
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.find.ui.FindFriendsActivity", "onResume", false);
    }

    /* JADX WARNING: type inference failed for: r1v0, types: [com.ss.android.ugc.aweme.find.ui.FindFriendsActivity, X.SNU, android.app.Activity] */
    public final void onStop() {
        8gF.LIZLLL(this);
        FindFriendsActivity.super.onStop();
        if (EnterTransitionCrashOptimizer.getContext() != null) {
            try {
                getWindow().getDecorView().getViewTreeObserver().dispatchOnPreDraw();
            } catch (Throwable unused) {
            }
        }
        try {
            getWindow().getDecorView().getViewTreeObserver().dispatchOnPreDraw();
        } catch (Throwable unused2) {
        }
    }

    /* JADX WARNING: type inference failed for: r5v0, types: [com.ss.android.ugc.aweme.find.ui.FindFriendsActivity, X.1oX, android.app.Activity] */
    public FindFriendsActivity() {
        D1G LIZ2 = KEM.LIZ.LIZ(FindFriendsViewModel.class);
        this.LJ = new lifecycleAwareLazy(this, new C3623ELj(this, LIZ2, C3622ELi.INSTANCE, LIZ2));
        this.LJFF = 7he.LIZ(new C3621ELh(this));
        this.LIZIZ = new Mjy();
        this.LIZJ = new SearchKeywordPresenter(this);
        this.LJI = 7he.LIZ(new C3872EUy(this));
        this.LJII = RouteArgExtension.INSTANCE.optionalArg(this, C3665EMz.LIZ, "previous_page", String.class);
        this.LJIIIIZZ = 7he.LIZ(new EWG(this));
    }

    public final void LJII() {
        OQh oQh = new OQh();
        oQh.LIZ(2xd.LIZ(2yg.LIZ));
        String string = getString(2131822227);
        n.LIZIZ(string, "");
        oQh.LIZ(string);
        String string2 = getString(2131822222);
        n.LIZIZ(string2, "");
        oQh.LIZ(string2);
        oQh.LJIIIZ = new C3668ENc(this);
        _$_findCachedViewById(2131370625).setStatus(oQh);
        OQg _$_findCachedViewById = _$_findCachedViewById(2131370625);
        n.LIZIZ(_$_findCachedViewById, "");
        _$_findCachedViewById.setVisibility(0);
    }

    /* JADX WARNING: type inference failed for: r5v0, types: [com.ss.android.ugc.aweme.find.ui.FindFriendsActivity, X.SNU, android.app.Activity] */
    public final void onDestroy() {
        String str;
        int i;
        8gF.LJ(this);
        FindFriendsViewModel LIZLLL2 = LIZLLL();
        int size = LIZLLL2.LIZJ.size();
        if (size > 0) {
            str = "";
        } else if (!LIZLLL2.LIZLLL) {
            str = "no_internet";
        } else if (LIZLLL2.LJ) {
            str = "requesting";
        } else {
            str = "other";
        }
        2UX r2 = new 2UX();
        if (size <= 0) {
            i = 0;
        } else {
            i = 1;
        }
        r2.LIZ("rec_card_show", i);
        r2.LIZ("rec_card_cnt", size);
        r2.LIZ("enter_method", "leave");
        r2.LIZ("reason", str);
        2nK.LIZ("find_friends_status", r2.LIZ);
        FindFriendsActivity.super.onDestroy();
        this.LIZIZ.LIZ();
        EX4 ex4 = this.LIZLLL;
        if (ex4 != null) {
            ex4.LIZJ();
        }
    }

    public final void LIZ(boolean z) {
        int i;
        boolean z2;
        FrameLayout frameLayout = (FrameLayout) _$_findCachedViewById(2131366933);
        n.LIZIZ(frameLayout, "");
        Qsn layoutParams = frameLayout.getLayoutParams();
        Objects.requireNonNull(layoutParams, "null cannot be cast to non-null type com.google.android.material.appbar.AppBarLayout.LayoutParams");
        Qsn qsn = layoutParams;
        int LJIILIIL = LJFF().LJIILIIL() + 1;
        RecyclerView _$_findCachedViewById = _$_findCachedViewById(2131369341);
        n.LIZIZ(_$_findCachedViewById, "");
        0E3 adapter = _$_findCachedViewById.getAdapter();
        if (adapter != null) {
            i = adapter.getItemCount();
        } else {
            i = 0;
        }
        if (LJIILIIL < i) {
            z2 = true;
        } else {
            z2 = false;
        }
        if (!z || !z2) {
            qsn.LIZ = 0;
            _$_findCachedViewById(2131362368).setExpanded(true);
        } else {
            qsn.LIZ = 1;
        }
        FrameLayout frameLayout2 = (FrameLayout) _$_findCachedViewById(2131366933);
        n.LIZIZ(frameLayout2, "");
        frameLayout2.setLayoutParams(qsn);
    }

    /* JADX WARNING: type inference failed for: r14v0, types: [com.ss.android.ugc.aweme.find.ui.FindFriendsActivity, X.DV1, X.4Qh, X.SNU, android.app.Activity] */
    public final void onCreate(Bundle bundle) {
        8gF.LIZ(this, bundle);
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.find.ui.FindFriendsActivity", "onCreate", true);
        activityConfiguration(C3918EWs.LIZ);
        FindFriendsActivity.super.onCreate(bundle);
        setContentView(2131559773);
        String LJIIJ = LJIIJ();
        if (LJIIJ != null) {
            FindFriendsViewModel LIZLLL2 = LIZLLL();
            M12.LIZ(LJIIJ);
            LIZLLL2.LJI = LJIIJ;
        }
        2cN unused = selectSubscribe(LIZLLL(), EK0.LIZ, EK3.LIZ, DUS.LIZ(), new EK2(this));
        selectSubscribe(LIZLLL(), EKQ.LIZ, C1345DVt.LIZIZ(), new EK9(this));
        selectSubscribe(LIZLLL(), EKY.LIZ, C1345DVt.LIZIZ(), new C3887EVn(this));
        2cN unused2 = selectSubscribe(LIZLLL(), EK6.LIZ, DUS.LIZ(), new EKA(this));
        _$_findCachedViewById(2131371262).setTitle(2131825110);
        OQM _$_findCachedViewById = _$_findCachedViewById(2131371262);
        n.LIZIZ(_$_findCachedViewById, "");
        _$_findCachedViewById(2131371262).setTitleColor(070.LIZJ(_$_findCachedViewById.getContext(), 2131099750));
        _$_findCachedViewById(2131371262).setOnTitleBarClickListener(new EVZ(this));
        if (FunctionSupportService.INSTANCE.notSupport(IFunctionKey.QR_CODE)) {
            OQM _$_findCachedViewById2 = _$_findCachedViewById(2131371262);
            n.LIZIZ(_$_findCachedViewById2, "");
            ImageView endBtn = _$_findCachedViewById2.getEndBtn();
            n.LIZIZ(endBtn, "");
            endBtn.setVisibility(8);
        }
        _$_findCachedViewById(2131366936).LIZ(this, this.LIZJ, LJI());
        View _$_findCachedViewById3 = _$_findCachedViewById(2131364136);
        n.LIZIZ(_$_findCachedViewById3, "");
        _$_findCachedViewById3.setVisibility(8);
        if (LJIIJJI()) {
            FrameLayout frameLayout = (FrameLayout) _$_findCachedViewById(2131366933);
            n.LIZIZ(frameLayout, "");
            frameLayout.setVisibility(0);
        }
        _$_findCachedViewById(2131364632).setOnTouchListener(new EVX(this));
        _$_findCachedViewById(2131372289).setOnClickListener(new EWI(this));
        _$_findCachedViewById(2131363031).setOnClickListener(new EWJ(this));
        Lpl _$_findCachedViewById4 = _$_findCachedViewById(2131364632);
        n.LIZIZ(_$_findCachedViewById4, "");
        2cN LIZLLL3 = Alx.LIZ(_$_findCachedViewById4).LIZLLL(500, TimeUnit.MILLISECONDS).LIZ(Mk2.LIZ(Mk3.LIZ)).LIZLLL(new C3888EVo(this));
        n.LIZIZ(LIZLLL3, "");
        4Dd.LIZ(LIZLLL3, this.LIZIZ);
        _$_findCachedViewById(2131364632).setOnEditorActionListener(new C3886EVm(this));
        if (this.LIZLLL == null) {
            FrameLayout frameLayout2 = (FrameLayout) _$_findCachedViewById(2131366934);
            n.LIZIZ(frameLayout2, "");
            Qeg _$_findCachedViewById5 = _$_findCachedViewById(2131372289);
            n.LIZIZ(_$_findCachedViewById5, "");
            SX3 _$_findCachedViewById6 = _$_findCachedViewById(2131366936);
            n.LIZIZ(_$_findCachedViewById6, "");
            this.LIZLLL = new EX4(frameLayout2, _$_findCachedViewById5, _$_findCachedViewById6, new C3889EVp(this));
        }
        C4034EaU.LIZ.LIZ(this).LIZJ.LIZJ().LIZ("source_default_key", new SXD((SV6) null, (SY7) null, 3, (2HN) null), SXD.class);
        LJ().LIZ = LIZLLL().LJI;
        RecyclerView _$_findCachedViewById7 = _$_findCachedViewById(2131369341);
        n.LIZIZ(_$_findCachedViewById7, "");
        _$_findCachedViewById7.setAdapter(LJ());
        RecyclerView _$_findCachedViewById8 = _$_findCachedViewById(2131369341);
        n.LIZIZ(_$_findCachedViewById8, "");
        _$_findCachedViewById8.setLayoutManager(LJFF());
        3Ok r6 = new 3Ok();
        r6.element = false;
        _$_findCachedViewById(2131369341).LIZ(new C3873EUz(this, r6));
        LIZLLL().LIZ(-1);
        User LIZJ2 = ESC.LIZJ();
        n.LIZIZ(LIZJ2, "");
        2cN LJIIIIZZ2 = F6Z.LIZ.LIZ((Context) this, (Class<? extends F1O>) C5640F0y.class, LIZJ2.getUid(), "find_friends_page", "auto", false, true, (Map<String, String>) null).LJIIIIZZ();
        n.LIZIZ(LJIIIIZZ2, "");
        4Dd.LIZ(LJIIIIZZ2, this.LIZIZ);
        if (TextUtils.equals(LJIIJ(), "homepage_friends")) {
            2UX r5 = new 2UX();
            r5.LIZ("enter_from", LJIIJ());
            2nK.LIZ("enter_find_friends", r5.LIZ);
        }
        LIZLLL();
        2UX r52 = new 2UX();
        r52.LIZ("rec_card_show", 0);
        r52.LIZ("enter_method", "enter");
        2nK.LIZ("find_friends_status", r52.LIZ);
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.find.ui.FindFriendsActivity", "onCreate", false);
    }

    public final <VM1 extends JediViewModel<S1>, S1 extends 5Am, R> R withState(VM1 vm1, LsC<? super S1, ? extends R> lsC) {
        M12.LIZ(vm1, lsC);
        return 5wO.LIZ(vm1, lsC);
    }

    public final <S extends 5Am> 2cN subscribe(JediViewModel<S> jediViewModel, DUT<S> dut, LsD<? super DVU, ? super S, 2Pr> lsD) {
        M12.LIZ(jediViewModel, dut, lsD);
        return 5wO.LIZ(this, jediViewModel, dut, lsD);
    }

    public final void onActivityResult(int i, int i2, Intent intent) {
        FindFriendsActivity.super.onActivityResult(i, i2, intent);
        LIZLLL().LIZIZ();
    }

    public final <S extends 5Am, A> 2cN selectSubscribe(JediViewModel<S> jediViewModel, PHD<S, ? extends A> phd, DUT<DRZ<A>> dut, LsD<? super DVU, ? super A, 2Pr> lsD) {
        M12.LIZ(jediViewModel, phd, dut, lsD);
        return 5wO.LIZ(this, jediViewModel, phd, dut, lsD);
    }

    public final <S extends 5Am, A, B> 2cN selectSubscribe(JediViewModel<S> jediViewModel, PHD<S, ? extends A> phd, PHD<S, ? extends B> phd2, DUT<C0435Cwt<A, B>> dut, LsE<? super DVU, ? super A, ? super B, 2Pr> lsE) {
        M12.LIZ(jediViewModel, phd, phd2, dut, lsE);
        return 5wO.LIZ(this, jediViewModel, phd, phd2, dut, lsE);
    }

    public final <S extends 5Am, T> 2cN asyncSubscribe(JediViewModel<S> jediViewModel, PHD<S, ? extends B8T<? extends T>> phd, DUT<DRZ<B8T<T>>> dut, LsD<? super DVU, ? super Throwable, 2Pr> lsD, LsC<? super DVU, 2Pr> lsC, LsD<? super DVU, ? super T, 2Pr> lsD2) {
        M12.LIZ(jediViewModel, phd, dut);
        return 5wO.LIZ(this, jediViewModel, phd, dut, lsD, lsC, lsD2);
    }

    public final <S extends 5Am, A, B, C> 2cN selectSubscribe(JediViewModel<S> jediViewModel, PHD<S, ? extends A> phd, PHD<S, ? extends B> phd2, PHD<S, ? extends C> phd3, DUT<DV9<A, B, C>> dut, LsF<? super DVU, ? super A, ? super B, ? super C, 2Pr> lsF) {
        M12.LIZ(jediViewModel, phd, phd2, phd3, dut, lsF);
        return 5wO.LIZ(this, jediViewModel, phd, phd2, phd3, dut, lsF);
    }

    public final <S extends 5Am, A, B, C, D> 2cN selectSubscribe(JediViewModel<S> jediViewModel, PHD<S, ? extends A> phd, PHD<S, ? extends B> phd2, PHD<S, ? extends C> phd3, PHD<S, ? extends D> phd4, DUT<C0643D4t<A, B, C, D>> dut, Lsh<? super DVU, ? super A, ? super B, ? super C, ? super D, 2Pr> lsh) {
        M12.LIZ(jediViewModel, phd, phd2, phd3, phd4, dut, lsh);
        return 5wO.LIZ(this, jediViewModel, phd, phd2, phd3, phd4, dut, lsh);
    }
}
