Created
March 9, 2019 17:31
-
-
Save lisamariewatkins/e07d2c7b6adf55dea854a1a240afd526 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 static void inject(Activity activity) { | |
checkNotNull(activity, "activity"); | |
Application application = activity.getApplication(); | |
if (!(application instanceof HasActivityInjector)) { | |
throw new RuntimeException( | |
String.format( | |
"%s does not implement %s", | |
application.getClass().getCanonicalName(), | |
HasActivityInjector.class.getCanonicalName())); | |
} | |
AndroidInjector<Activity> activityInjector = | |
((HasActivityInjector) application).activityInjector(); | |
checkNotNull(activityInjector, "%s.activityInjector() returned null", application.getClass()); | |
activityInjector.inject(activity); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment