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

import X.0A9;
import X.0AA;
import X.0AP;
import X.0HH;
import X.1hK;
import X.OSO;
import X.OVM;
import X.OWC;
import X.OWD;
import android.os.Bundle;
import android.os.Message;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.bytedance.common.utility.collection.WeakHandler;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.base.fragment.AmeBaseFragment;
import com.ss.android.ugc.aweme.music.model.Music;
import com.ss.android.ugc.aweme.shortvideo.model.MusicModel;

public abstract class BaseChooseMusicFragment extends AmeBaseFragment implements View.OnClickListener, TextView.OnEditorActionListener, 0A9, WeakHandler.IHandler {
    public NewMusicTabFragment LIZ;
    public boolean LIZIZ;
    public OVM LIZJ;
    public View LIZLLL;
    public TextView LJ;
    public View LJIIIZ;
    public boolean LJIIJ;
    public boolean LJIIJJI;
    public WeakHandler LJIIL = new WeakHandler(this);
    public TextWatcher LJIILIIL = new TextWatcher() {
        static {
            Covode.recordClassIndex(89275);
        }

        public final void afterTextChanged(Editable editable) {
        }

        public final void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }

        public final void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }
    };
    public int LJIILJJIL;
    public String LJIILL;
    public Music LJIIZILJ;
    public String LJIJ;
    public String LJIJI;
    public boolean LJIJJ;
    public MusicModel LJIJJLI;
    public String LJIL;
    public String LJJ;

    static {
        Covode.recordClassIndex(89272);
    }

    public final void LIZ() {
    }

    public void handleMsg(Message message) {
    }

    public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
        return false;
    }

    public void onDestroy() {
        BaseChooseMusicFragment.super.onDestroy();
        this.LJIIL.removeCallbacksAndMessages((Object) null);
    }

    public void onDestroyView() {
        getChildFragmentManager().LIZIZ(this);
        BaseChooseMusicFragment.super.onDestroyView();
    }

    public void onClick(View view) {
        1hK activity;
        if (view.getId() == 2131372289) {
            this.LIZIZ = false;
            this.LIZJ.LIZIZ.setVisibility(0);
        } else if (view.getId() != 2131369676 && view.getId() == 2131362572 && (activity = getActivity()) != null) {
            activity.onBackPressed();
        }
    }

    public void onCreate(Bundle bundle) {
        BaseChooseMusicFragment.super.onCreate(bundle);
        if (getArguments() != null) {
            this.LJIILJJIL = getArguments().getInt("com.ss.android.ugc.aweme.intent.extra.EXTRA_MUSIC_TYPE", 1);
            this.LJIILL = getArguments().getString("challenge");
            this.LJIL = getArguments().getString("creation_id");
            this.LJJ = getArguments().getString("shoot_way");
            this.LJIIZILJ = (Music) getArguments().getSerializable("sticker_music");
            this.LJIJ = getArguments().getString("first_sticker_music_ids", (String) null);
            this.LJIJJ = getArguments().getBoolean("is_busi_sticker", false);
            this.LJIJI = getArguments().getString("first_sticker_id", (String) null);
            this.LJIJJLI = (MusicModel) getArguments().getSerializable("music_model");
            this.LJIIJ = getArguments().getBoolean("music_allow_clear", false);
            this.LJIIJJI = getArguments().getBoolean("music_is_photomv", false);
        }
    }

    public void onViewCreated(View view, Bundle bundle) {
        BaseChooseMusicFragment.super.onViewCreated(view, bundle);
        0AA childFragmentManager = getChildFragmentManager();
        NewMusicTabFragment LIZ2 = childFragmentManager.LIZ(2131363713);
        if (LIZ2 != null) {
            this.LIZ = LIZ2;
        } else {
            int i = this.LJIILJJIL;
            String str = this.LJIILL;
            Music music = this.LJIIZILJ;
            String str2 = this.LJIJ;
            String str3 = this.LJIJI;
            boolean z = this.LJIJJ;
            String str4 = this.LJJ;
            Bundle bundle2 = new Bundle();
            bundle2.putInt("com.ss.android.ugc.aweme.intent.extra.EXTRA_MUSIC_TYPE", i);
            if (!TextUtils.isEmpty(str)) {
                bundle2.putString("challenge", str);
            }
            if (music != null) {
                bundle2.putSerializable("sticker_music", music);
            }
            if (str2 != null) {
                bundle2.putString("first_sticker_music_ids", str2);
            }
            if (str3 != null) {
                bundle2.putString("first_sticker_id", str3);
            }
            bundle2.putBoolean("is_busi_sticker", z);
            NewMusicTabFragment newMusicTabFragment = new NewMusicTabFragment();
            if (!TextUtils.isEmpty(str4)) {
                bundle2.putString("shoot_way", str4);
            }
            newMusicTabFragment.setArguments(bundle2);
            this.LIZ = newMusicTabFragment;
            newMusicTabFragment.LJIILIIL = 0;
            MusicModel musicModel = this.LJIJJLI;
            if (musicModel != null && musicModel.isMvThemeMusic()) {
                this.LIZ.LJIJJ = true;
            }
            this.LIZ.LJIJJLI = this.LJIIJJI;
            0AP LIZ3 = childFragmentManager.LIZ();
            LIZ3.LIZ(2131363713, this.LIZ);
            LIZ3.LIZJ();
        }
        if (this.LJIIJ) {
            this.LIZLLL = view.findViewById(2131363127);
            this.LJ = (TextView) view.findViewById(2131363858);
            this.LJIIIZ = view.findViewById(2131363128);
        }
        getChildFragmentManager().LIZ(this);
        OVM ovm = this.LIZJ;
        ovm.LIZJ.setOnClickListener(ovm.LIZ);
        ovm.LIZ.LIZ.LIZ = new OWC(ovm);
        ovm.LIZ.LIZ.LIZ = new OWD(ovm);
    }

    public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        View LIZ2 = 0HH.LIZ(layoutInflater, 2131560277, viewGroup, false);
        OSO.LIZLLL = this.LJJ;
        OSO.LIZJ = this.LJIL;
        this.LIZJ = new OVM(LIZ2, this, this.LJIILJJIL, this.LJIILIIL);
        return LIZ2;
    }
}
