package com.zwh.mvparms.eyepetizer.app; import android.app.Application; import android.content.Context; import android.support.multidex.MultiDex; import com.jess.arms.base.App; import com.jess.arms.base.delegate.AppDelegate; import com.jess.arms.base.delegate.AppLifecycles; import com.jess.arms.di.component.AppComponent; import com.tencent.tinker.loader.app.ApplicationLike; /** * Created by Administrator on 2017\12\6 0006. */ public class BaseApplication extends Application implements App { private static BaseApplication mApp; private AppLifecycles mAppDelegate; private ApplicationLike tinkerApplicationLike; public BaseApplication() { } @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(base); this.mAppDelegate = new AppDelegate(base); this.mAppDelegate.attachBaseContext(base); } @Override public void onCreate() { super.onCreate(); // initTinkerPatch(); mApp = this; this.mAppDelegate.onCreate(this); } // private void initTinkerPatch() { // // 我们可以从这里获得Tinker加载过程的信息 // if (BuildConfig.TINKER_ENABLE) { // tinkerApplicationLike = TinkerPatchApplicationLike.getTinkerPatchApplicationLike(); // // 初始化TinkerPatch SDK // TinkerPatch.init(tinkerApplicationLike) // .reflectPatchLibrary() // .setPatchRollbackOnScreenOff(true) // .setPatchRestartOnSrceenOff(true) // .setFetchPatchIntervalByHours(3) // ; // // // fetchPatchUpdateAndPollWithInterval 与 fetchPatchUpdate(false) // // 不同的是,会通过handler的方式去轮询 // TinkerPatch.with().fetchPatchUpdateAndPollWithInterval(); // } // } /** * 在模拟环境中程序终止时会被调用 */ @Override public void onTerminate() { super.onTerminate(); if (mAppDelegate != null) this.mAppDelegate.onTerminate(this); } public static BaseApplication getAppContext() { return mApp; } /** * 将AppComponent返回出去,供其它地方使用, AppComponent接口中声明的方法返回的实例,在getAppComponent()拿到对象后都可以直接使用 * * @return */ @Override public AppComponent getAppComponent() { return ((App) mAppDelegate).getAppComponent(); } }