Esdras Esdras - 1 year ago 76
Android Question

FirebaseRecyclerAdapter blinks my row when it's updated

I'm using Firebase to create a chat app. I'm using a

from firebase-ui to display all messages. My problem is when someone like a message (as you can see below) the entire layout blinks. It happens if I change the message on Firebase Console as well. In my view holder I only update the heart image view according with my model. I'm using version 0.6.2 but it still happens on 1.0.0.

About my adapter, I extend
and because I'm using
I've overridden the following methods:

  • getItemViewType

  • populateViewHolder

  • onCreateViewHolder

enter image description here

class ChatMessageOutViewHolder extends RecyclerView.ViewHolder {

TextView messengerView;

ImageView heartView;

TextView likesView;

TextView timeView;

ChatMessageOutViewHolder(View v) {
ButterKnife.bind(this, v);

void apply(final ChatMessage model) {
likesView.setText(model.likes == null ? "" : String.valueOf(model.likes.size()));

Drawable image = ContextCompat.getDrawable(mContext, R.drawable.ic_fav_1);
if (model.likes != null && model.likes.contains(mUserId)) {
image = ContextCompat.getDrawable(mContext, R.drawable.ic_fav_2);

SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm", Locale.getDefault());
timeView.setText(simpleDateFormat.format(new Date(model.getTimeStamp())));

heartView.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (mListener != null) {

Answer Source

I figured out!! It's not a bug on FirebaseRecyclerAdapter. It's sounds like a default behaviour of RecyclerView. To solve it a just add the following lines after setup my local reference.

RecyclerView.ItemAnimator animator = mRecyclerView.getItemAnimator();
if (animator instanceof SimpleItemAnimator) {
    ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download