0

I am trying to load image from firebase storage to my recyclerview. In onBindViewHolder method I have implemented below code to load the image. But I am facing strange problem. Already I have seen some of similar problem's solutions but none of them worked.

Code

public void onBindViewHolder(@NonNull final AlternateListHolder_Market holder, int position) {

        productsListOfMarketFirestore curretItem = filterList.get(position);
        StorageReference storageReference = FirebaseStorage.getInstance().getReferenceFromUrl("gs://app-31e06.appspot.com/user_image1/").child(curretItem.getProductId() + ".jpg");
        Glide.with(holder.imageView.getContext())
                .load(storageReference)
                .into(holder.imageView);
}

Error

E/GlideExecutor: Request threw uncaught throwable
    com.bumptech.glide.Registry$NoModelLoaderAvailableException: Failed to find any ModelLoaders for model: gs://app-31e06.appspot.com/user_image1/1111.jpg
        at com.bumptech.glide.Registry.getModelLoaders(Registry.java:584)
        at com.bumptech.glide.load.engine.DecodeHelper.getLoadData(DecodeHelper.java:205)
        at com.bumptech.glide.load.engine.DecodeHelper.getCacheKeys(DecodeHelper.java:223)
        at com.bumptech.glide.load.engine.ResourceCacheGenerator.startNext(ResourceCacheGenerator.java:44)
        at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:302)
        at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:269)
        at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:233)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)
        at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:446)
halfer
  • 19,824
  • 17
  • 99
  • 186
  • In load("...") you need to pass image link. If you are taking image location from firebase storage then first get all the link in a List and then pass it to the adapter class. – Hritik Gupta May 19 '20 at 12:54
  • I am passing storage reference here. Image location is already initialized in ```storageReference```. – S. S. Saruar Jahan May 19 '20 at 13:02
  • Log the value of storage Reference. Check, if it is returning image URL of 1111.jpg or not. – Hritik Gupta May 19 '20 at 13:36
  • unfortunately no. How should I fix this?how can i get URL from storage reference? isn't it possible!!.. or is there any other way to do this? – S. S. Saruar Jahan May 19 '20 at 13:46
  • actually it's giving me something like this "gs://app-31e06.appspot.com/user_image1/1111.jpg" which i have initialized before. should pass the http link to load("..") method?? – S. S. Saruar Jahan May 19 '20 at 13:50
  • The link which storeReference is having is the location of your storage on Google cloud. This is what I said above that load() method needs an image url to download and display image. In order to get image link of 1111.jpg , you need to gets It's url from firebase storage. – Hritik Gupta May 19 '20 at 14:13
  • Check this. https://stackoverflow.com/questions/37374868/how-to-get-url-from-firebase-storage-getdownloadurl – Hritik Gupta May 19 '20 at 14:13
  • After getting the url you just pass it to load() method – Hritik Gupta May 19 '20 at 14:14

0 Answers0