How come it doesn't show every structure, but only the first of the repeated list? What am I doing wrong?
I want to sort by desc rating
Here is the structure of the data in Firebase,
Structure
|
id_structure
|
rating: 7
final FirebaseRecyclerAdapter<Structure,StructureViewHolder> adapter=
new FirebaseRecyclerAdapter<Structure, StructureViewHolder>(options) {
@Override
protected void onBindViewHolder(@NonNull StructureViewHolder structureViewHolder, int i, @NonNull Structure structure) {
StructureRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
List<Structure> structureList=new ArrayList<>();
for(DataSnapshot d:dataSnapshot.getChildren()){
Structure structure=d.getValue(Structure.class);
structureList.add(structure);
}
Collections.reverse(structureList);
for(Structure s:structureList) {
structureViewHolder.structureRating.setText(String.format(Locale.ITALY, "%.1f", s.getRating()));
}
}
};