I want to download the following image upload code with Picasso image cache.
DownloadImage downloadImage = new DownloadImage();
downloadImage.execute(advert.getImgUrl());
private class DownloadImage extends AsyncTask<String, Void, Bitmap> {
@Override
protected Bitmap doInBackground(String... arg) {
Bitmap bmp = null;
try {
URL url = new URL(arg[0]);
bmp = BitmapFactory.decodeStream(url.openConnection()
.getInputStream());
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
return null;
}
return bmp;
}
@Override
protected void onPostExecute(Bitmap result) {
if (result == null) {
Intent intent = new Intent(AdvertisingActivity.this,
AdvertisingErrorActivity.class);
intent.putExtra("ad-error", "Error downloading image");
}
adImg.setImageBitmap(result);
super.onPostExecute(result);
}
}
I have a few questions regarding this.
I want to upload multiple images in parallel. If I repeat calls Picasso.with(getActivity()).load(url);with different URL values, is this done?
I want to upload images to one activity and use it in another action. Is it possible? How can I do that?
If I call Picasso.with(getActivity()).load(url);more than once with the same URL value, does it load cached images for subsequent calls after loading the image?
If the image upload process is not possible for some reason, can you tell Picasso about the error?