com.nikedlab.android.inject.ApplicationSingleton Maven / Gradle / Ivy
The newest version!
package com.nikedlab.android.inject;
import com.nikedlab.android.inject.interfaces.ApplicationContext;
import com.nikedlab.android.inject.processors.DirectApplicationContext;
import com.nikedlab.android.inject.processors.Injector;
public class ApplicationSingleton {
private static final ApplicationSingleton INSTANCE = new ApplicationSingleton();
private ApplicationContext applicationContext;
private Injector injector;
private ApplicationSingleton() {
}
public synchronized ApplicationContext getApplicationContext() {
if (applicationContext == null) {
applicationContext = new DirectApplicationContext();
}
return applicationContext;
}
public synchronized Injector getInjector() {
if (injector == null) {
ApplicationContext applicationContext = getApplicationContext();
injector = new Injector(applicationContext);
}
return injector;
}
public static ApplicationSingleton getInstance() {
return INSTANCE;
}
}