-3
this.books = new ArrayList<>();
mFirebaseDatabaseReference.child(SellBooksPost).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot AdataSnapshot) {
for (final DataSnapshot AmessageSnapshot : AdataSnapshot.getChildren()) {
bFirebaseDatabaseReference.child(mUserId).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot BdataSnapshot) {
for (DataSnapshot BmessageSnapshot : BdataSnapshot.getChildren()) {
if (BmessageSnapshot.child("book").getValue().toString().equals(AmessageSnapshot.child("SellBooksPostId").getValue().toString())){
Log.d("INFO", "SELL BOOK book " + BmessageSnapshot.child("book").getValue());
Log.d("INFO", "SELL BOOK DETAIL " + AmessageSnapshot.child("SellBooksPostId").getValue());
books.add(new Book(
AmessageSnapshot.child("SellBooksPostId").getValue().toString(),
AmessageSnapshot.child("bookTitle").getValue().toString()
));
}
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
saleBookPostAdapter = new SaleBookPostAdapter(getApplicationContext(), books);
mRoomRecyclerView.setHasFixedSize(true);
mRoomRecyclerView.setAdapter(saleBookPostAdapter);
前後提供代碼的請求給問題 –