I'm Setting a Call log application that retrieve the data of Calls from one Firebase database Child and the name of the equivalent Contact from another Child. I can run the queries and they retrieve the data but don't know how to cast then to the same Adaptor.
I'm using Android Studio and Firebase realtime database with little experience in both. My best result is this:
public void onChildAdded(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {
Person personList = dataSnapshot.getValue(Person.class);
String nombre = dataSnapshot.child("mNumber").getValue().toString();
Query query = mFirebaseDatabase.getReference("Names")
.orderByChild(nombre);
query.addListenerForSingleValueEvent(
new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if (dataSnapshot.exists()) {
for (DataSnapshot snapshot : dataSnapshot.getChildren()) {
String artist = snapshot.getValue().toString();
Person personName = snapshot.getValue(Person.class);
mContactsAdapter.add(personName);
}
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
mContactsAdapter.add(personList);
}
This is how Firebase Realtime Database looks like
{
"Missed" : {
"-LmPZ-AOWIPSfEr-XK1v" : {
"mCheck" : "Check Out",
"mDate" : "16-08-19",
"mNumber" : "6505551212",
"mTime" : "15:13"
},
"-LmQGRvIYzAqqfmn94xU" : {
"mCheck" : "Check Out",
"mDate" : "16-08-19",
"mNumber" : "6505551213",
"mTime" : "18:32"
}
},
"Names" : {
"6505551212" : {
"mName" : "Bruce Wills"
},
"6505551213" : {
"mName" : "Peter Pan"
}
}
}
for now, the result looks like this
I want the same card to have the name AND the rest of the data.