|  |  |  | 
|---|
|  |  |  | package com.dayu.recharge; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import android.app.Activity; | 
|---|
|  |  |  | import android.app.Application; | 
|---|
|  |  |  | import android.content.Context; | 
|---|
|  |  |  | import android.content.Intent; | 
|---|
|  |  |  | import android.text.TextUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dayu.baselibrary.BaseApplication; | 
|---|
|  |  |  | import com.dayu.baselibrary.utils.AidlUtil; | 
|---|
|  |  |  | import com.dayu.baselibrary.business.BusinessProvider; | 
|---|
|  |  |  | import com.dayu.baselibrary.business.StartLoginNavigotor; | 
|---|
|  |  |  | import com.dayu.baselibrary.dao.BaseDaoSingleton; | 
|---|
|  |  |  | import com.dayu.baselibrary.dbbean.LibraryBean; | 
|---|
|  |  |  | import com.dayu.baselibrary.utils.BaseCommon; | 
|---|
|  |  |  | import com.dayu.henanlibrary.HeNanApplication; | 
|---|
|  |  |  | import com.dayu.henanlibrary.dao.HNBaseDaoSingleton; | 
|---|
|  |  |  | import com.dayu.henanlibrary.dbBean.AdminDataBean; | 
|---|
|  |  |  | import com.dayu.qihealonelibrary.QHAloneApplication; | 
|---|
|  |  |  | import com.dayu.qiheonlinelibrary.QHOnLineApplication; | 
|---|
|  |  |  | import com.dayu.recharge.activity.LoginActivity; | 
|---|
|  |  |  | import com.tencent.bugly.crashreport.CrashReport; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public class MyApplication extends Application { | 
|---|
|  |  |  | import java.io.File; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public class MyApplication extends Application implements StartLoginNavigotor { | 
|---|
|  |  |  | public static String TAG = "MyApplication"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //当前加载的library模块   //0:河南版本,1齐河单机版 | 
|---|
|  |  |  | public int libraryType = BaseCommon.NoLibrary; | 
|---|
|  |  |  | public static MyApplication myApplication; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void onCreate() { | 
|---|
|  |  |  | super.onCreate(); | 
|---|
|  |  |  | myApplication = this; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | File file = new File(HNBaseDaoSingleton.SqlitePath); | 
|---|
|  |  |  | if (!file.exists()) { | 
|---|
|  |  |  | file.mkdirs(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | initApplication(); | 
|---|
|  |  |  | BaseApplication.getInstance().onCreat(this); | 
|---|
|  |  |  | HeNanApplication.getInstance().application = this; | 
|---|
|  |  |  | CrashReport.initCrashReport(getApplicationContext(), "45551598b8", true); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void initApplication() { | 
|---|
|  |  |  | //兼容老版的,认为有addressCode并且LibraryBean为null的为河南版本的 | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | AdminDataBean adminDataBean = HNBaseDaoSingleton.getInstance(this).adminDao().findFirst(); | 
|---|
|  |  |  | LibraryBean libraryBean = BaseDaoSingleton.getInstance(this).libraryDao().findFirst(); | 
|---|
|  |  |  | if (adminDataBean != null && libraryBean == null && !TextUtils.isEmpty(adminDataBean.addressCode)) { | 
|---|
|  |  |  | libraryType = BaseCommon.HeNanLibrary; | 
|---|
|  |  |  | initHeNan(); | 
|---|
|  |  |  | } else if (libraryBean != null) { | 
|---|
|  |  |  | libraryType = libraryBean.getType(); | 
|---|
|  |  |  | switch (libraryType) { | 
|---|
|  |  |  | case BaseCommon.HeNanLibrary: | 
|---|
|  |  |  | initHeNan(); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case BaseCommon.QHAloneLibrary: | 
|---|
|  |  |  | QHAloneApplication.getInstance().application = this; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case BaseCommon.QHOnLineLibrary: | 
|---|
|  |  |  | QHOnLineApplication.getInstance(this); | 
|---|
|  |  |  | BusinessProvider.getInstance(this); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | CrashReport.postCatchedException(e); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 初始化河南 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private void initHeNan() { | 
|---|
|  |  |  | HeNanApplication.getInstance().application = this; | 
|---|
|  |  |  | HeNanApplication.getInstance().initEasySocket(false, null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void navigateToLogin(Context context) { | 
|---|
|  |  |  | Intent intent = new Intent(context, LoginActivity.class); | 
|---|
|  |  |  | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); | 
|---|
|  |  |  | context.startActivity(intent); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|