1

Am creating a RecyclerView to show some images and text, then user can bookmark rows of RecyclerView. Images of the RecyclerView are match parent on width and height will be wrap_content. On clicking on bookmark, adapter calls notifydatasetchanged in RecyclerView. My issue is that after calling notifydatasetchanged changed, RecyclerView blinking its images by height.

        @Override
        public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
            if (holder instanceof VHITEM) {
                final VHITEM VHitem = (VHITEM) holder;
                Glide.with(mContext)
                        .load(articleDataList.get(position).SourcePath)
                        .asBitmap()
                        .diskCacheStrategy(DiskCacheStrategy.ALL)
                        .placeholder(R.drawable.defaultimage)
                        .error(R.drawable.defaultimage)
                        .dontAnimate()
                        .into(VHitem.imageViewTagPic); 
            }
        }

OnButton Click

    VHItem.imageViewAddRemoveBookmark.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
    notifyDataSetChanged(); }
    }

RecyclerView configuration

LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(linearLayoutManager);
Bincy Baby
  • 3,941
  • 5
  • 36
  • 62

2 Answers2

1

Try using this on RecyclerView to restrict the blinking of view.

RecyclerView.ItemAnimator animator = mRecycler.getItemAnimator();

if (animator instanceof SimpleItemAnimator) {
    ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
}
TWiStErRob
  • 44,762
  • 26
  • 170
  • 254
AndroidBeginner
  • 663
  • 1
  • 9
  • 16
0

It's not because of glide, if item data changed call notifyitemchanged(position,payload) and then override onBindViewHolder 3 argument method

Bincy Baby
  • 3,941
  • 5
  • 36
  • 62