The RecyclerView
, unlike to ListView
, doesn\'t have a simple way to set an empty view to it, so one has to manage it manually, making empty view vi
There is a method in the ItemAnimator class that is called when all item animations are finished:
/**
* Method which returns whether there are any item animations currently running.
* This method can be used to determine whether to delay other actions until
* animations end.
*
* @return true if there are any item animations currently running, false otherwise.
*/
public abstract boolean isRunning();
You can override it to detect when all item animations have ended:
recyclerView.itemAnimator = object : DefaultItemAnimator() {
override fun isRunning(): Boolean {
val isAnimationRunning = super.isRunning()
if(!isAnimationRunning) {
// YOUR CODE
}
return isAnimationRunning
}
}