-1

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.

Dor
  • 657
  • 1
  • 5
  • 11
pe.jeon
  • 23
  • 4

2 Answers2

0

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
                    }
                });
Ankit
  • 1,068
  • 6
  • 10
  • I tried it according to your suggestion. Then I got a result that the all images are changed the error_image. I checked the URL from uploadCurrent.getImageUrl(), it indicates correct URLs of firebase database. – pe.jeon Sep 07 '19 at 12:47
  • is that url loading properly in browser?.if yes then try to check your internet connection,or if your image size is too large then try too resize in picasso like .resize(200, 200); – Ankit Sep 07 '19 at 12:56
  • No, actually not. "com.google.android.gms.tasks.zzu@9bdfc92" this is one of urls in my database. But it looks not a proper url for the images. – pe.jeon Sep 07 '19 at 13:02
  • check this your problem is same like this https://stackoverflow.com/questions/57183427/download-url-is-getting-as-com-google-android-gms-tasks-zzu441922b-while-using – Ankit Sep 07 '19 at 13:15
0

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


            }
        });
Adnan Bashir
  • 645
  • 4
  • 8