sangcomz / StickyTimeLine

:book:StickyTimeLine is timeline view for android.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

duplication in recycler view

MahdiAhmadnejad opened this issue · comments

when I use glide in adapter to set the images for each item , my items in recycler will be duplicated.
I have no idea , when I remove Glide or Picasso it is ok.
duplication_problem

this is my code

public class NotifyAdapter extends RecyclerView.Adapter<NotifyAdapter.ViewHolder> {
    private LayoutInflater layoutInflater;
    private List<NotifyModel> notifyList;
    private Context context;
    @LayoutRes
    private int rowLayout;

    public NotifyAdapter(LayoutInflater layoutInflater, List<NotifyModel> notifyList, int rowLayout , Context context) {
        this.layoutInflater = layoutInflater;
        this.notifyList = notifyList;
        this.rowLayout = rowLayout;
        this.context = context;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = layoutInflater.inflate(rowLayout, parent, false);
        return new ViewHolder(v);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        NotifyModel notifyModel = notifyList.get(position);
        holder.fullName.setText(notifyModel.getMessage());
        Picasso.get().load(notifyModel.getImgurl()).into(holder.imageView);
        Log.d("Running", "onBindViewHolder: " + position);    
    
    }

    @Override
    public int getItemCount() {
        return notifyList.size();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        public TextView fullName;
        public ImageView imageView;
        public ViewHolder(View view) {
            super(view);
            fullName = view.findViewById(R.id.name_textView);
            imageView = view.findViewById(R.id.image_view);
        }
    }
}

Thanks!

Hi,

Picasso.get().load(notifyModel.getImgurl()).into(holder.imageView);

Are you saying that if you remove this code it will work fine?

Hi,

Picasso.get().load(notifyModel.getImgurl()).into(holder.imageView);

Are you saying that if you remove this code it will work fine?

Hi, Yes

Hi,

Picasso.get().load(notifyModel.getImgurl()).into(holder.imageView);

Are you saying that if you remove this code it will work fine?

I sincerely apologize for the bug in my code that was randomly doubling values. This was entirely my mistake in programming the incorrect logic. Thank you for your patience and assistance troubleshooting an issue that stemmed from my flawed coding