I'm trying to load images stored in my Firestore storage to the image view with RecyclerView of Android. Uploading image is not a problem and I configured same permission for upload and download. But it only shows an image specified in the parameter of placeholder.
I searched several things which seem to be relevant with this issue. Then I found that the matter of the version of Picasso Library and change of with(context) to get()
.
I applied them to my code and tested.
with the version of Picasso for 2.5.2 then tried with(mContext). Next I tried the version of Picasso for 2.71828 then tried get()
.
But both gives same result which can be confirmed here .
It seems to be this is not a matter of Picasso. But I couldn't find proper solution.
Anyone can help this out?
Source for onBindViewHolder
in an imageAdapter.java
@Override
public void onBindViewHolder(ImageViewHolder holder, int position) {
Upload uploadCurrent = mUploads.get(position);
holder.textViewName.setText(uploadCurrent.getName());
Picasso.with(mContext)
.load(uploadCurrent.getImageUrl())
.placeholder(R.mipmap.ic_launcher)
.fit()
.centerCrop()
.into(holder.imageView);
}
As I mentioned above, get()
replaced of with( mContext
) already tried.
Please let me know if you need further information for this.
you can use a callback to get success/error events.
Picasso.with(mContext)
.load(uploadCurrent.getImageUrl())
.error(R.drawable.error_image)
.into(holder.imageView, new com.squareup.picasso.Callback() {
@Override
public void onSuccess() {
// will load image
}
@Override
public void onError() {
// will not load image from url
}
});
im soryy for to much late but this is 100% worked fo me.. you just use imagPath in picaso to load image and done
String imagpath="";
FirebaseStorage storageReference = FirebaseStorage.getInstance();
DatabaseReference mDatabase = null;
UploadTask uploadTask;
StorageReference riversRef = storageReference.getReference();
final StorageReference imagesRef = riversRef.child("images/Avatars/"+getSaltString()+filePathh.getLastPathSegment());
uploadTask = imagesRef.putFile(filePathh);
// Register observers to listen for when the download is done or if it fails
uploadTask.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle unsuccessful uploads
}
}).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
// taskSnapshot.getMetadata() contains file metadata such as size, content-type, etc.
// ...
imagesRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
String content = uri.toString();
String result = content.substring(content.indexOf("%") + 1, content.indexOf("?"));
result = result.substring(2);
if (content.length() > 0) {
imagepath=content;
}
}
});
//update session image path
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.