package com.ss.android.ugc.aweme.kids.choosemusic.fragment;

import X.0Gf;
import X.0Gp;
import X.0HH;
import X.4PU;
import X.C5418OUr;
import X.C5421OUu;
import X.C5425OUy;
import X.Cmx;
import X.OSO;
import X.OV7;
import X.OV8;
import X.OVA;
import X.OVI;
import X.OVR;
import X.OXN;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.arch.widgets.base.DataCenter;
import com.ss.android.ugc.aweme.base.fragment.AmeBaseFragment;
import com.ss.android.ugc.aweme.kids.choosemusic.activity.MusicDetailListActivity;
import com.ss.android.ugc.aweme.kids.choosemusic.api.ChooseMusicApi;

public class MusicSheetFragment extends AmeBaseFragment implements OV7<OXN>, 4PU, OVR<OXN> {
    public DataCenter LIZ;
    public OVA<OXN> LIZIZ;
    public int LIZJ;
    public C5418OUr LIZLLL;
    public C5421OUu LJ;
    public final int LJIIIZ = 20;

    static {
        Covode.recordClassIndex(89295);
    }

    public final String LIZIZ() {
        return "music_sheet_list";
    }

    public final String LIZJ() {
        return "refresh_status_music_sheet";
    }

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

    public final void LJIILJJIL() {
        C5418OUr oUr = this.LIZLLL;
        if (oUr != null) {
            oUr.LIZ();
        }
    }

    public final DataCenter LJ() {
        DataCenter LIZ2 = DataCenter.LIZ(Cmx.LIZIZ(this), this);
        this.LIZ = LIZ2;
        return LIZ2;
    }

    public final void LJIILL() {
        if (getActivity() != null) {
            getActivity().onBackPressed();
        }
    }

    public final void LIZ() {
        C5418OUr oUr = new C5418OUr(getContext(), this.LIZ);
        this.LIZLLL = oUr;
        oUr.LIZ();
    }

    public final void bc_() {
        DataCenter dataCenter;
        int intValue;
        OVA<OXN> ova = this.LIZIZ;
        if (ova != null) {
            ova.LIZ();
        }
        if (this.LIZLLL != null && (dataCenter = this.LIZ) != null) {
            Object LIZ2 = ((OV8) dataCenter.LIZ("music_sheet_list")).LIZ("list_cursor");
            if (LIZ2 instanceof Long) {
                intValue = ((Long) LIZ2).intValue();
            } else if (LIZ2 instanceof Integer) {
                intValue = ((Integer) LIZ2).intValue();
            } else {
                return;
            }
            if (intValue > 0) {
                ChooseMusicApi.LIZIZ(intValue).LIZ(new C5425OUy(this.LIZLLL), 0Gp.LIZIZ, (0Gf) null);
            }
        }
    }

    public final OVA<OXN> LIZ(View view) {
        View view2 = view;
        OVI ovi = new OVI(getContext(), view2, this, this, this.LIZJ);
        ovi.LIZ.setTitle(2131827398);
        this.LIZIZ = ovi;
        return ovi;
    }

    public void onCreate(Bundle bundle) {
        MusicSheetFragment.super.onCreate(bundle);
        int i = 1;
        if (getArguments() != null) {
            i = getArguments().getInt("com.ss.android.ugc.aweme.intent.extra.EXTRA_MUSIC_TYPE", 1);
        }
        this.LIZJ = i;
    }

    public final /* synthetic */ void LIZIZ(Object obj) {
        OXN oxn = (OXN) obj;
        if (oxn != null && !TextUtils.isEmpty(oxn.LIZ)) {
            Intent intent = new Intent(getContext(), MusicDetailListActivity.class);
            intent.putExtra("music_type", 2);
            intent.putExtra("music_class_id", oxn.LIZ);
            intent.putExtra("music_class_name", oxn.LIZIZ);
            intent.putExtra("music_category_is_hot", oxn.LJ);
            intent.putExtra("com.ss.android.ugc.aweme.intent.extra.EXTRA_MUSIC_TYPE", this.LIZJ);
            intent.putExtra("music_class_enter_method", "click_category_list");
            intent.putExtra("music_class_level", oxn.LJFF);
            startActivityForResult(intent, 10001);
            OSO.LIZ(oxn.LIZIZ, "click_category_list", "", "change_music_page_detail", oxn.LIZ);
        }
    }

    public void onViewCreated(View view, Bundle bundle) {
        MusicSheetFragment.super.onViewCreated(view, bundle);
        if (this.LJ == null) {
            this.LJ = new C5421OUu(this);
        }
        this.LJ.LIZ(view);
    }

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

    public void onActivityResult(int i, int i2, Intent intent) {
        MusicSheetFragment.super.onActivityResult(i, i2, intent);
        if (i == 10001 && i2 == -1) {
            getActivity().setResult(-1, intent);
            getActivity().finish();
        }
    }
}
