How To See If Firestorerecycleradapter Is Empty?
I would like to know how is it possible to discover when FirestoreRecyclerAdapter is ONLY empty. With the following code, I can discover if it has one or more instances into it, bu
Solution 1:
Override onDataChanged() and check in it
FirestoreRecyclerAdapter<Spots, SpotViewHolder> adapter = new FirestoreRecyclerAdapter<Spots, SpotViewHolder>(options) {
@Override
protected void onBindViewHolder(@NonNull SpotViewHolder spotViewHolder, int i, @NonNull Spots spots) {
//...
}
@NonNull
@Override
public SpotViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
//...
}
// Add this
@Override
public void onDataChanged() {
// do your thing
if(getItemCount() == 0)
Toast.makeText(getContext(), "Empty", Toast.LENGTH_SHORT).show();
}
};
Post a Comment for "How To See If Firestorerecycleradapter Is Empty?"