use of com.squareup.picasso.OkHttp3Downloader in project Manhua by ag2s20150909.
the class APP method onCreate.
@Override
public void onCreate() {
super.onCreate();
mContext = this;
fixdeThreadPool = Executors.newFixedThreadPool(1);
CrashHandler.getInstance().init(this).setOnCrashListener(new CrashHandler.OnCrashListener() {
@Override
public void onCrash(Context context, String errorMsg) {
Toast.makeText(context, errorMsg, Toast.LENGTH_LONG).show();
}
}).setCrashSave().setCrashSaveTargetFolder(this.getExternalFilesDir("crash").getPath());
File file = new File(mContext.getExternalCacheDir(), "okhttpcache");
if (!file.exists()) {
file.mkdirs();
}
okhttp3.Cache cache = new okhttp3.Cache(file, 1024 * 1024 * 500);
okhttp3.OkHttpClient client = new OkHttpClient.Builder().cache(cache).build();
OkHttp3Downloader okHttp3Downloader = new OkHttp3Downloader(client);
Picasso.Builder picassoBuilder = new Picasso.Builder(mContext);
picassoBuilder.downloader(okHttp3Downloader).build();
Picasso picasso = picassoBuilder.build();
Picasso.setSingletonInstance(picasso);
}
Aggregations