package com.prank.tool.sounds.app;

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

import com.ad.toponlibrary.AdManager;
import com.prank.tool.sounds.app.data.Sounds;
import com.prank.tool.sounds.app.data.detail;

import com.prank.tool.sounds.app.data.Db;
import com.prank.tool.sounds.app.common.MyUtils;
import com.up.uploadlibrary.UpLoadManager;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class MyPrank extends Application {

    public static MyPrank app;
    public static Typeface defaultFont;
    public static List<Sounds> bean;

    @Override
    public void onCreate() {
        super.onCreate();
        app = this;
        AssetManager assets = getAssets();
        defaultFont = Typeface.createFromAsset(assets, "pranks.ttf");
        Db.init(this);
        if (bean != null)
            return;
         String TAG = "=============";
        AdManager.INSTANCE.init(TAG,app,"h686c94daa9048","a4d08f2ee92add56411b087ab9bc47732",
                "fe06c76b794f95216f98e5982ae8f335fc558956",
                "n686c95104d799",
                "n686c950497733",
                "n686c94f520af0",false);
        UpLoadManager.INSTANCE.init(this,TAG);

        try {
            InputStream open = getAssets().open("prank.json");
            String string = MyUtils.getString(open);
            if (!string.isEmpty()) {
                bean = MyUtils.getBean(string);
                for (Sounds category:bean){
                    for (detail detail1 : category.getDetailList()) {
                        detail1.setLike(false);
                        Db.getBoxBean().put(detail1);
                    }
                }
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
