dimanche 25 mars 2018

Firebase Firestone Random Document from Database

Here is my Firebase FireStone Database Structure:

MainPosts

-7YBc5LhUwU2wQB4ZybOl -

-IcInT5YEPKL2TVSAADP2

-tiUCi5IUuuCA2BT5Ldda

This is my Code:

firebaseFirestore.collection("MainPosts").addSnapshotListener(SingleVideoActivity.this, new EventListener<QuerySnapshot>() {
        @Override
        public void onEvent(QuerySnapshot documentSnapshots, FirebaseFirestoreException e) {

            for (DocumentChange doc : documentSnapshots.getDocumentChanges()) {
                if (doc.getType() == DocumentChange.Type.ADDED) {
                    String blogPostId = doc.getDocument().getId();

                    BlogPost blogPost = doc.getDocument().toObject(BlogPost.class).withId(blogPostId);

                    blog_list.add(blogPost);
                    blogListRecyclerAdapter.notifyDataSetChanged();
                }
            }

        }
    });

What i want to do to get random document like from this three :-

-7YBc5LhUwU2wQB4ZybOl

-IcInT5YEPKL2TVSAADP2

-tiUCi5IUuuCA2BT5Ldda




Aucun commentaire:

Enregistrer un commentaire