Package dagger.android
Class DispatchingAndroidInjector<T>
- java.lang.Object
-
- dagger.android.DispatchingAndroidInjector<T>
-
- Type Parameters:
T- the core Android type to be injected
- All Implemented Interfaces:
AndroidInjector<T>
@Beta public final class DispatchingAndroidInjector<T> extends java.lang.Object implements AndroidInjector<T>
Performs members-injection on instances of core Android types (e.g.Activity,Fragment) that are constructed by the Android framework and not by Dagger. This class relies on an injected mapping from each concrete class to anAndroidInjector.Factoryfor anAndroidInjectorof that class. Each concrete class must have its own entry in the map, even if it extends another class which is already present in the map. CallsObject.getClass()on the instance in order to find the appropriateAndroidInjector.Factory.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDispatchingAndroidInjector.InvalidInjectorBindingExceptionException thrown if an incorrect binding is made for aAndroidInjector.Factory.-
Nested classes/interfaces inherited from interface dagger.android.AndroidInjector
AndroidInjector.Builder<T>, AndroidInjector.Factory<T>
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidinject(T instance)Performs members-injection oninstance.booleanmaybeInject(T instance)Attempts to perform members-injection oninstance, returningtrueif successful,falseotherwise.
-
-
-
Method Detail
-
maybeInject
@CanIgnoreReturnValue public boolean maybeInject(T instance)
Attempts to perform members-injection oninstance, returningtrueif successful,falseotherwise.- Throws:
DispatchingAndroidInjector.InvalidInjectorBindingException- if the injector factory bound for a class does not inject instances of that class
-
inject
public void inject(T instance)
Performs members-injection oninstance.- Specified by:
injectin interfaceAndroidInjector<T>- Throws:
DispatchingAndroidInjector.InvalidInjectorBindingException- if the injector factory bound for a class does not inject instances of that classjava.lang.IllegalArgumentException- if noAndroidInjector.Factoryis bound forinstance
-
-