1 min readSep 12, 2016
In this case you will have to extend BrainFuckingApp from Application class and write:
private static InstanceStorage instanceStorage;
private static LazyInstanceStorage lazyInstanceStorage;@Override
public void onCreate() {
super.onCreate();
Context appContext = getApplicationContext();
List<Object> singleInstances = //list of singletons
storage = new InstanceStorage(singleInstances);
List<? extends LazyInstance> lazyInstances = //list of initializers
lazyInstanceStorage = new LazyInstanceStorage(lazyInstances);
}public static <T> T getGlobal(Class<T> clazz) {
return instanceStorage.get(clazz);
}public static <T> T getLazyGlobal(Class<T> clazz) {
return lazyInstanceStorage.get(clazz);
}