this is my database structure.
order
key
address
cart node with 3 childs
phone
total etc
I have tried all the ways to get into the cart object that is created but when it gives me an error and when i try to retrieve it in a recyclerview it just returns the first "0" child nothing else. I have tried using hashmaps and arraylists and i have also given the recyclerview adapter to show the retrieval of data.
//this is my pojo below.
public class Order {
private String phone;
private String address;
private String time;
private String date;
private String message;
private String total;
private HashMap<String,Cart> cart;
private String tax;
private String status;
public Order() {
}
//getter and setter
//code for looping over the child node
orderDB.child("orders").child(currentUser).addValueEventListener(new
ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
if (dataSnapshot.exists()) {
for (DataSnapshot orderSnapshot : dataSnapshot.getChildren()) {
Order order = orderSnapshot.getValue(Order.class);
onGoingOrderList.add(order);
rvOnGoingOrders.setAdapter(onGoingOrderadapter);
}
}
}
//code for my adapter
public void onBindViewHolder(OngoingOrderViewholder holder, int position) {
holder.tvProductnameOngoingOrders.setText(onGoingOrderArrayList.get(position).getCart().get(position).getName());
this is the error that i am getting if i retrieve the data into a hashmap https://ibb.co/d8gJ6d