Categories

See More
Popular Forum

MBA (4887) B.Tech (1769) Engineering (1486) Class 12 (1030) Study Abroad (1004) Computer Science and Engineering (988) Business Management Studies (865) BBA (846) Diploma (746) CAT (651) B.Com (648) B.Sc (643) JEE Mains (618) Mechanical Engineering (574) Exam (525) India (462) Career (452) All Time Q&A (439) Mass Communication (427) BCA (417) Science (384) Computers & IT (Non-Engg) (383) Medicine & Health Sciences (381) Hotel Management (373) Civil Engineering (353) MCA (349) Tuteehub Top Questions (348) Distance (340) Colleges in India (334)
See More

Having trouble receiving new data from firebase?

General Tech Bugs & Fixes

Max. 2000 characters
Replies

usr_profile.png

User

( 6 months ago )

Having trouble receiving new data from firebase?

 

 

 

 

 

 

 

 

 

 

 

 

 

I am running my app and adding a new child to firebase, online you can see all the child's values, but the data snapshot only gets the first value of the new child added.

we tried reading the child values each one separately, but it seems like the data snapshot doesn't even know they exist.

public static void NotifyToTripList(final NotifyDataChange<List<Trip>> notifyDataChange) {
    if (notifyDataChange != null) {
        if (tripRefChildEventListener != null) {
            notifyDataChange.onFailure(new Exception("first unNotify trip list"));
            return;
        }

        tripList.clear();
        tripRefChildEventListener = new ChildEventListener() {
            @override
            public void onChildAdded(DataSnapshot dataSnapshot, String s) {                   
                Trip t=new Trip();
                t.setTripID(dataSnapshot.getKey());
                if(dataSnapshot.child("DriverID").getValue()!=null) t.setDriverID(Long.parseLong(dataSnapshot.child("DriverID").getValue().toString()));
                else t.setDriverID(0L);
                t.setDestination(dataSnapshot.child("Destination").getValue().toString());
                t.setCurrentLocation(dataSnapshot.child("CurrentLocation").getValue().toString());
                t.setPassengerEmail(dataSnapshot.child("PassengerEmail").getValue().toString());
                t.setPassengerNumber(dataSnapshot.child("PassengerNumber").getValue().toString());
                t.setPassengerName(dataSnapshot.child("PassengerName").getValue().toString());
                SimpleDateFormat format = new SimpleDateFormat("HH:mm"); 
                tripList.add(t);
                notifyDataChange.OnDataChanged(tripList);
        }
    }
}

the code from the main menu:

FireBaseDataBase.NotifyToTripList(new FireBaseDataBase.NotifyDataChange<List<Trip>>() {
    

what's your interest