package com.tool.applockpro;

import static android.content.ContentValues.TAG;

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

import com.anythink.core.api.ATSDK;
import com.anythink.core.api.NetTrafficeCallback;
import com.anythink.interstitial.api.ATInterstitial;
import com.tool.applockpro.data.MyDataBase;
import com.tool.applockpro.data.Mydata;
import com.tool.applockpro.tool.Mytools;

import java.util.ArrayList;
import java.util.List;

public class ApplockSkin extends Application {
    public static final String DB_Name = "lock_database";
    public static final String Table_Name = "lock_table";
    public static final int DB_Version = 1;
    private static Context context;
    private static final String PREFS_NAME = "MyPrefs";
    private static final String KEY_PWD = "key_pwd";
    public static SharedPreferences sp;
    public static SharedPreferences.Editor et;
    public static final int checkpwd_0 = 0;
    public static List<Mydata> system = new ArrayList<>();
    public static List<Mydata> third = new ArrayList<>();
    public static List<Mydata> lock = new ArrayList<>();
    public static int keyad = 0;

    public static List<Mydata> getSystem() {
        return system;
    }

    public static List<Mydata> getThird() {
        return third;
    }

    public static List<Mydata> getLock() {
        return lock;
    }
    private static final String TOP_ID = "h66a7349cb62fb";
    private static final String TOP_KEY = "a32d537b2e12a9fcabe2f2fe77628864c";
    private static final String TOP_DEBUG = "5c12401a5c59afe9a3ac946dd22ae5f1fecd8c1c";
    public static List<ATInterstitial> ads;

    public static   String TAG = "LOCK_APP----------";
    @Override
    public void onCreate() {
        super.onCreate();
        context = getApplicationContext();
        Mytools.getapplist(this);


        sp = getSharedPreferences(PREFS_NAME, MODE_PRIVATE);
        et = sp.edit();


        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();


    }


    private void initSdk() {

//        ATSDK.integrationChecking(context);

        ATSDK.init(context, TOP_ID, TOP_KEY);

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

    }

    public static List<ATInterstitial> lodAd() {

        return ads;
    }

    public static void savePWD(String pwd) {
        et.putString(KEY_PWD, pwd);
        et.apply();
    }

    public static String getPWD() {
        return sp.getString(KEY_PWD, "");
    }

    public static Context getContext() {
        return context;
    }
}
