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

import X.0ND;
import X.2GO;
import X.2UX;
import X.2nK;
import X.2or;
import X.2ov;
import X.3EX;
import X.9EH;
import X.9bw;
import X.B6A;
import X.B6J;
import X.BMC;
import X.BMG;
import X.C3487BMd;
import X.C3822BZa;
import X.C6521Cc1;
import X.QHW;
import X.QJt;
import X.SfZ;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import androidx.recyclerview.widget.RecyclerView;
import com.bytedance.covode.number.Covode;
import com.bytedance.router.SmartRoute;
import com.ss.android.ugc.aweme.base.model.UrlModel;
import com.ss.android.ugc.aweme.challenge.ui.DetailAwemeListFragment;
import com.ss.android.ugc.aweme.feed.model.Aweme;
import com.ss.android.ugc.aweme.music.model.Music;
import com.ss.android.ugc.aweme.music.model.PeopleAlsoLikeInfoStruct;
import java.util.ArrayList;
import java.util.List;

public class MusicDetailAwemeListFragment extends DetailAwemeListFragment implements 2GO {
    public Music LJJIJLIJ;
    public B6A LJJIL;
    public C3487BMd LJJIZ;

    static {
        Covode.recordClassIndex(94118);
    }

    public void onDestroyView() {
        super.onDestroyView();
        this.LJJIL.LIZ(false);
    }

    public void onStop() {
        super.onStop();
        if (SfZ.LJIJ.LJIIIZ() == null) {
            0ND.LIZ();
        }
    }

    public final /* bridge */ /* synthetic */ void LIZ(RecyclerView.ViewHolder viewHolder) {
        LIZ((C3822BZa) viewHolder);
    }

    public final List<Aweme> LIZIZ(List<Aweme> list) {
        ArrayList arrayList = new ArrayList();
        C3487BMd bMd = this.LJJIZ;
        if (bMd != null) {
            arrayList.add(bMd);
        }
        arrayList.addAll(list);
        return arrayList;
    }

    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        this.LJIL = new BMG() {
            static {
                Covode.recordClassIndex(94120);
            }

            public final void LIZIZ() {
                0ND.LIZIZ("music", "list");
            }

            public final void LIZ() {
                0ND.LIZIZ("music", "list");
                2or.LIZ("single_song", (2ov) null, 6);
            }

            public final void LIZ(boolean z) {
                0ND.LIZIZ("music", "list", z ? 1 : 0);
            }

            public final void LIZ(Exception exc) {
                0ND.LIZ("music", "list", 9bw.LIZ(9EH.LJJIFFI.LIZ(), exc));
                2or.LIZ("single_song", 2ov.FAIL, 4);
            }
        };
    }

    public final void LIZ(C3822BZa bZa) {
        super.LIZ(bZa);
        if (bZa != null && bZa.LJIILJJIL != null) {
            Aweme aweme = (Aweme) bZa.LJIILJJIL;
            String str = this.LIZJ;
            String str2 = this.LJ;
            String aid = aweme.getAid();
            String authorUid = aweme.getAuthorUid();
            int adapterPosition = bZa.getAdapterPosition();
            if (adapterPosition >= 0) {
                adapterPosition++;
            }
            2UX r2 = new 2UX();
            r2.LIZ("enter_from", "single_song");
            r2.LIZ("music_id", str);
            r2.LIZ("process_id", str2);
            r2.LIZ("group_id", aid);
            r2.LIZ("author_id", authorUid);
            r2.LIZ("order", adapterPosition);
            2nK.LIZ("show_video", r2.LIZ);
        }
    }

    public final void LIZ(Bundle bundle) {
        super.LIZ(bundle);
        if (bundle != null) {
            this.LJJIJLIJ = bundle.getSerializable("detail_music_data");
            PeopleAlsoLikeInfoStruct peopleAlsoLikeInfoStruct = (PeopleAlsoLikeInfoStruct) bundle.getSerializable("people_also_like_info");
            if (peopleAlsoLikeInfoStruct != null && peopleAlsoLikeInfoStruct.isValid()) {
                C3487BMd bMd = new C3487BMd(peopleAlsoLikeInfoStruct, this.LIZJ);
                this.LJJIZ = bMd;
                List<UrlModel> covers = bMd.getCovers();
                if (covers != null) {
                    for (UrlModel next : covers) {
                        if (next != null) {
                            QJt LIZ = QHW.LIZ(3EX.LIZ(next));
                            LIZ.LIZIZ = getActivity();
                            LIZ.LIZ("MusicDetailAwemeListFra");
                            QHW.LIZIZ(LIZ.LIZIZ());
                        }
                    }
                }
            }
        }
    }

    public final SmartRoute LIZ(Aweme aweme, BMC bmc) {
        SmartRoute LIZ = super.LIZ(aweme, bmc);
        Music music = this.LJJIJLIJ;
        if (music != null) {
            LIZ.withParam("feed_data_music", music);
        }
        LIZ.withParam("feed_data_author_id", aweme.getAuthorUid());
        LIZ.withParam("feed_data_is_ad", aweme.isAd());
        return LIZ;
    }

    public void onViewCreated(View view, Bundle bundle) {
        super.onViewCreated(view, bundle);
        AnonymousClass1 r1 = new B6A(requireActivity()) {
            static {
                Covode.recordClassIndex(94119);
            }

            public final boolean onKeyDown(int i, KeyEvent keyEvent) {
                if (i == 4) {
                    0ND.LIZJ("music", "list");
                }
                return false;
            }
        };
        this.LJJIL = r1;
        r1.LIZ(true);
    }

    public final void LIZ(View view, Aweme aweme, String str) {
        if (!(aweme instanceof C3487BMd)) {
            super.LIZ(view, aweme, str);
        } else if (!C6521Cc1.LIZ(view, 1200)) {
            B6J.LIZ.LIZ(getActivity(), this.LIZJ, "video_list");
        }
    }
}
