package com.ss.android.ugc.aweme.im.sdk.chat.feature.input.gifpanel.bottomsheet;

import X.0EB;
import X.0HH;
import X.28B;
import X.2om;
import X.3S8;
import X.4ZZ;
import X.7he;
import X.C1469Iia;
import X.C2176Itz;
import X.C2586J1l;
import X.Crj;
import X.CsY;
import X.Fpa;
import X.Fpd;
import X.Fpe;
import X.Fpf;
import X.HeD;
import X.J22;
import X.J24;
import X.J26;
import X.J28;
import X.J5K;
import X.KEM;
import X.LnI;
import X.Ls2;
import X.M12;
import X.Qeg;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import com.bytedance.covode.number.Covode;
import com.bytedance.tux.sheet.sheet.TuxSheet;
import com.ss.android.ugc.aweme.im.sdk.chat.feature.input.gifpanel.GifController;
import com.ss.android.ugc.aweme.im.sdk.chat.feature.input.gifpanel.GiphyViewModel;
import java.util.HashMap;
import kotlin.h.b.n;

public final class GifChoosePanelBottomSheet extends Hilt_GifChoosePanelBottomSheet {
    public static final Fpa LJIIIIZZ = new Fpa((byte) 0);
    public C2586J1l LJ;
    public 28B LJFF;
    public ProgressBar LJI;
    public Qeg LJII;
    public View LJIIIZ;
    public 4ZZ LJIIJ;
    public final Crj LJIIJJI = 7he.LIZ(new J26(this));
    public final Crj LJIIL;
    public HashMap LJIILIIL;

    static {
        Covode.recordClassIndex(84516);
    }

    public final View LIZ(int i) {
        if (this.LJIILIIL == null) {
            this.LJIILIIL = new HashMap();
        }
        View view = (View) this.LJIILIIL.get(Integer.valueOf(i));
        if (view != null) {
            return view;
        }
        View view2 = getView();
        if (view2 == null) {
            return null;
        }
        View findViewById = view2.findViewById(i);
        this.LJIILIIL.put(Integer.valueOf(i), findViewById);
        return findViewById;
    }

    public final GifController LIZ() {
        return (GifController) this.LJIIJJI.getValue();
    }

    public final GiphyViewModel LIZIZ() {
        return (GiphyViewModel) this.LJIIL.getValue();
    }

    public final void LJI() {
        HashMap hashMap = this.LJIILIIL;
        if (hashMap != null) {
            hashMap.clear();
        }
    }

    public final /* synthetic */ void onDestroyView() {
        GifChoosePanelBottomSheet.super.onDestroyView();
        LJI();
    }

    public final void onStart() {
        GifChoosePanelBottomSheet.super.onStart();
        LIZIZ().LIZ();
    }

    public GifChoosePanelBottomSheet() {
        Fpd fpd = new Fpd(this);
        this.LJIIL = CsY.LIZ(this, KEM.LIZ.LIZ(GiphyViewModel.class), new C1469Iia(fpd), (Ls2) null);
    }

    public final void LIZ(C2586J1l j1l) {
        M12.LIZ(j1l);
        this.LJ = j1l;
    }

    public final void onViewCreated(View view, Bundle bundle) {
        M12.LIZ(view);
        if (this.LJ == null) {
            3S8.LIZ(TuxSheet.LJIJI, this);
            return;
        }
        View findViewById = view.findViewById(2131369974);
        n.LIZIZ(findViewById, "");
        this.LJIIIZ = findViewById;
        4ZZ findViewById2 = view.findViewById(2131363385);
        n.LIZIZ(findViewById2, "");
        this.LJIIJ = findViewById2;
        28B findViewById3 = view.findViewById(2131369388);
        n.LIZIZ(findViewById3, "");
        this.LJFF = findViewById3;
        View findViewById4 = view.findViewById(2131369000);
        n.LIZIZ(findViewById4, "");
        this.LJI = (ProgressBar) findViewById4;
        Qeg findViewById5 = view.findViewById(2131370606);
        n.LIZIZ(findViewById5, "");
        this.LJII = findViewById5;
        4ZZ r1 = this.LJIIJ;
        if (r1 == null) {
            n.LIZ("");
        }
        r1.setOnClickListener(new Fpf(this));
        28B r5 = this.LJFF;
        if (r5 == null) {
            n.LIZ("");
        }
        r5.setController(LIZ());
        StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(3, 1);
        staggeredGridLayoutManager.LJIIIIZZ();
        r5.setLayoutManager(staggeredGridLayoutManager);
        r5.setItemAnimator((0EB) null);
        r5.LIZ(new J5K(3, LnI.LIZ(HeD.LIZIZ(requireContext(), 8.0f))));
        r5.LIZ(new C2176Itz(this));
        2om.LIZIZ.LIZ("gif_choose_panel_bottomsheet_async").LIZ(r5);
        LIZIZ().LIZ.observe(this, new J24(this));
        LIZIZ().LJ.observe(this, new J28(this));
        LIZIZ().LIZLLL.observe(this, new J22(this));
        LIZIZ().LJFF.observe(this, new Fpe(this));
        LIZIZ().LIZ(true);
    }

    public final View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        M12.LIZ(layoutInflater);
        return 0HH.LIZ(layoutInflater, 2131559994, viewGroup, false);
    }
}
