In my android app I am using FirestoreRecyclerAdapter
from firebase-UI which binds Query
and Model
. When app is off-line I need it to show nothing. But the app shows data from cache which is DEFAULT
according to docs
I also tried to .setPersistenceEnabled(false)
on FirestoreRecyclerOptions
which didn't help.
From this I figured out that I need to use get(Source.SERVER)
on Query
but I am not using get()
on my query
as I am using it in FirestoreRecyclerOptions
, which is used by FirestoreRecyclerAdapter
Here is my code which is basically same as in example app from firebaseui in lines 160-178.
Query query = FirebaseFirestore.getInstance()
.collection("files")
.orderBy("timestamp")
.limit(50);
FirestoreRecyclerOptions<FileToPrint> options = new FirestoreRecyclerOptions.Builder<FileToPrint>()
.setQuery(query, FileToPrint.class)
.build();
adapter = new FirestoreRecyclerAdapter<FileToPrint, FileToPrintHolder>(options) {
@Override
public void onBindViewHolder(FileToPrintHolder holder, int position, FileToPrint model) {
// Bind the Chat object to the ChatHolder
holder.bind(model);
}
@Override
public FileToPrintHolder onCreateViewHolder(ViewGroup group, int i) {
// Create a new instance of the ViewHolder, in this case we are using a custom
// layout called R.layout.message for each item
View view = LayoutInflater.from(group.getContext())
.inflate(R.layout.file_to_print_item, group, false);
return new FileToPrintHolder(view);
}
};
mRecyclerView.setAdapter(adapter);
When I disconnect the Internet I expect to see empty list, but instead I see this log:
Firestore: (21.0.0) [OnlineStateTracker]: Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds
This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.
and