luke cross
luke cross

Reputation: 331

FirestorePagingAdapter not update Firestore data when fields changed?

currently i'm using the FirestoreRecyclerAdapter and FirestoreRecyclerOptions and his can listening the data updates, but this method consumes much data, so, i'm tried using FirestorePagingOptions and FirestorePagingAdapter, he's can paginate the data and got economy of date, but, when the data is updated not happens with RecyclerView methods, i'm have adapter.startListening(), but, didn't work.

This work very fine, but, the data consumed is strong.

public class AnuncioAdapter extends FirestoreRecyclerAdapter<AnuncioPrincipal, AnuncioAdapter.AnuncioHolder> {

    public AnuncioAdapter(FirestoreRecyclerOptions<AnuncioPrincipal> options)
    {
        super(options);
    }

The method work fine to economy, but, not update...

public class AnuncioAdapter extends FirestorePagingAdapter<AnuncioPrincipal, AnuncioAdapter.AnuncioHolder> {

    public AnuncioAdapter(FirestorePagingOptions<AnuncioPrincipal> options)
    {
        super(options);
    }

Upvotes: 1

Views: 428

Answers (2)

Adeyemi Seun
Adeyemi Seun

Reputation: 111

Its simple

  1. Do You Simple FirestorePagingAdapter in a method e.g loadAdapter()
  2. Now do Normal Listener and call loadAdapter() to reload for every changes.

Upvotes: 0

Frank van Puffelen
Frank van Puffelen

Reputation: 598728

The FirebaseUI paging adapter does not use real-time listeners. According to the documentation:

The FirestorePagingAdapter binds a Query to a RecyclerView by loading documents in pages. This results in a time and memory efficient binding, however it gives up the real-time events afforted [sic] by the FirestoreRecyclerAdapter.

So you'll have to choose: either you can have real-time updates, or you can have pagination, but you can't have both with the adapters that come with FirebaseUI.

Upvotes: 4

Related Questions