I'm trying to load data from firebase to recyclerView using the code below but, I'm Having a problem when scrolling RecyclerView after scrolling down a lot of time successively, and that happened only in the first time when data load, i really don't know what's going wrong in my code please help!
Here it is a summarize of my onBindViewHolder :
holder.tvPhoneNumber.setText("");
holder.ivContactImage.setImageResource(R.color.avatar_color);
name = FirebaseDatabase.getInstance().getReference().child("Users").child(phoneNumberId);
name.keepSynced(true);
followListener = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if (dataSnapshot.child("status").exists()) {
nameData = dataSnapshot.child("status").getValue().toString();
holder.tvPhoneNumber.setText(nameData);
} else {
holder.tvPhoneNumber.setText("");
}
if (dataSnapshot.child("thumb_image").exists()) {
imageData = dataSnapshot.child("thumb_image").getValue().toString();
Picasso.with(mContext).load(imageData).resize(100, 100).placeholder(R.color.avatar_color)
.error(R.color.avatar_color).centerCrop().into(holder.ivContactImage);
} else {
holder.ivContactImage.setImageResource(R.color.avatar_color);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
};
name.addListenerForSingleValueEvent(followListener);
The problem is that i have this methode inside of my adapter class
@Override
public int getItemViewType(int position) {
if (position == contactList.size()){
return VIEW_TYPE2;
}else {
return VIEW_TYPE1;
}
}