Back to project page mvp-notes.
The source code is released under:
Apache License
If you think the Android project mvp-notes listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.corneliudascalu.mvpnotes.common; // ww w. ja v a2 s.c o m import android.app.Application; import dagger.ObjectGraph; /** * Holds the app object graph in a static variable, which will only be destroyed if the app is destroyed * * @author Corneliu Dascalu <corneliu.dascalu@gmail.com> */ public class ObjectGraphHolder { private static ObjectGraph objectGraph; private static ObjectGraphCreator objectGraphCreator; public static ObjectGraph getObjectGraph(Application application) { if (objectGraph == null) { objectGraph = objectGraphCreator.create(application); } return objectGraph; } public static void setObjectGraphCreator(ObjectGraphCreator objectGraphCreator) { if (ObjectGraphHolder.objectGraphCreator == null) { ObjectGraphHolder.objectGraphCreator = objectGraphCreator; } } public static void forceObjectGraphCreator(ObjectGraphCreator objectGraphCreator) { objectGraph = null; ObjectGraphHolder.objectGraphCreator = objectGraphCreator; } public static void inject(Application application, Object object) { getObjectGraph(application).inject(object); } public static ObjectGraph createScopedObjectGraph(Application application, Object... modules) { return ObjectGraphHolder.getObjectGraph(application).plus(modules); } }