package com.example.applock.application;

import static android.content.ContentValues.TAG;

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

import androidx.localbroadcastmanager.content.LocalBroadcastManager;

import com.anythink.core.api.ATSDK;
import com.anythink.core.api.NetTrafficeCallback;
import com.anythink.interstitial.api.ATInterstitial;
import com.example.applock.allmanager.Datamanager;
import com.example.applock.roombase.AppEntity;
import com.example.applock.roombase.SoftWareLockRoom;
import com.example.applock.value.MyAllValues;
import com.example.applock.allmanager.AppManager;
import com.example.applock.value.Mytool;

import org.w3c.dom.Entity;

import java.util.List;
import java.util.Set;

public class SoftWareLockApplication extends Application {
    public static boolean isPass = false;
    private static final String TOP_ID = "h66a2480dd8ead";
    private static final String TOP_KEY = "aa0d3c0bc4f1109593d30d5c1f3a32120";
    private static final String TOP_DEBUG = "d2f08ee302fdd0741819983376817c0bf71bfe67";
    public static List<ATInterstitial> ads;
    public static SoftWareLockApplication app;
    private static Context context;
    public static int userOption =0;
    public static final String TAG = "===============";

    @Override
    public void onCreate() {
        super.onCreate();

        app = this;
        context = getApplicationContext();

        ATSDK.checkIsEuTraffic(this, new NetTrafficeCallback() {

            @Override
            public void onResultCallback(boolean isEU) {
                Log.e(TAG, "onResultCallback:" + isEU);
                if (isEU && ATSDK.getGDPRDataLevel(context) == ATSDK.UNKNOWN) {
                    ATSDK.showGdprAuth(context);
                }

            }

            @Override
            public void onErrorCallback(String errorMsg) {
                Log.e(TAG, "onErrorCallback:" + errorMsg);
            }
        });

        initSdk();


        MyAllValues.softWareLockApplication = this;
        isPass = true;
        Datamanager.init(this);
        Datamanager.resetKeyCount();
        Set<AppEntity> entityApps = AppManager.QueryPhoneApp(this);
        SoftWareLockRoom.insertRoom(entityApps);
    }

    private void initSdk() {

//        ATSDK.integrationChecking(context);

        ATSDK.init(context, TOP_ID, TOP_KEY);

        ads = Mytool.getAllAd();
//        ATSDK.setNetworkLogDebug(true);
//        ATDebuggerUITest.showDebuggerUI(context,TOP_DEBUG);
    }

    public static List<ATInterstitial> lodAd() {

        return ads;
    }

}
