Search in sources :

Example 1 with AppContextModule

use of org.wordpress.android.fluxc.module.AppContextModule in project WordPress-Android by wordpress-mobile.

the class WordPress method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    mContext = this;
    long startDate = SystemClock.elapsedRealtime();
    // Init WellSql
    WellSql.init(new WellSqlConfig(getApplicationContext()));
    // Init Dagger
    mAppComponent = DaggerAppComponent.builder().appContextModule(new AppContextModule(getApplicationContext())).build();
    component().inject(this);
    mDispatcher.register(this);
    // Init static fields from dagger injected singletons, for legacy Actions/Utils
    sRequestQueue = mRequestQueue;
    sImageLoader = mImageLoader;
    sOAuthAuthenticator = mOAuthAuthenticator;
    ProfilingUtils.start("App Startup");
    // Enable log recording
    AppLog.enableRecording(true);
    AppLog.i(T.UTILS, "WordPress.onCreate");
    if (!PackageUtils.isDebugBuild()) {
        Fabric.with(this, new Crashlytics());
    }
    // If the migration was not done and if we have something to migrate
    runFluxCMigration();
    versionName = PackageUtils.getVersionName(this);
    initWpDb();
    enableHttpResponseCache(mContext);
    // EventBus setup
    EventBus.TAG = "WordPress-EVENT";
    EventBus.builder().logNoSubscriberMessages(false).sendNoSubscriberEvent(false).throwSubscriberException(true).installDefaultEventBus();
    RestClientUtils.setUserAgent(getUserAgent());
    // PasscodeLock setup
    if (!AppLockManager.getInstance().isAppLockFeatureEnabled()) {
        // Make sure that PasscodeLock isn't already in place.
        // Notifications services can enable it before the app is started.
        AppLockManager.getInstance().enableDefaultAppLockIfAvailable(this);
    }
    if (AppLockManager.getInstance().isAppLockFeatureEnabled()) {
        AppLockManager.getInstance().getAppLock().setExemptActivities(new String[] { "org.wordpress.android.ui.ShareIntentReceiverActivity" });
    }
    HelpshiftHelper.init(this);
    ApplicationLifecycleMonitor applicationLifecycleMonitor = new ApplicationLifecycleMonitor();
    registerComponentCallbacks(applicationLifecycleMonitor);
    registerActivityLifecycleCallbacks(applicationLifecycleMonitor);
    initAnalytics(SystemClock.elapsedRealtime() - startDate);
    // If users uses a custom locale set it on start of application
    WPActivityUtils.applyLocale(getContext());
    // Allows vector drawable from resources (in selectors for instance) on Android < 21 (can cause issues
    // with memory usage and the use of Configuration). More informations:
    // https://developer.android.com/reference/android/support/v7/app/AppCompatDelegate.html#setCompatVectorFromResourcesEnabled(boolean)
    // Note: if removed, this will cause crashes on Android < 21
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
Also used : AppContextModule(org.wordpress.android.fluxc.module.AppContextModule) WellSqlConfig(org.wordpress.android.fluxc.persistence.WellSqlConfig) Crashlytics(com.crashlytics.android.Crashlytics)

Aggregations

Crashlytics (com.crashlytics.android.Crashlytics)1 AppContextModule (org.wordpress.android.fluxc.module.AppContextModule)1 WellSqlConfig (org.wordpress.android.fluxc.persistence.WellSqlConfig)1