All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nikedlab.android.inject.InjectedApplication Maven / Gradle / Ivy

There is a newer version: 3.0.13
Show newest version
package com.nikedlab.android.inject;

import android.app.Application;
import android.content.Context;

/**
 * Application class.
 *
 * @author Koert Zeilstra
 */
public abstract class InjectedApplication extends Application {

    public static Application application;

    @Override
    public void onCreate() {
        super.onCreate();
        application = this;
        ApplicationContext applicationContext = ApplicationSingleton.getInstance().getApplicationContext();
        applicationContext.bindInstance(Context.class, this);
        initializeContext(applicationContext);
    }

    public void injectInto(Object target) {
        ApplicationSingleton.getInstance().getInjector().inject(target);
    }

    /**
     * Initialize application context, create your bindings in your subclass
     * and override this method. Always call super.
     *
     * @param applicationContext Application context.
     */
    protected void initializeContext(final ApplicationContext applicationContext) {

    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy