Open mwandotheboss opened 5 years ago
@Override protected void onStart() { super.onStart(); FirebaseRecyclerOptions<FindParents> options = new FirebaseRecyclerOptions.Builder<FindParents>() .setQuery(chatsReference, FindParents.class) .build(); FirebaseRecyclerAdapter<FindParents, allChatsViewHolder> adapter = new FirebaseRecyclerAdapter<FindParents, allChatsViewHolder>(options) { @Override protected void onBindViewHolder(@NonNull allChatsViewHolder allChatsViewHolder, int position, @NonNull FindParents findParents) { //get the user ID of each of the users message in the messages node final String usersIDs = getRef(position).getKey(); usersReference.child(usersIDs).addValueEventListener(new ValueEventListener() { @Override public void onDataChange(@NonNull DataSnapshot dataSnapshot) { if (dataSnapshot.hasChild("profileImage")){ final String retrieveProfileImage = dataSnapshot.child("profileImage").getValue().toString(); //display profile picture Picasso.get() .load(retrieveProfileImage) .placeholder(R.drawable.profile_image_placeholder) .into(allChatsViewHolder.allChatsProfileImage); } final String retrieveUserFullName = dataSnapshot.child("fullName").getValue().toString(); final String retrieveUserStatus = dataSnapshot.child("status").getValue().toString(); //now display the values allChatsViewHolder.allChatsUserName.setText(retrieveUserFullName); allChatsViewHolder.allChatsUserStatus.setText("Last Seen: " + "\n " + "Date" + " Time"); } @Override public void onCancelled(@NonNull DatabaseError databaseError) { } }); } @NonNull @Override public allChatsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View view = LayoutInflater .from(parent.getContext()) .inflate(R.layout.all_chats_display_layout, parent, false); return new allChatsViewHolder(view); } }; allChatsList.setAdapter(adapter); allChatsList.setLayoutManager(new LinearLayoutManager(this)); adapter.startListening(); }
private static class allChatsViewHolder extends RecyclerView.ViewHolder{
CircleImageView allChatsProfileImage; TextView allChatsUserStatus; TextView allChatsUserName; public allChatsViewHolder(@NonNull View itemView) { super(itemView); allChatsProfileImage = itemView.findViewById(R.id.all_chats_profile_image); allChatsUserName = itemView.findViewById(R.id.all_chats_profile_full_name); allChatsUserStatus = itemView.findViewById(R.id.all_chats_profile_status); } }
Please refer the snippet of my code from app Click here
Thanks let me try
Is it possible you identify the error mistake in my code? I still cannot figure it out from your code
private static class allChatsViewHolder extends RecyclerView.ViewHolder{