use of dagger.Provides in project sqlbrite by square.
the class DbModule method provideDatabase.
@Provides
@Singleton
BriteDatabase provideDatabase(SqlBrite sqlBrite, SQLiteOpenHelper helper) {
BriteDatabase db = sqlBrite.wrapDatabaseHelper(helper, Schedulers.io());
db.setLoggingEnabled(true);
return db;
}
use of dagger.Provides in project Just-Another-Android-App by athkalia.
the class BuildTypeAwareModule method providesNetworkBehavior.
@Provides
@Singleton
@SuppressWarnings("checkstyle:magicnumber")
public static NetworkBehavior providesNetworkBehavior() {
NetworkBehavior networkBehavior = NetworkBehavior.create();
networkBehavior.setDelay(1, TimeUnit.SECONDS);
// Delay can vary by 50%.
networkBehavior.setVariancePercent(50);
// 20% of all calls are failing.
networkBehavior.setFailurePercent(20);
return networkBehavior;
}
use of dagger.Provides in project guice by google.
the class DaggerMethodScanner method prepareMethod.
@Override
public <T> Key<T> prepareMethod(Binder binder, Annotation rawAnnotation, Key<T> key, InjectionPoint injectionPoint) {
Method providesMethod = (Method) injectionPoint.getMember();
Provides annotation = (Provides) rawAnnotation;
if (providesMethod.isAnnotationPresent(IntoSet.class)) {
return processSetBinding(binder, key);
} else if (providesMethod.isAnnotationPresent(ElementsIntoSet.class)) {
binder.addError("@ElementsIntoSet contributions are not suppored by Guice.", providesMethod);
return key;
} else if (providesMethod.isAnnotationPresent(IntoMap.class)) {
/* TODO(cgruber) implement map bindings */
binder.addError("Map bindings are not yet supported.");
return key;
}
switch(annotation.type()) {
case UNIQUE:
return key;
case MAP:
/* TODO(cgruber) implement map bindings */
binder.addError("Map bindings are not yet supported.");
return key;
case SET:
return processSetBinding(binder, key);
case SET_VALUES:
binder.addError(Type.SET_VALUES.name() + " contributions are not supported by Guice.", providesMethod);
return key;
default:
binder.addError("Unknown @Provides type " + annotation.type() + ".", providesMethod);
return key;
}
}
use of dagger.Provides in project u2020 by JakeWharton.
the class DebugApiModule method provideLoggingInterceptor.
@Provides
@Singleton
HttpLoggingInterceptor provideLoggingInterceptor() {
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(message -> Timber.tag("OkHttp").v(message));
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.HEADERS);
return loggingInterceptor;
}
use of dagger.Provides in project u2020 by JakeWharton.
the class DebugApiModule method provideBehavior.
@Provides
@Singleton
NetworkBehavior provideBehavior(@NetworkDelay Preference<Long> networkDelay, @NetworkFailurePercent Preference<Integer> networkFailurePercent, @NetworkVariancePercent Preference<Integer> networkVariancePercent) {
NetworkBehavior behavior = NetworkBehavior.create();
behavior.setDelay(networkDelay.get(), MILLISECONDS);
behavior.setFailurePercent(networkFailurePercent.get());
behavior.setVariancePercent(networkVariancePercent.get());
return behavior;
}
Aggregations