Created
June 6, 2014 18:56
-
-
Save shekibobo/7f23a9191df1de91c442 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyApp extends Application { | |
private static Context context; | |
private static ObjectGraph objectGraph; | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
context = this; | |
buildObjectGraphAndInject(); | |
} | |
public void buildObjectGraphAndInject() { | |
objectGraph = ObjectGraph.create(Modules.list(this)); | |
objectGraph.inject(this); | |
} | |
public static void injectStatic(Object o) { | |
objectGraph.inject(o); | |
} | |
public void inject(Object o) { | |
objectGraph.inject(o); | |
} | |
public static MyApp get() { | |
return (MyApp) context.getApplicationContext(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment