我正在尝试将Picasso
下载到internal storage
,但它显示没有向HAL
提供足够的数据。
public void downloadImage( String url) {
String filename= UUID.randomUUID().toString()+".jpg";
Picasso.with(getApplicationContext()).load(url)
.into(new Imagedownloader(anime_relativelayout,lottieAnimationView,
getApplicationContext().getContentResolver(),filename,"image desc"));
}
public class Imagedownloader implements Target {
private RelativeLayout anime_relativelayout;
private LottieAnimationView lottieAnimationView;
String name;
String desc;
public Imagedownloader(RelativeLayout anime_relativelayout, LottieAnimationView lottieAnimationView,
ContentResolver contentResolver, String filename, String s) {
this.contentResolverWeakReference = new WeakReference<ContentResolver>(contentResolver);
this.name = filename;
this.desc = s;
this.lottieAnimationView=lottieAnimationView;
this.anime_relativelayout=anime_relativelayout;
}
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
ContentResolver resolver=contentResolverWeakReference.get();
//AlertDialog dialog=alertDialogWeakReference.get();
MediaStore.Images.Media.insertImage(resolver,bitmap,name,desc);
//lottieAnimationView.pauseAnimation();
//anime_relativelayout.setVisibility(View.GONE);
//dialog.dismiss();
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
}