roboguice
Class RoboGuice

java.lang.Object
  extended by roboguice.RoboGuice

public class RoboGuice
extends Object

Manages injectors for RoboGuice applications. There are two types of injectors: 1. The base application injector, which is not typically used directly by the user. 2. The ContextScopedInjector, which is obtained by calling getInjector(android.content.Context), and knows about your current context, whether it's an activity, service, or something else. BUG hashmap should also key off of stage and modules list


Nested Class Summary
static class RoboGuice.util
           
 
Field Summary
static com.google.inject.Stage DEFAULT_STAGE
           
protected static WeakHashMap<android.app.Application,com.google.inject.Injector> injectors
           
protected static int modulesResourceId
           
protected static WeakHashMap<android.app.Application,ResourceListener> resourceListeners
           
protected static WeakHashMap<android.app.Application,ViewListener> viewListeners
           
 
Method Summary
static void destroyInjector(android.content.Context context)
           
static com.google.inject.Injector getBaseApplicationInjector(android.app.Application application)
          Return the cached Injector instance for this application, or create a new one if necessary.
static RoboInjector getInjector(android.content.Context context)
           
protected static ResourceListener getResourceListener(android.app.Application application)
           
protected static ViewListener getViewListener(android.app.Application application)
           
static
<T> T
injectMembers(android.content.Context context, T t)
          A shortcut for RoboGuice.getInjector(context).injectMembers(o);
static DefaultRoboModule newDefaultRoboModule(android.app.Application application)
           
static com.google.inject.Injector setBaseApplicationInjector(android.app.Application application, com.google.inject.Stage stage)
          Return the cached Injector instance for this application, or create a new one if necessary.
static com.google.inject.Injector setBaseApplicationInjector(android.app.Application application, com.google.inject.Stage stage, com.google.inject.Module... modules)
          Return the cached Injector instance for this application, or create a new one if necessary.
static void setModulesResourceId(int modulesResourceId)
          Allows the user to override the "roboguice_modules" resource name with some other identifier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_STAGE

public static com.google.inject.Stage DEFAULT_STAGE

injectors

protected static WeakHashMap<android.app.Application,com.google.inject.Injector> injectors

resourceListeners

protected static WeakHashMap<android.app.Application,ResourceListener> resourceListeners

viewListeners

protected static WeakHashMap<android.app.Application,ViewListener> viewListeners

modulesResourceId

protected static int modulesResourceId
Method Detail

getBaseApplicationInjector

public static com.google.inject.Injector getBaseApplicationInjector(android.app.Application application)
Return the cached Injector instance for this application, or create a new one if necessary.


setBaseApplicationInjector

public static com.google.inject.Injector setBaseApplicationInjector(android.app.Application application,
                                                                    com.google.inject.Stage stage,
                                                                    com.google.inject.Module... modules)
Return the cached Injector instance for this application, or create a new one if necessary. If specifying your own modules, you must include a DefaultRoboModule for most things to work properly. Do something like the following: RoboGuice.setAppliationInjector( app, RoboGuice.DEFAULT_STAGE, Modules.override(RoboGuice.newDefaultRoboModule(app)).with(new MyModule() );

See Also:
Modules.override(com.google.inject.Module...), setBaseApplicationInjector(android.app.Application, com.google.inject.Stage, com.google.inject.Module...), newDefaultRoboModule(android.app.Application), If using this method with test cases, be sure to call {@link roboguice.RoboGuice.util#reset()} in your test teardown methods to avoid polluting our other tests with your custom injector. Don't do this in your real application though.

setModulesResourceId

public static void setModulesResourceId(int modulesResourceId)
Allows the user to override the "roboguice_modules" resource name with some other identifier. This is a static value.


setBaseApplicationInjector

public static com.google.inject.Injector setBaseApplicationInjector(android.app.Application application,
                                                                    com.google.inject.Stage stage)
Return the cached Injector instance for this application, or create a new one if necessary.


getInjector

public static RoboInjector getInjector(android.content.Context context)

injectMembers

public static <T> T injectMembers(android.content.Context context,
                                  T t)
A shortcut for RoboGuice.getInjector(context).injectMembers(o);


newDefaultRoboModule

public static DefaultRoboModule newDefaultRoboModule(android.app.Application application)

getResourceListener

protected static ResourceListener getResourceListener(android.app.Application application)

getViewListener

protected static ViewListener getViewListener(android.app.Application application)

destroyInjector

public static void destroyInjector(android.content.Context context)


Copyright © 2012. All Rights Reserved.