Search in sources :

Example 1 with AppInfoUserAgentInterceptor

use of com.toshi.manager.network.interceptor.AppInfoUserAgentInterceptor in project toshi-android-client by toshiapp.

the class GlideOkHttpStack method registerComponents.

@Override
public void registerComponents(Context context, Glide glide) {
    final File cacheDir = new File(BaseApplication.get().getCacheDir(), "ToshiImageCache");
    final Cache cache = new Cache(cacheDir, MAX_SIZE);
    final OkHttpClient client = new OkHttpClient().newBuilder().cache(cache).addInterceptor(new AppInfoUserAgentInterceptor()).addInterceptor(new HttpLoggingInterceptor(new LoggingInterceptor()).setLevel(HttpLoggingInterceptor.Level.BODY)).build();
    glide.register(CachedGlideUrl.class, InputStream.class, superFactory(new OkHttpUrlLoader.Factory(client), CachedGlideUrl.class));
    glide.register(ForceLoadGlideUrl.class, InputStream.class, superFactory(new OkHttpUrlLoader.Factory(client), ForceLoadGlideUrl.class));
}
Also used : OkHttpClient(okhttp3.OkHttpClient) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) LoggingInterceptor(com.toshi.manager.network.interceptor.LoggingInterceptor) ModelLoaderFactory(com.bumptech.glide.load.model.ModelLoaderFactory) AppInfoUserAgentInterceptor(com.toshi.manager.network.interceptor.AppInfoUserAgentInterceptor) File(java.io.File) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) Cache(okhttp3.Cache)

Aggregations

ModelLoaderFactory (com.bumptech.glide.load.model.ModelLoaderFactory)1 AppInfoUserAgentInterceptor (com.toshi.manager.network.interceptor.AppInfoUserAgentInterceptor)1 LoggingInterceptor (com.toshi.manager.network.interceptor.LoggingInterceptor)1 File (java.io.File)1 Cache (okhttp3.Cache)1 OkHttpClient (okhttp3.OkHttpClient)1 HttpLoggingInterceptor (okhttp3.logging.HttpLoggingInterceptor)1