@Beta public final class AndroidInjection extends Object
Modifier and Type | Method and Description |
---|---|
static void |
inject(Activity activity)
Injects
activity if an associated AndroidInjector implementation can be found,
otherwise throws an IllegalArgumentException . |
static void |
inject(BroadcastReceiver broadcastReceiver,
Context context)
Injects
broadcastReceiver if an associated AndroidInjector implementation can
be found, otherwise throws an IllegalArgumentException . |
static void |
inject(ContentProvider contentProvider)
Injects
contentProvider if an associated AndroidInjector implementation can be
found, otherwise throws an IllegalArgumentException . |
static void |
inject(Fragment fragment)
Injects
fragment if an associated AndroidInjector implementation can be found,
otherwise throws an IllegalArgumentException . |
static void |
inject(Service service)
Injects
service if an associated AndroidInjector implementation can be found,
otherwise throws an IllegalArgumentException . |
public static void inject(Activity activity)
activity
if an associated AndroidInjector
implementation can be found,
otherwise throws an IllegalArgumentException
.RuntimeException
- if the Application
doesn't implement HasActivityInjector
.public static void inject(Fragment fragment)
fragment
if an associated AndroidInjector
implementation can be found,
otherwise throws an IllegalArgumentException
.
Uses the following algorithm to find the appropriate AndroidInjector<Fragment>
to
use to inject fragment
:
HasFragmentInjector
, and if none do
fragment
's activity
if it implements
HasFragmentInjector
, and if not
Application
if it implements HasFragmentInjector
.
HasFragmentInjector
, a IllegalArgumentException
is
thrown.IllegalArgumentException
- if no parent fragment, activity, or application implements
HasFragmentInjector
.public static void inject(Service service)
service
if an associated AndroidInjector
implementation can be found,
otherwise throws an IllegalArgumentException
.RuntimeException
- if the Application
doesn't implement HasServiceInjector
.public static void inject(BroadcastReceiver broadcastReceiver, Context context)
broadcastReceiver
if an associated AndroidInjector
implementation can
be found, otherwise throws an IllegalArgumentException
.RuntimeException
- if the Application
from Context.getApplicationContext()
doesn't implement HasBroadcastReceiverInjector
.public static void inject(ContentProvider contentProvider)
contentProvider
if an associated AndroidInjector
implementation can be
found, otherwise throws an IllegalArgumentException
.RuntimeException
- if the Application
doesn't implement HasContentProviderInjector
.Copyright © 2012–2017 The Dagger Authors. All rights reserved.