Let's say I have a RecyclerView
, and when it loads data from the databse, I want to do something. I'd imagine it like this:
recyclerView.setOnUpdateListener(new OnUpdateListener() {
@Override
public void onChanged() {
//I do whatever I want
}
};
What I've seen:
I've seen this link but the question isn't too clear; and neither is the answer as it doesn't explain what's it doing. And it's pretty old.
I've seen this but it isn't answered yet.
Why?
Because I am loading data from the Database, and I want to show a progress circle while it's loading, and dismiss it when data shows.
Note: I am using a FirebaseRecyclerAdapter
.
Use RecyclerView.AdapterDataObserver.
like this:
RecyclerView.Adapter adapter = ...
adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
@Override
public void onChanged() {
//Do some task.
}
});
recyclerView.setAdapter(adapter);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With