package com.trace.drawing.people.tools;

import android.app.Application;
import android.content.Intent;
import android.content.res.AssetManager;
import android.graphics.Typeface;

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;
import com.trace.drawing.people.bean.MyDataBase;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class App extends Application {
    public static String Key_ViewDir = "pre_dir";
    public static String Key_ISMAIN = "ismain";
    public static String Key_Camera = "camera_data";

    public static String TAG = "=============";


    public static App app;
    public static boolean initSDkOK = false;
    public static String initAction = "ACTION_INIT";
    private String SDK_KEY = "JMeJ_zoCmLQanoRonVSe2Enge8a9nbn42zicsx1WI6o_8HiX6M5KleETOJBowqzbycmbn_iART4rFyC8m6uOi9";
    public static final String[] CLASS_NAMES = {
            "local_Aesthetic",
            "local_One Line Art",
            "local_People",
            "local_Animals",
            "local_Birds",
            "local_Tropical Paradise",
            "local_World Monuments",
            "local_Butterfly",
            "local_Food",
            "local_Cartoons",
            "local_Christmas",
            "local_Festivals",
            "local_Flowers",
            "local_Fruits",
            "local_General",
            "local_Mehndi",
            "local_Nature",
            "local_Architectures",
            "local_Rangoli",
            "local_Sports",
            "local_Car",
            "local_Space"
    };

    public static Typeface defaultFont;
    private static List<String> classNameList;

    @Override
    public void onCreate() {
        super.onCreate();
        app = this;
        AssetManager assets = getAssets();
        defaultFont = Typeface.createFromAsset(assets, "myfont.ttf");
        classNameList = Arrays.asList(CLASS_NAMES);
        initMAxSDk();
        MyDataBase.init(this);

    }

    private void initMAxSDk() {
        AppLovinSdkInitializationConfiguration build = AppLovinSdkInitializationConfiguration.builder(SDK_KEY, this)
                .setMediationProvider(AppLovinMediationProvider.MAX)
                .build();
        AppLovinSdk.getInstance(this).initialize(build, new AppLovinSdk.SdkInitializationListener() {
            @Override
            public void onSdkInitialized(AppLovinSdkConfiguration appLovinSdkConfiguration) {
                initSDkOK = true;
                LocalBroadcastManager.getInstance(App.this).sendBroadcast(new Intent(initAction));
            }
        });
    }

    public static List<String> getAllDir() {
        Collections.shuffle(classNameList);
        return classNameList;


    }
}
