Search in sources :

Example 11 with Provides

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;
}
Also used : BriteDatabase(com.squareup.sqlbrite.BriteDatabase) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 12 with Provides

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;
}
Also used : NetworkBehavior(retrofit2.mock.NetworkBehavior) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 13 with Provides

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;
    }
}
Also used : ElementsIntoSet(dagger.multibindings.ElementsIntoSet) Method(java.lang.reflect.Method) Provides(dagger.Provides)

Example 14 with Provides

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;
}
Also used : HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 15 with Provides

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;
}
Also used : NetworkBehavior(retrofit2.mock.NetworkBehavior) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Aggregations

Provides (dagger.Provides)46 Singleton (javax.inject.Singleton)35 HttpLoggingInterceptor (okhttp3.logging.HttpLoggingInterceptor)11 OkHttpClient (okhttp3.OkHttpClient)10 OkHttpClient (com.squareup.okhttp.OkHttpClient)5 StethoInterceptor (com.facebook.stetho.okhttp3.StethoInterceptor)3 GsonBuilder (com.google.gson.GsonBuilder)3 Cache (okhttp3.Cache)3 LoginManager (com.byoutline.kickmaterial.managers.LoginManager)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 PlaceRenderer (com.github.pedrovgs.sample.renderer.PlaceRenderer)2 TvShowRenderer (com.github.pedrovgs.sample.renderer.TvShowRenderer)2 Gson (com.google.gson.Gson)2 BindingsGroup (dagger.internal.BindingsGroup)2 SetBinding (dagger.internal.SetBinding)2 PerApplication (io.hefuyi.listener.injector.scope.PerApplication)2 File (java.io.File)2 LinkedHashMap (java.util.LinkedHashMap)2 Named (javax.inject.Named)2 ExecutableElement (javax.lang.model.element.ExecutableElement)2