package com.neptune.base;

import android.app.Application;
import android.content.Context;
import android.util.Log;

import com.pax.dal.IDAL;
import com.pax.gl.page.PaxGLPage;
import com.pax.neptunelite.api.NeptuneLiteUser;

public class NeptuneAppMgmt extends Application {

    private static IDAL dal;
    private static Context appContext;
    private static PaxGLPage iPaxGLPage;

    @Override
    public void onCreate() {
        super.onCreate();
        appContext = getApplicationContext();
        dal = getDal();
    }
    
    public static IDAL getDal(){
        if(dal == null){
            try {
                long start = System.currentTimeMillis();
                dal = NeptuneLiteUser.getInstance().getDal(appContext);
                Log.i("Test","get dal cost:"+(System.currentTimeMillis() - start)+" ms");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return dal;
    }

    public static PaxGLPage getIPaxGLPage() {
        if(iPaxGLPage == null){
            iPaxGLPage = PaxGLPage.getInstance(appContext);
        }
        return iPaxGLPage;
    }

    public static Context getAppContext() {
        return appContext;
    }
}
