package com.offline.music.player;

import android.app.Application;
import android.content.Context;
import android.content.Intent;

import androidx.localbroadcastmanager.content.LocalBroadcastManager;

import com.applovin.sdk.AppLovinMediationProvider;
import com.applovin.sdk.AppLovinSdk;
import com.applovin.sdk.AppLovinSdkConfiguration;
import com.applovin.sdk.AppLovinSdkInitializationConfiguration;

public class MusicApplication extends Application {

    public static Context myApplication;

    public static String visitorData;


    private String MAx_SDK_key = "tAh5Z8CtFiG05NfRWh9UuOHCp3h3SaFvlh6Phw5ucaxFMCRs2d97F7lywfBKOEKSipdaGq8vZOaDLZkrL1fDDc";

    public static boolean initSDkOK = false;
    public static String initAction = "MUSIC_ACTION_INIT";

    public static void setVisitorData(String visitorData) {
        MusicApplication.visitorData = visitorData;
    }

    public static String getVisitorData() {
        return visitorData;
    }


    @Override
    public void onCreate() {
        super.onCreate();
        myApplication = this;
        InitializeMax();
//        Sp.init(this);
//        RemoteConfigJava.getInstance().init(this);
//        ObjectBoxManager.init(this);
//        MyMediaControllerManager.getInstance().init(new MediaControllerStatusListener() {
//            @Override
//            public void onMediaControllerComplete(boolean isOk) {
//                CommonUtils.LogMsg("=-----mediaController+" + isOk);
//            }
//        });
    }

    private void InitializeMax() {
        AppLovinSdkInitializationConfiguration initConfig = AppLovinSdkInitializationConfiguration.builder(MAx_SDK_key, this)
                .setMediationProvider(AppLovinMediationProvider.MAX)
                .build();

        // Initialize the SDK with the configuration
        AppLovinSdk.getInstance(this).initialize(initConfig, new AppLovinSdk.SdkInitializationListener() {
            @Override
            public void onSdkInitialized(final AppLovinSdkConfiguration sdkConfig) {
                initSDkOK = true;
                LocalBroadcastManager.getInstance(MusicApplication.this).sendBroadcast(new Intent(initAction));
            }
        });
    }

}
