Delaying to load Firebase data using addListenerForSingleValueEvent Android

I am trying to display all the users that are registered in the app in a recycler view with the user's name, photo, registration number and dojo. This is my Firebase users: Firebase database users list

Then, I created a method that will take dataSnapshot and store all the users in a List all_users. After that, I'll just display the information in the recyclerView. Here is the code for this method:

public List<User> getUsers(DataSnapshot dataSnapshot){

    List<User> all_users = new ArrayList<>();

    // From all the users ID, it gets one by one.
    for (DataSnapshot ds: dataSnapshot.getChildren()){
        Log.i(TAG, "getUsers: " + ds);

        // Transform the value of the specific key to a User object and get its full name, birth_date...
        try {
            User user = new User();


            Log.i(TAG, "getUsers: " + user.toString());
            Log.i(TAG, "getUsers: " + all_users.toString());

        }catch (NullPointerException e){e.printStackTrace();}


    Log.i(TAG, "getUsers: " + all_users.toString());
    return all_users;


Now, I call this method in setupFirebaseAuth and then I setup the Recycler View. Here is the code for setupFirebaseAuth.

private void setupFirebaseAuth(){
    Log.i(TAG, "setupFirebaseAuth: Setting up firebase Auth");

    mAuth = FirebaseAuth.getInstance();
    firebaseMethods = new FirebaseMethods(getActivity());

    // Get a reference from the users field.
    myRef = FirebaseDatabase.getInstance().getReference().child(mContext.getString(R.string.dbname_users));
    myRef.addListenerForSingleValueEvent(new ValueEventListener() {
        public void onDataChange(DataSnapshot dataSnapshot) {
            // Show all the users node. Key = userID and Value = information (belt_color, birth_date...).
            Log.i(TAG, "onDataChange: " + dataSnapshot.getValue().toString());
            all_users = firebaseMethods.getUsers(dataSnapshot);

        public void onCancelled(DatabaseError databaseError) {
            // handle database error.


Conclusion, it works well, all the users are displayed in the fragment, the only problem is that it delays too much the first time it is loading and then when some data is changed. It delays around 30 seconds, eventhought I have just 5 users registered. Is there a way to make it load faster, or am I missing something?

If it is necessary, here is the code for the RecyclerAdapter

public class RecyclerAdapter extends RecyclerView.Adapter<ViewHolder> {

private List<User> users;
private Context mContext;

public RecyclerAdapter(List<User> users, Context mContext) {
    this.users = users;
    this.mContext = mContext;

public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

    View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.snippet_affiliates_recyclerview, parent, false);

    return new ViewHolder(view);


public void onBindViewHolder(ViewHolder holder, final int position) {

    User sampleUser = users.get(position);

    Log.i(TAG, "onBindViewHolder: " + sampleUser.getProfile_img_url());
            holder.circleImageView, null, "");

    holder.linearLayout_eachItem.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            Toast.makeText(mContext, "Item: " + (position + 1), Toast.LENGTH_SHORT).show();

public int getItemCount() {return users.size();}