@Provides
    @Singleton
    Retrofit provideCall() {
        Cache cache = null;
        try {
            cache = new Cache(cacheFile, 10 * 1024 * 1024);
        } catch (Exception e) {
            e.printStackTrace();
        }
        /* TODO Consider moving elsewhere. */
        OkHttpClient okHttpClient = new OkHttpClient.Builder()
                .addInterceptor(new Interceptor() {
                    @Override
                    public okhttp3.Response intercept(Chain chain) throws IOException {
                        Request original = chain.request();
                        HttpUrl originalHttpUrl = original.url();
                        HttpUrl url = originalHttpUrl.newBuilder()
                                .addQueryParameter("APPID", BuildConfig.API_OPENWEATHERMAP_KEY)
                                .build();
                        Request request = original.newBuilder()
                                .header("Content-Type", "application/json")
                                .removeHeader("Pragma")
                                .header("Cache-Control", String.format("max-age=%d", BuildConfig.CACHETIME))
                                .url(url)
                                .build();
                        okhttp3.Response response = chain.proceed(request);
                        response.cacheResponse();
                        return response;
                    }
                })
                .cache(cache)
                .build();
        return new Retrofit.Builder()
                .baseUrl(BuildConfig.API_OPENWEATHERMAP_BASEURL)
                .client(okHttpClient)
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .build();
    }
@Provides
    @Singleton
    Retrofit provideCall() {
        Cache cache = null;
        try {
            cache = new Cache(cacheFile, 10 * 1024 * 1024);
        } catch (Exception e) {
            e.printStackTrace();
        }
       
        OkHttpClient okHttpClient = new OkHttpClient.Builder()
                .addInterceptor(new Interceptor() {
                    @Override
                    public okhttp3.Response intercept(Chain chain) throws IOException {
                        Request original = chain.request();
                        HttpUrl originalHttpUrl = original.url();
                        HttpUrl url = originalHttpUrl.newBuilder()
                                .addQueryParameter("APPID", BuildConfig.API_OPENWEATHERMAP_KEY)
                                .build();
                        Request request = original.newBuilder()
                                .header("Content-Type", "application/json")
                                .removeHeader("Pragma")
                                .header("Cache-Control", String.format("max-age=%d", BuildConfig.CACHETIME))
                                .url(url)
                                .build();
                        okhttp3.Response response = chain.proceed(request);
                        response.cacheResponse();
                        return response;
                    }
                })
                .cache(cache)
                .build();
        return new Retrofit.Builder()
                .baseUrl(BuildConfig.API_OPENWEATHERMAP_BASEURL)
                .client(okHttpClient)
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .build();
    }
@provides @singleton retrofit providecall() { cache cache = null; try { cache = new cache(cachefile, 10 * 1024 * 1024); } catch (exception e) { e.printstacktrace(); } okhttpclient okhttpclient = new okhttpclient.builder() .addinterceptor(new interceptor() { @override public okhttp3.response intercept(chain chain) throws ioexception { request original = chain.request(); httpurl originalhttpurl = original.url(); httpurl url = originalhttpurl.newbuilder() .addqueryparameter("appid", buildconfig.api_openweathermap_key) .build(); request request = original.newbuilder() .header("content-type", "application/json") .removeheader("pragma") .header("cache-control", string.format("max-age=%d", buildconfig.cachetime)) .url(url) .build(); okhttp3.response response = chain.proceed(request); response.cacheresponse(); return response; } }) .cache(cache) .build(); return new retrofit.builder() .baseurl(buildconfig.api_openweathermap_baseurl) .client(okhttpclient) .addconverterfactory(gsonconverterfactory.create()) .addcalladapterfactory(rxjavacalladapterfactory.create()) .build(); }