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

import X.1hK;
import X.3YB;
import X.7W7;
import X.7df;
import X.9EH;
import X.B2W;
import X.BL8;
import X.Lnj;
import X.M12;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.ss.android.ugc.aweme.detail.base.DetailPanelBehavior;
import com.ss.android.ugc.aweme.homepage.msadapt.MSAdaptionService;
import com.ss.android.ugc.aweme.music.ui.MusicDetailFragment;
import kotlin.h.b.n;

public final class MusicDetailService implements IMusicDetailService {
    static {
        Covode.recordClassIndex(94085);
    }

    public static IMusicDetailService LIZ() {
        MethodCollector.i(14385);
        IMusicDetailService iMusicDetailService = (IMusicDetailService) Lnj.LIZ(IMusicDetailService.class, false);
        if (iMusicDetailService != null) {
            MethodCollector.o(14385);
            return iMusicDetailService;
        }
        Object LIZIZ = Lnj.LIZIZ(IMusicDetailService.class, false);
        if (LIZIZ != null) {
            IMusicDetailService iMusicDetailService2 = (IMusicDetailService) LIZIZ;
            MethodCollector.o(14385);
            return iMusicDetailService2;
        }
        if (Lnj.z == null) {
            synchronized (IMusicDetailService.class) {
                try {
                    if (Lnj.z == null) {
                        Lnj.z = new MusicDetailService();
                    }
                } catch (Throwable th) {
                    MethodCollector.o(14385);
                    throw th;
                }
            }
        }
        MusicDetailService musicDetailService = (MusicDetailService) Lnj.z;
        MethodCollector.o(14385);
        return musicDetailService;
    }

    public static Bundle LIZIZ(Intent intent) {
        try {
            return intent.getExtras();
        } catch (Exception unused) {
            return null;
        }
    }

    public final Fragment LIZ(Intent intent) {
        M12.LIZ(intent);
        if (MSAdaptionService.LIZJ().LIZ(9EH.LJJIFFI.LIZ())) {
            return MusicDetailFragment.LIZIZ(LIZIZ(intent));
        }
        return null;
    }

    public final void LIZ(Context context, Bundle bundle) {
        int i;
        M12.LIZ(context, bundle);
        if (context instanceof 1hK) {
            if (BL8.LIZIZ) {
                i = 4;
            } else {
                i = 3;
            }
            bundle.putBoolean("IS_PANEL", true);
            MusicDetailFragment LIZIZ = MusicDetailFragment.LIZIZ(bundle);
            7W7 LJJJI = 7df.LJJJI();
            n.LIZIZ(LJJJI, "");
            boolean LJIILJJIL = LJJJI.LJIILJJIL();
            7df.LJJJI().LJJIII();
            3YB r1 = new 3YB();
            n.LIZIZ(LIZIZ, "");
            r1.LIZ(LIZIZ);
            r1.LIZ(i);
            r1.LIZIZ(false);
            r1.LIZ(new DetailPanelBehavior());
            r1.LIZ(new B2W(LIZIZ, LJIILJJIL, context));
            r1.LIZ.show(((1hK) context).getSupportFragmentManager(), "MusicDetailPanel");
        }
    }
}
