package com.ads.cal.picturetranslate;

import android.app.Application;

import com.ads.cal.picturetranslate.db.DataBaseManager;
import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.initialization.InitializationStatus;
import com.google.android.gms.ads.initialization.OnInitializationCompleteListener;

public class PictureApplication extends Application {

    private static DataBaseManager dataBaseManager;
    private static Application application;

    @Override
    public void onCreate() {
        super.onCreate();
        application = this;
        new Thread(() -> {
            PictureTranslateUtils.init();
        });
        initDB();
        MobileAds.initialize(this, new OnInitializationCompleteListener() {
            @Override
            public void onInitializationComplete(InitializationStatus initializationStatus) {
            }
        });
    }

    public static Application getApplication() {
        return application;
    }

    private void initDB() {
        dataBaseManager = new DataBaseManager(this);
        dataBaseManager.open();
    }

    public static DataBaseManager getDataBaseManager() {
        return dataBaseManager;
    }
}
