| | |
| | | import com.dayu.qihealonelibrary.QHAloneApplication; |
| | | import com.tencent.bugly.crashreport.CrashReport; |
| | | |
| | | import java.io.File; |
| | | |
| | | public class MyApplication extends Application { |
| | | public static String TAG = "MyApplication"; |
| | | |
| | |
| | | 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); |
| | | CrashReport.initCrashReport(getApplicationContext(), "45551598b8", true); |
| | |
| | | |
| | | public void initApplication() { |
| | | //兼容老版的,认为有addressCode并且LibraryBean为null的为河南版本的 |
| | | 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; |
| | | HeNanApplication.getInstance().application = this; |
| | | } else if (libraryBean != null) { |
| | | libraryType = libraryBean.getType(); |
| | | switch (libraryType) { |
| | | case BaseCommon.HeNanLibrary: |
| | | HeNanApplication.getInstance().application = this; |
| | | break; |
| | | case BaseCommon.QHAloneLibrary: |
| | | QHAloneApplication.getInstance().application = this; |
| | | break; |
| | | 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; |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | CrashReport.postCatchedException(e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 初始化河南 |
| | | */ |
| | | private void initHeNan() { |
| | | HeNanApplication.getInstance().application = this; |
| | | HeNanApplication.getInstance().initEasySocket(false, null); |
| | | } |
| | | |
| | | |
| | | } |