roboguice.inject.ContextScopedProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of roboguice Show documentation
Show all versions of roboguice Show documentation
A framework for using Google Guice dependency injection in Android.
package roboguice.inject;
import android.content.Context;
import com.google.inject.Inject;
import com.google.inject.Provider;
public class ContextScopedProvider {
@Inject protected ContextScope scope;
@Inject protected Provider provider;
public T get(Context context) {
synchronized (ContextScope.class) {
scope.enter(context);
try {
return provider.get();
} finally {
scope.exit(context);
}
}
}
}