Search in sources :

Example 16 with Provides

use of dagger.Provides in project Telecine by JakeWharton.

the class TelecineModule method provideAnalytics.

@Provides
@Singleton
Analytics provideAnalytics() {
    if (BuildConfig.DEBUG) {
        return new Analytics() {

            @Override
            public void send(Map<String, String> params) {
                Timber.tag("Analytics").d(String.valueOf(params));
            }
        };
    }
    GoogleAnalytics googleAnalytics = GoogleAnalytics.getInstance(app);
    Tracker tracker = googleAnalytics.newTracker(BuildConfig.ANALYTICS_KEY);
    // ms? s? better be s.
    tracker.setSessionTimeout(300);
    return new Analytics.GoogleAnalytics(tracker);
}
Also used : GoogleAnalytics(com.google.android.gms.analytics.GoogleAnalytics) Tracker(com.google.android.gms.analytics.Tracker) Map(java.util.Map) GoogleAnalytics(com.google.android.gms.analytics.GoogleAnalytics) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 17 with Provides

use of dagger.Provides in project BookReader by JustWayward.

the class BookApiModule method provideOkHttpClient.

@Provides
public OkHttpClient provideOkHttpClient() {
    LoggingInterceptor logging = new LoggingInterceptor(new Logger());
    logging.setLevel(LoggingInterceptor.Level.BODY);
    OkHttpClient.Builder builder = new OkHttpClient.Builder().connectTimeout(10, TimeUnit.SECONDS).connectTimeout(20 * 1000, TimeUnit.MILLISECONDS).readTimeout(20 * 1000, TimeUnit.MILLISECONDS).retryOnConnectionFailure(// 失败重发
    true).addInterceptor(new HeaderInterceptor()).addInterceptor(logging);
    return builder.build();
}
Also used : LoggingInterceptor(com.justwayward.reader.api.support.LoggingInterceptor) OkHttpClient(okhttp3.OkHttpClient) HeaderInterceptor(com.justwayward.reader.api.support.HeaderInterceptor) Logger(com.justwayward.reader.api.support.Logger) Provides(dagger.Provides)

Example 18 with Provides

use of dagger.Provides in project SpotiQ by ZinoKader.

the class AppModule method providePartiesRepository.

@Provides
@Singleton
PartiesRepository providePartiesRepository() {
    FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance();
    DatabaseReference databaseReference = firebaseDatabase.getReference().child(FirebaseConstants.CHILD_PARTYLIST);
    return new PartiesRepository(databaseReference);
}
Also used : FirebaseDatabase(com.google.firebase.database.FirebaseDatabase) DatabaseReference(com.google.firebase.database.DatabaseReference) PartiesRepository(se.zinokader.spotiq.repository.PartiesRepository) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 19 with Provides

use of dagger.Provides in project jianshi by wingjay.

the class AppModule method provideOkHttpClient.

@Provides
@Singleton
OkHttpClient provideOkHttpClient(GlobalRequestInterceptor globalRequestInterceptor) {
    OkHttpClient.Builder builder = new OkHttpClient.Builder().connectionPool(new ConnectionPool(5, 59, TimeUnit.SECONDS)).connectTimeout(20, TimeUnit.SECONDS).readTimeout(20, TimeUnit.SECONDS).addInterceptor(globalRequestInterceptor).retryOnConnectionFailure(false);
    if (BuildConfig.DEBUG) {
        builder.addNetworkInterceptor(new StethoInterceptor());
    }
    HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
    httpLoggingInterceptor.setLevel(BuildConfig.DEBUG ? HttpLoggingInterceptor.Level.BODY : HttpLoggingInterceptor.Level.NONE);
    builder.addInterceptor(httpLoggingInterceptor);
    return builder.build();
}
Also used : ConnectionPool(okhttp3.ConnectionPool) OkHttpClient(okhttp3.OkHttpClient) StethoInterceptor(com.facebook.stetho.okhttp3.StethoInterceptor) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 20 with Provides

use of dagger.Provides in project dobby-android by InceptAi.

the class ProdModule method providesNetworkLayer.

@Singleton
@Provides
public NetworkLayer providesNetworkLayer(DobbyApplication application, DobbyThreadpool threadpool, DobbyEventBus eventBus) {
    NetworkLayer networkLayer = new NetworkLayer(application.getApplicationContext(), threadpool, eventBus);
    application.getProdComponent().inject(networkLayer);
    networkLayer.initialize();
    return networkLayer;
}
Also used : NetworkLayer(com.inceptai.dobby.NetworkLayer) 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