I am altering a recyclerview and would like to be notified of when that update is finished. I read How to know when the RecyclerView has finished laying down the items? that you are notified in the callback to addOnGlobalLayoutListener, but that is called too many times unless you add the last line.
Here is what I tried:
my_rv.viewTreeObserver.addOnGlobalLayoutListener {
calculate(myAdapter.getItems())
my_rv.viewTreeObserver.removeOnGlobalLayoutListener(this)
}
in order for the last line to compile, my fragment needs to override onGlobalLayout. What am I supposed to put in onGlobalLayout? I never see that callback even called.