RecyclerView
's LayoutManager
class defines a function called onAdapterChanged()
. If you call RecyclerView.setAdapter()
when a LayoutManager
is already attached, LayoutManager.onAdapterChanged()
gets called as expected.
However, if you call RecyclerView.setAdapter()
before you attach the LayoutManager
, onAdapterChanged()
doesn't fire when you do attach it, meaning there doesn't seem to be a way for a late-attached LayoutManager
to get the currently-attached Adapter.
This surprised me as I thought it would call it, passing 'null' for oldAdapter
, but that isn't the case.
So, barring things like explicitly passing an adapter to the LayoutManager
ourselves, is there anything in the current API which would expose the current Adapter
to a LayoutManager
?