如何实现Picasso Executor从后台的Url列表中下载图像。我要实现的代码如下
Picasso.setSingletonInstance(new Picasso.Builder(this).defaultBitmapConfig(Bitmap.Config.RGB_565).executor(threadpool)))
我实现了以下代码,以便从单个网址下载图像。
public void downloadImage(String url, String id,ImageDownloadedCallBack imageDownloadedCallBack){
mImagename=id+JPEG;
if(mIimageDownloadedCallBack != null) {
Picasso.get().load(url).into(mTarget);
} else {
mIimageDownloadedCallBack=imageDownloadedCallBack;
Picasso.get().load(url).into(mTarget);
}
}
public final Target mTarget = new Target() {
@Override
public void onBitmapLoaded(final Bitmap bitmap, Picasso.LoadedFrom from) {
fileStorage.putFile(mImagename,bitmap);
if (mIimageDownloadedCallBack != null) {
mIimageDownloadedCallBack.imageDownloadComplete(bitmap, true);
}
}
@Override
public void onBitmapFailed(Exception e, Drawable errorDrawable) {
if(mIimageDownloadedCallBack != null) {
mIimageDownloadedCallBack.imageDownloadComplete(null,false);
}
Log.d(TAG,e.getMessage());
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
if (placeHolderDrawable != null) {Log.d(TAG,"PlaceHolderDrawable");}
}
};
这是我需要传递给毕加索的url的列表
public void getDepartmentList() {
AppExecutors appExecutors = new AppExecutors();
appExecutors.diskIO().execute(() -> {
Departments departments = PersistentItemsUtil.getsDepartments();
List<MdcItemSummary> mdcItems = ProductLocatorApplication.getDatabase().mdcItemSummaryDao().getMDCItems(departments.getDept().getName());
Log.d("MDC", mdcItems.toString());
});
}
任何帮助将不胜感激...