package com.frinder.frinder.views;


import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.frinder.frinder.R;
import com.frinder.frinder.dataaccess.UserFirebaseDas;
import com.frinder.frinder.model.Message;
import com.frinder.frinder.model.User;
import com.stfalcon.chatkit.messages.MessageHolders;

import butterknife.BindView;
import butterknife.ButterKnife;

public class IncomingMessageViewHolder extends MessageHolders.IncomingTextMessageViewHolder<Message> {

    @BindView(R.id.messageUserAvatar)
    ImageView messageUserAvatar;
    private Context mContext;
    private Message mCurrentMessage;

    private UserFirebaseDas mUserDas;

    public IncomingMessageViewHolder(View itemView) {
        super(itemView);
        ButterKnife.bind(this, itemView);
        mContext = itemView.getContext();

        mUserDas = new UserFirebaseDas(mContext);
    }

    @Override
    public void onBind(final Message message) {
        super.onBind(message);
        this.mCurrentMessage = message;
        mUserDas.getUser(message.senderId, new UserFirebaseDas.OnCompletionListener() {
            @Override
            public void onUserReceived(User user) {
                // Ensure that the ViewHolder is still at the same position
                if (message == mCurrentMessage) {
                    messageUserAvatar.setVisibility(View.VISIBLE);
                    Glide.with(mContext)
                            .load(user.getProfilePicUrl())
                            .centerCrop()
                            .into(messageUserAvatar);
                }
            }
        });
    }
}

@@ -1073,16 +1073,71 @@
 essage;%0A
+        messageUserAvatar.setVisibility(View.VISIBLE);%0A
         
@@ -1420,75 +1420,8 @@
 ) %7B%0A
-                    messageUserAvatar.setVisibility(View.VISIBLE);%0A
     

Fix message list image visibility