MCPcopy Index your code
hub / github.com/google/dagger / AndroidInjector

Interface AndroidInjector

java/dagger/android/AndroidInjector.java:35–84  ·  view source on GitHub ↗

Performs members-injection for a concrete subtype of a core Android type (e.g., android.app.Activity or android.app.Fragment). Commonly implemented by dagger.Subcomponent-annotated types whose {@link dagger.Sub

Source from the content-addressed store, hash-verified

33 * @see DispatchingAndroidInjector
34 */
35@Beta
36@DoNotMock(
37 "Faked versions of AndroidInjector are much clearer than a mock. See https://google.github.io/dagger/testing")
38public interface AndroidInjector<T> {
39
40 /** Injects the members of {@code instance}. */
41 void inject(T instance);
42
43 /**
44 * Creates {@link AndroidInjector}s for a concrete subtype of a core Android type.
45 *
46 * @param <T> the concrete type to be injected
47 */
48 @DoNotMock
49 interface Factory<T> {
50 /**
51 * Creates an {@link AndroidInjector} for {@code instance}. This should be the same instance
52 * that will be passed to {@link #inject(Object)}.
53 */
54 AndroidInjector<T> create(T instance);
55 }
56
57 /**
58 * An adapter that lets the common {@link dagger.Subcomponent.Builder} pattern implement {@link
59 * Factory}.
60 *
61 * @param <T> the concrete type to be injected
62 */
63 @DoNotMock
64 abstract class Builder<T> implements AndroidInjector.Factory<T> {
65 @Override
66 public final AndroidInjector<T> create(T instance) {
67 seedInstance(instance);
68 return build();
69 }
70
71 /**
72 * Provides {@code instance} to be used in the binding graph of the built {@link
73 * AndroidInjector}. By default, this is used as a {@link BindsInstance} method, but it may be
74 * overridden to provide any modules which need a reference to the activity.
75 *
76 * <p>This should be the same instance that will be passed to {@link #inject(Object)}.
77 */
78 @BindsInstance
79 public abstract void seedInstance(T instance);
80
81 /** Returns a newly-constructed {@link AndroidInjector}. */
82 public abstract AndroidInjector<T> build();
83 }
84}

Callers 4

injectMethod · 0.65
maybeInjectMethod · 0.65
injectIfNecessaryMethod · 0.65
injectMethod · 0.65

Implementers 6

FooInjectorjavatests/dagger/android/DispatchingAn
NullFoojavatests/dagger/functional/nullables/
JavaxInjectjava/dagger/grpc/server/processor/Sour
AndroidInjectionjava/dagger/android/AndroidInjection.j
DispatchingAndroidInjectorjava/dagger/android/DispatchingAndroid
AndroidSupportInjectionjava/dagger/android/support/AndroidSup

Calls

no outgoing calls

Tested by

no test coverage detected