-1

I was trying to load data from firebase into my recycler view. There are two values that I am retrieving first is Name and second is the ImageUrl. When i run my app the value from the name is displaying on the recyclerview but the image is still blank. Somehow picasso is failing to load the image into the CircleImageView.

Below is my ViewHolderclass

public static class CategoryViewHolder extends RecyclerView.ViewHolder {

View mView;
CircleImageView categoryImageView;
TextView categoryName;

public CategoryViewHolder(View itemView) {
    super(itemView);

    mView = itemView;

}

public void setDisplayName(String name){

     categoryName = (TextView) mView.findViewById(R.id.Category_name);
    categoryName.setText(name);

}


public void setUserImage(String thumb_image, Context ctx){

    categoryImageView = (CircleImageView) 
mView.findViewById(R.id.Category_pic);



 Picasso.with(ctx).load(thumb_image).placeholder(R.drawable. 
   default_avatar)
 .into( categoryImageView);
 //   Picasso.with(ctx) .load(thumb_image)  .into(categoryImageView);
}


 }

this is my model class

public class CategoryItems {
private  String Name;
private String ImageUrl;

public CategoryItems(String title, String imageURL) {
this.Name = title;
this.ImageUrl = imageURL;
}


publ  ic CategoryItems(){

                   }

public String getName() {
return Name;
}

 public void setName(String name) {
Name = name;
}

public String getImageUrl() {
return ImageUrl;
}

 public void setImageUrl(String imageUrl) {
ImageUrl = imageUrl;
}
}

this is my FirebaseREcyclerViewAdapter

public void onStart() {
super.onStart();
startListening();
}

 public void startListening(){
  Query query = FirebaseDatabase.getInstance()
        .getReference()
        .child("Catlist")
        .limitToLast(500);

    FirebaseRecyclerOptions<CategoryItems> options =
        new FirebaseRecyclerOptions.Builder<CategoryItems>()
                .setQuery(query, CategoryItems.class)
                .build();
   FirebaseRecyclerAdapter adapter = new 
   FirebaseRecyclerAdapter<CategoryItems, CategoryViewHolder>(options) {
    @Override
    public CategoryViewHolder onCreateViewHolder(ViewGroup parent, int 
  viewType) {


        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.category_items, parent, false);



        return new CategoryViewHolder(view);
    }

    @Override
    protected void onBindViewHolder(final CategoryViewHolder holder, int 
   position, final CategoryItems model) {

        holder.setDisplayName(model.getName());
        holder.setUserImage(model.getImageUrl(), getContext());
     //   holder.setUserStatus(model.getStatus());
        Log.d(model.getImageUrl().toString(), "onBindViewHolder: ");


    }
};
mUsersList.setAdapter(adapter);
adapter.startListening();
}

my recycler is displaying names only and i tried to log the imageurls and its displaying the url fine

depp
  • 25
  • 6
  • if you can provide sample url of your thumb_image string here – Fahed Yasin May 06 '18 at 06:54
  • @FahedYasin url in my database were all wrong . thank you for your reply. can you please take a look at my other problem .https://stackoverflow.com/questions/50180119/cropactivity-is-not-starting-in-onactivityresult-inside-fragment i have tried many solutions but nothing is working – depp May 06 '18 at 07:53
  • okay, let me check – Fahed Yasin May 06 '18 at 07:58

1 Answers1

0

Try enabling logging in Picasso to look at errors and warning, it will definitely show some error in your case which you can resolve.

Picasso  
.with(context)
.setLoggingEnabled(true)
....

For more information check out this link

Rahul Sahni
  • 465
  • 4
  • 12
  • Thanks turned out that the image Url that i have pasted in my firebase were somehow not pasted right ...thanks a lot. Can you please take a look at my other problem also https://stackoverflow.com/questions/50180119/cropactivity-is-not-starting-in-onactivityresult-inside-fragment i have seen every thread but couldnt figure out what the problem is ..thanks in advance – depp May 06 '18 at 07:50
  • Okay, I'll into it – Rahul Sahni May 07 '18 at 13:38