Search in sources :

Example 26 with Provides

use of dagger.Provides in project philm by chrisbanes.

the class NetworkProvider method provideTmdbClient.

@Provides
@Singleton
public Tmdb provideTmdbClient(@CacheDirectory File cacheLocation) {
    Tmdb tmdb = new PhilmTmdb(cacheLocation);
    tmdb.setApiKey(Constants.TMDB_API_KEY);
    tmdb.setIsDebug(Constants.DEBUG_NETWORK);
    return tmdb;
}
Also used : Tmdb(com.uwetrottmann.tmdb.Tmdb) PhilmTmdb(app.philm.in.network.PhilmTmdb) PhilmTmdb(app.philm.in.network.PhilmTmdb) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 27 with Provides

use of dagger.Provides in project cryptomator by cryptomator.

the class CryptomatorModule method provideWebDavServer.

@Provides
@Singleton
WebDavServer provideWebDavServer(Binding<InetSocketAddress> serverSocketAddressBinding) {
    WebDavServer server = WebDavServer.create();
    // no need to unsubscribe eventually, because server is a singleton
    EasyBind.subscribe(serverSocketAddressBinding, server::bind);
    return server;
}
Also used : WebDavServer(org.cryptomator.frontend.webdav.WebDavServer) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 28 with Provides

use of dagger.Provides in project cryptomator by cryptomator.

the class CryptomatorModule method provideDeferredCloser.

@Provides
@Singleton
DeferredCloser provideDeferredCloser() {
    DeferredCloser closer = new DeferredCloser();
    Cryptomator.addShutdownTask(() -> {
        try {
            closer.close();
        } catch (Exception e) {
            LOG.error("Error during shutdown.", e);
        }
    });
    return closer;
}
Also used : DeferredCloser(org.cryptomator.ui.util.DeferredCloser) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 29 with Provides

use of dagger.Provides in project ListenerMusicPlayer by hefuyicoder.

the class NetworkModule method provideLastFMRetrofit.

@Provides
@Named("lastfm")
@PerApplication
Retrofit provideLastFMRetrofit() {
    String endpointUrl = Constants.BASE_API_URL_LASTFM;
    Gson gson = new GsonBuilder().create();
    GsonConverterFactory gsonConverterFactory = GsonConverterFactory.create(gson);
    HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
    loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
    OkHttpClient client = new OkHttpClient.Builder().cache(new Cache(FileUtil.getHttpCacheDir(ListenerApp.getContext()), Constants.HTTP_CACHE_SIZE)).connectTimeout(Constants.HTTP_CONNECT_TIMEOUT, TimeUnit.MILLISECONDS).readTimeout(Constants.HTTP_READ_TIMEOUT, TimeUnit.MILLISECONDS).build();
    //        OkHttpClient newClient = client.newBuilder().addInterceptor(loggingInterceptor).build();
    Retrofit retrofit = new Retrofit.Builder().baseUrl(endpointUrl).client(client).addConverterFactory(gsonConverterFactory).addCallAdapterFactory(RxJavaCallAdapterFactory.create()).build();
    return retrofit;
}
Also used : Retrofit(retrofit2.Retrofit) OkHttpClient(okhttp3.OkHttpClient) GsonBuilder(com.google.gson.GsonBuilder) GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) GsonConverterFactory(retrofit2.converter.gson.GsonConverterFactory) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) Cache(okhttp3.Cache) Named(javax.inject.Named) PerApplication(io.hefuyi.listener.injector.scope.PerApplication) Provides(dagger.Provides)

Example 30 with Provides

use of dagger.Provides in project ListenerMusicPlayer by hefuyicoder.

the class NetworkModule method provideKuGouRetrofit.

@Provides
@Named("kugou")
@PerApplication
Retrofit provideKuGouRetrofit() {
    String endpointUrl = Constants.BASE_API_URL_KUGOU;
    Gson gson = new GsonBuilder().create();
    GsonConverterFactory gsonConverterFactory = GsonConverterFactory.create(gson);
    HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
    loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
    OkHttpClient client = new OkHttpClient.Builder().cache(new Cache(FileUtil.getHttpCacheDir(ListenerApp.getContext()), Constants.HTTP_CACHE_SIZE)).connectTimeout(Constants.HTTP_CONNECT_TIMEOUT, TimeUnit.MILLISECONDS).readTimeout(Constants.HTTP_READ_TIMEOUT, TimeUnit.MILLISECONDS).build();
    //        OkHttpClient newClient = client.newBuilder().addInterceptor(loggingInterceptor).build();
    Retrofit retrofit = new Retrofit.Builder().baseUrl(endpointUrl).client(client).addConverterFactory(gsonConverterFactory).addCallAdapterFactory(RxJavaCallAdapterFactory.create()).build();
    return retrofit;
}
Also used : Retrofit(retrofit2.Retrofit) OkHttpClient(okhttp3.OkHttpClient) GsonBuilder(com.google.gson.GsonBuilder) GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) GsonConverterFactory(retrofit2.converter.gson.GsonConverterFactory) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) Cache(okhttp3.Cache) Named(javax.inject.Named) PerApplication(io.hefuyi.listener.injector.scope.PerApplication) 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