I\'ve made a library that shows a fast-scroller for RecyclerView (here, in case anyone wants), and I want to decide when to show and when to hide the fa
I'm using the 'addOnGlobalLayoutListener' for this. Here is my example:
Definition of an interface to perform the action required after the load:
public interface RecyclerViewReadyCallback {
void onLayoutReady();
}
on the RecyclerView, I trigger the onLayoutReady method when the load is ready:
mRecyclerView.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
if (recyclerViewReadyCallback != null) {
recyclerViewReadyCallback.onLayoutReady();
}
recyclerViewReadyCallback = null;
});
Note: The set to null is necessary to prevent the method from being called multiple times.