//here, you could use queueListView.add() too
@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.queue_list, container, false);
        //Instantiate Firebase objects
        mDatabase = FirebaseDatabase.getInstance(); //instance of Firebase object(i.e. database root object)
        mDepositQueueReference = mDatabase.getReference("depositQueue"); //reference to depositQueue child object in root object
        //Instantiate other variables
        queueListView = rootView.findViewById(R.id.list);
        loadingIndicator = rootView.findViewById(R.id.loading_indicator);
        final List<Payment> paymentsList = new ArrayList<Payment>();
        postAdapter = new QueueAdapter(getActivity(), R.layout.queue_view, paymentsList);
        queueListView.setAdapter(postAdapter);
        /**Delete this post adapter when you finish*/
//        postAdapter.add(new Payment("James Blunt", "0149603509", "4500", "WAEC", "07033513241", "igwenus619@gmail.com"));
        //Add ChildEventListener, so that changes made in the database are reflected
        mChildEventListener = new ChildEventListener() {
            @Override
            public void onChildAdded(DataSnapshot dataSnapshot, String s) {
                if (dataSnapshot.exists()) {
                    loadingIndicator.setVisibility(View.GONE);
                    Payment payment = dataSnapshot.getValue(Payment.class);
                    /**Uncomment this when you've finished*/
                    postAdapter.add(payment); //here, you could use queueListView.add() too
                }
            }
            @Override
            public void onChildChanged(DataSnapshot dataSnapshot, String s) {
            }
            @Override
            public void onChildRemoved(DataSnapshot dataSnapshot) {
            }
            @Override
            public void onChildMoved(DataSnapshot dataSnapshot, String s) {
            }
            @Override
            public void onCancelled(DatabaseError databaseError) {
                Log.e(TAG, "postComments:onCancelled", databaseError.toException());
            }
        };
        mDepositQueueReference.addChildEventListener(mChildEventListener);
        queueListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Payment payment = paymentsList.get(position);
                Intent intent = new Intent(getActivity(), ConfirmDetailsActivity.class);
                intent.putExtra("pushID", payment.getPushID());
                intent.putExtra("accountName", payment.getAccountName());
                intent.putExtra("accountNumber", payment.getAccountNumber());
                intent.putExtra("depositAmount", payment.getDepositAmount());
                intent.putExtra("depositorName", payment.getDepositorName());
                intent.putExtra("depositorPhoneNumber", payment.getDepositorPhoneNumber());
                intent.putExtra("depositorEmail", payment.getDepositorEmail());
                Log.e(TAG, "Phone Number" + payment.depositorPhoneNumber);
                startActivity(intent);
            }
        });
        return rootView;
    }
Payment payment = dataSnapshot.getValue(Payment.class);
/**Uncomment this when you've finished*/
postAdapter.add(payment); //here, you could use queueListView.add() too
}
}
/**Delete this post adapter when you finish*/
// postAdapter.add(new Payment("James Blunt", "0149603509", "4500", "WAEC", "07033513241", "igwenus619@gmail.com"));
//Add ChildEventListener, so that changes made in the database are reflected
mChildEventListener = new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
if (dataSnapshot.exists()) {
loadingIndicator.setVisibility(View.GONE);
Payment payment = dataSnapshot.getValue(Payment.class);
/**Uncomment this when you've finished*/
postAdapter.add(payment); //here, you could use queueListView.add() too
}
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
View rootView = inflater.inflate(R.layout.queue_list, container, false);
//Instantiate Firebase objects
mDatabase = FirebaseDatabase.getInstance(); //instance of Firebase object(i.e. database root object)
mDepositQueueReference = mDatabase.getReference("depositQueue"); //reference to depositQueue child object in root object
//Instantiate other variables
queueListView = rootView.findViewById(R.id.list);
loadingIndicator = rootView.findViewById(R.id.loading_indicator);
final List<Payment> paymentsList = new ArrayList<Payment>();
postAdapter = new QueueAdapter(getActivity(), R.layout.queue_view, paymentsList);
queueListView.setAdapter(postAdapter);
/**Delete this post adapter when you finish*/
// postAdapter.add(new Payment("James Blunt", "0149603509", "4500", "WAEC", "07033513241", "igwenus619@gmail.com"));
//Add ChildEventListener, so that changes made in the database are reflected
mChildEventListener = new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
if (dataSnapshot.exists()) {
loadingIndicator.setVisibility(View.GONE);
Payment payment = dataSnapshot.getValue(Payment.class);
/**Uncomment this when you've finished*/
postAdapter.add(payment); //here, you could use queueListView.add() too
}
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
Log.e(TAG, "postComments:onCancelled", databaseError.toException());
}
};
mDepositQueueReference.addChildEventListener(mChildEventListener);
queueListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {