0

This one works in activity.this one load the image from firebase to recyclerview:

            Glide.with(PURPLE_MARKET.this).load(productsModel.getImage()).
                    placeholder(R.drawable.loading).into(holder.producticon);

And in a fragment datas are loading perfectly from firebase to recyclerview:

            holder.titletv.setText(productsModel.getProductName());
            holder.pricetv.setText("Rs." + productsModel.getPrice() + ".00");

The problem starts with loading images to the fragment from firebase,here is the code:

            Glide.with(getActivity())
                    .load(productsModel.getImage())
                    .placeholder(R.drawable.loading)
                    .into(holder.imageFav);

if you need more updates,please tell me in the comment, Please give me a solution,i am stucking...

1 Answers1

1

Try Glide.with(getActivity().getContext()).

Sam Chen
  • 7,597
  • 2
  • 40
  • 73
  • Sorry, android studio is not get getActivity().getContext.it gets getActivity().getApplicationContext(). – Ashrik Ahamed Feb 08 '21 at 01:27
  • @Ashrik Ahamed So does `getActivity().getApplicationContext()` work? If not, what error you get? – Sam Chen Feb 08 '21 at 04:58
  • when its time to load the image by glide, the logcat says "Load failed for null with size [0x0] class com.bumptech.glide.load.engine.GlideException: Received null model". please suggest me a solution, i am stucking here. – Ashrik Ahamed Feb 08 '21 at 15:12
  • @Ashrik Ahamed According to the error, the image uri/url you passed seems to be null, see this post: https://github.com/bumptech/glide/issues/476 – Sam Chen Feb 08 '21 at 15:27
  • But it loads in an activity – Ashrik Ahamed Feb 08 '21 at 17:34
  • @Ashrik Ahamed Try using `requireContext()` instead of `getActivity()`. – Sam Chen Feb 08 '21 at 17:48
  • Why its not working on this fragment..it says recieved null model...but in activity, not showing that null model error..its perfectly loads to activity... – Ashrik Ahamed Feb 09 '21 at 13:56
  • @Ashrik Ahamed You can ask this author: https://stackoverflow.com/questions/60684890/load-failed-for-null-with-size-0x0-class-com-bumptech-glide-load-engine-glidee – Sam Chen Feb 09 '21 at 14:47