package com.ss.android.ugc.aweme.discover.presenter;

import X.0Bs;
import X.0Bv;
import X.0Bx;
import X.0By;
import X.1Bn;
import X.1hK;
import X.2GD;
import X.2GO;
import X.BbC;
import X.C3320STs;
import X.C3436SYe;
import X.C3679Sd9;
import X.C4295Sn5;
import X.CZs;
import X.M12;
import X.STH;
import X.STM;
import X.SU7;
import X.SUD;
import X.SYU;
import X.SZW;
import android.os.Bundle;
import android.util.SparseArray;
import android.view.View;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.discover.helper.MusicPlayHelper;
import com.ss.android.ugc.aweme.discover.model.SearchMusic;
import com.ss.android.ugc.aweme.discover.model.SearchObserver;
import com.ss.android.ugc.aweme.discover.model.SearchStateViewModel;
import com.ss.android.ugc.aweme.discover.ui.SearchOriginalFragment;
import java.util.Objects;
import kotlin.h.b.n;

public final class SearchMusicFragment extends SearchOriginalFragment<SearchMusic> implements 2GO {
    public MusicPlayHelper LIZ;
    public SparseArray LIZIZ;

    static {
        Covode.recordClassIndex(65266);
    }

    public final void LIZJ() {
        SparseArray sparseArray = this.LIZIZ;
        if (sparseArray != null) {
            sparseArray.clear();
        }
    }

    public final String LIZLLL() {
        return "music";
    }

    public final boolean LJIJI() {
        return true;
    }

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

    public final void LJIIIZ() {
        MusicPlayHelper musicPlayHelper = this.LIZ;
        if (musicPlayHelper != null) {
            musicPlayHelper.LIZ();
        }
    }

    public final void onPause() {
        super.onPause();
        LJIIIZ();
    }

    public SearchMusicFragment() {
        this.LJJIFFI = C3320STs.LIZIZ.LIZLLL();
    }

    public final void LJFF() {
        super.LJFF();
        C4295Sn5 sn5 = new C4295Sn5();
        sn5.LJIILJJIL("music_search_result");
        sn5.LJFF();
    }

    public final void LJIIJJI() {
        LIZ(new C3679Sd9(this.LIZ, this.LJJ, LJJIII(), this));
        CZs.LIZ(LJJIIJ(), new C3436SYe(this));
    }

    public final void LJIIIIZZ() {
        LIZ((SU7<?>) new STH());
        SU7<?> LJIIL = LJIIL();
        Objects.requireNonNull(LJIIL, "null cannot be cast to non-null type com.ss.android.ugc.aweme.discover.presenter.SearchMusicPresenter");
        LJIIL.LIZ(new STM());
        LJIIL().a_((BbC) this);
        LJIIL().LIZ((SUD) this);
    }

    public static 0Bx LIZ(1hK r2) {
        0Bx LIZ2 = 0By.LIZ(r2, (0Bv) null);
        if (2GD.LIZ) {
            0Bs.LIZ(LIZ2, r2);
        }
        return LIZ2;
    }

    public final void setUserVisibleHint(boolean z) {
        super.setUserVisibleHint(z);
        if (!z) {
            LJIIIZ();
        }
    }

    public final void onViewCreated(View view, Bundle bundle) {
        M12.LIZ(view);
        1hK activity = getActivity();
        if (activity == null) {
            n.LIZIZ();
        }
        this.LIZ = LIZ(activity).LIZ(MusicPlayHelper.class);
        1hK activity2 = getActivity();
        if (activity2 == null) {
            n.LIZIZ();
        }
        SearchStateViewModel LIZ2 = LIZ(activity2).LIZ(SearchStateViewModel.class);
        n.LIZIZ(LIZ2, "");
        SearchObserver searchObserver = new SearchObserver();
        searchObserver.setListener(new SZW(this));
        1Bn<Integer> r0 = LIZ2.searchState;
        r0.observe(this, searchObserver);
        1Bn<Boolean> r1 = LJJIJL().isShowingFilters;
        if (r1 != null) {
            r1.observe(this, new SYU(this));
        }
        super.onViewCreated(view, bundle);
    }
}
