WMSApplication.java 1.88 KB
package com.lijinji.part;

import android.app.Application;
import android.content.Context;


import com.lijinji.part.util.CrashHandler;
import com.lijinji.part.util.SoundUtils;
import com.lijinji.part.util.SpeechUtil;

import org.xutils.x;


public class WMSApplication extends Application {

    private static String cookie;
    //  greenDao
//    private  DaoMaster.DevOpenHelper mHelper;
//    private  SQLiteDatabase db;
//    private  DaoMaster mDaoMaster;
//    private  DaoSession mDaoSession;
    private static Context mContext;
    private static WMSApplication instance;

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

    public static WMSApplication getInstance() {
        if(instance == null) {
            instance = new WMSApplication();
        }
        return instance;
    }

    public  void initData() {
        mContext = this;
        SoundUtils.getInstance(this);
        setupDataBase();
        CrashHandler.getInstance().init(this);

        x.Ext.init(this);
        x.Ext.setDebug(BuildConfig.DEBUG); // 是否输出debug日志, 开启debug会影响性能.
        SpeechUtil.getInstance(mContext).initSpeech();
    }

    public static String getOkhttpCookie() {
        return cookie;
    }

    public static void setOkhttpCookie(String result) {
        cookie = result;
    }

    /**
     * 初始化数据库
     */
    private void setupDataBase() {
//        mHelper = new DaoMaster.DevOpenHelper(this, "WMSApplication", null);
//        db = mHelper.getWritableDatabase();
//        mDaoMaster = new DaoMaster(db);
//        mDaoSession = mDaoMaster.newSession();
//        WMSLog.d("setupDataBase");
    }


//    public DaoSession getDaoSession() {
//        return mDaoSession;
//    }
//
//    public SQLiteDatabase getDb() {
//        return db;
//    }

    public static Context getContext() {
        return mContext;
    }


}