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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations