Firebase send Data

0

Good afternoon,

I have this problem, I am separating the project into layers and when I want to get the data and send it to the interface layer so that it shows up in recyclerView it returns empty, and I never load it and I have to use variables static and call them from the interface layer to load it, but that programming is not correct.

What can be the problem or what can be the solution?

I put the method that should return the ArrayList : ArrayList<amigo> listaAmigos;

public ArrayList<amigo> getAmigos(String email)
{
    String delimitadores = "@";
    String[] emailCortado =email.split(delimitadores);
    DatabaseReference amigos = ref.child("amigos").child(emailCortado[0]);
    amigos.addChildEventListener(new ChildEventListener() {

        @Override
        public void onChildAdded(DataSnapshot dataSnapshot, String s) {
            amigo sss = dataSnapshot.getValue(amigo.class);
            listaAmigos.add(sss);

        }

        @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) {

        }
    });

    return listaAmigos;
}

Thank you in advance, I await your response.

    
asked by Franco Londra 29.09.2016 в 14:11
source

1 answer

0

Good morning,

Firebase has a library FirebaseUI that includes FirebaseRecyclerAdapter plus a number of other things. In your case you could use this adapter for your recyclerView

Here you have a example in which you use different types of lists using the FirebaseUI library.

I hope you find it useful.

    
answered by 09.12.2016 в 13:51