I have got the Firebase database structure as shown in Image1. My code to retrieve all the children under the "Orders" node is as follows:
This is the AdminOrdersViewHolder class:
The problem with the above code is it returns all null values (as shown in Image2). In other words, model.getName(), model.getPhone(), model.getAddress(), model.getCity, model.getState, model.getPin(), model.getTotalAmount, model.getOrderDate & model.getOrderTime() return null values. Can someone please help me out with this?
Please note that in the first image, if the node "112226042020" is not present, the above code runs fine but the null values are returned after the node "112226042020" has got added. What could be the issue please?
Quick guess: Order of execution.
TLDR: At the time when the view is constructed the model hasn't populated yet. So, figure out the order (and timing) when the data are fetched and put into the model and change your code so it happens befor the view calls the getter.
posted 3 months ago
Thanks Bob for your suggestion but I guess that is not the issue. There are 2 reasons why I am saying so:
Firstly, as already stated in my post, the null values creep up only when the node "112226042020" is there but if it is not there, setText gets the correct values from Firebase. Secondly, there is a button as well in the AdminOrdersViewHolder class. When this button is clicked & the user selects one of the 2 options, then that item gets deleted from Firebase (even though all of them are nulls). So I don't think that is the issue. Any other suggestion please???
Thanks once again....
posted 3 months ago
debug debug debug - or in other words: what makes you so sure about that your assumptions that my idea is incorrect? have you really debugged it or do you just guess?
sadly I don'T know much about android development - but when something in a gui shows up as null it's most often of two reasons:
1) wrong order of execution / bad timing
2) gui updated from the wrong thread (not the EDT)