I have an error using FirebaseRecyclerAdapter, at the time of retrieving the data the firebase has this error: " com.google.firebase.database.DatabaseException: Expected to List while deserializing, but got a class java.util. HashMap "
I saw that it is something related to reading the ID created for each clinic, I am automatically generating a key for each clinic. Can anyone help me with this? How do I retrieve the ids and display all the registered clinics on the firebase?
mFirebaseDatabase=FirebaseDatabase.getInstance();rootReference=mFirebaseDatabase.getReference().child("clinicas");
listaClinicas = new ArrayList<>();
}
@Override
protected void onStart() {
super.onStart();
FirebaseRecyclerAdapter<Clinicas, ViewHolder> firebaseRecyclerAdapter =
new FirebaseRecyclerAdapter<Clinicas, ViewHolder>(
Clinicas.class,
R.layout.adapter_lista_clinicas,
ViewHolder.class,
rootReference
) {
@Override
protected void populateViewHolder(final ViewHolder viewHolder, final Clinicas clinicas, int position) {
final String clinicasIds = getRef(position).getKey();
rootReference.child(clinicasIds).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
viewHolder.setDetails(getApplicationContext(), clinicas.getNomeClinica(), clinicas.getEnderecoClinica(),
clinicas.getBairroClinica(), clinicas.getEstadoCidadeClinica(), clinicas.getTelefoneClinica(), clinicas.getWhatsappClinica(),
clinicas.getFoto2());
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
};
mRecyclerView.setAdapter(firebaseRecyclerAdapter);
}