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

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

The newest version!
package com.nikedlab.android.inject.extenders;

import android.app.Application;
import android.content.Context;
import com.nikedlab.android.inject.interfaces.ApplicationContext;
import com.nikedlab.android.inject.ApplicationSingleton;

/**
 * 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