I use picasso to download and cache image but the images does't cache but download successfully and i don't fin the problem and i use dagger to decency inject picasso object also but i don't think that is the problem
Here is my code at the adapter as i pass picasso to the adapter object
picasso.load(currentClient.getLogoUrl())
.placeholder(R.mipmap.ic_launcher)
.into(holder.clientImage);
And my di code
@Module(includes = {ContextModule.class, NetworkModule.class})
public class PicassoModule {
@Provides
@InmaaApplicationScope
public Picasso picasso(@ApplicationContext Context context, OkHttp3Downloader okHttp3Downloader) {
return new Picasso.Builder(context)
.downloader(okHttp3Downloader)
.build();
}
@Provides
@InmaaApplicationScope
public OkHttp3Downloader okHttp3Downloader(OkHttpClient okHttpClient) {
return new OkHttp3Downloader(okHttpClient);
}
}
The other module
@Module(includes = ContextModule.class)
public class NetworkModule {
@Provides
@InmaaApplicationScope
public HttpLoggingInterceptor loggingInterceptor() {
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(message -> Timber.i(message));
interceptor.setLevel(HttpLoggingInterceptor.Level.BASIC);
return interceptor;
}
@Provides
@InmaaApplicationScope
public Cache cache(File cacheFile) {
return new Cache(cacheFile, 512 * 1024 * 1024); //512 MB for cache
}
@Provides
@InmaaApplicationScope
public File cacheFile(@ApplicationContext Context context) {
return new File(context.getCacheDir(), "okhttp_cache");
}
@Provides
@InmaaApplicationScope
public OkHttpClient okHttpClient(HttpLoggingInterceptor loggingInterceptor, Cache cache) {
return new OkHttpClient.Builder()
.addInterceptor(loggingInterceptor)
.cache(cache)
.build();
}
}
at the Activity code
@Inject
Picasso picasso;
clientsAdapter = new ClientsAdapter(picasso);
The state of the cache folder
