-
-
Save mozerian/4533361d40268fe469442e2f1bfdd798 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//function to fetch payment data from the database | |
private void fetchPaymentUsers() | |
{ | |
payRef.addValueEventListener(new ValueEventListener() { | |
@Override | |
public void onDataChange(DataSnapshot dataSnapshot) { | |
for (DataSnapshot snapshot : dataSnapshot.getChildren()) { | |
//creating an object and setting to displlay | |
Constants pays = new Constants(); | |
pays.setFirst_Name(snapshot.child("FirstName").getValue().toString()); | |
pays.setOther_Name(snapshot.child("OtherName").getValue().toString()); | |
pays.setPhone(snapshot.child("Phone").getValue().toString()); | |
//this just log details fetched from db(you can use Timber for logging | |
Log.d("Payment", "Name: " + pays.getFirst_Name()); | |
Log.d("Payment", "othername: " + pays.getOther_Name()); | |
Log.d("Payment", "phone: " + pays.getPhone()); | |
/* The error before was cause by giving incorrect data type | |
You were adding an object of type PaymentUsers yet the arraylist expects obejct of type DisabledUsers | |
*/ | |
paymentUsersList.add(pays); | |
} | |
//create a pdf file and catch exception beacause file may not be created | |
try { | |
createPaymentReport(paymentUsersList); | |
} catch (DocumentException | FileNotFoundException e) { | |
e.printStackTrace(); | |
} | |
} | |
@Override | |
public void onCancelled(DatabaseError databaseError) { | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment