If you try to set null adapter, it will throw NPE in RecyclerViewPagerAdapter's constructor at the .hasStableIds() call. But setting a null adapter is a perfectly correct usage, especially when your adapter has references to context and other dependencies. Nulling it out in the RecyclerViewPager prevents memory leaks. One way to be fixed is all overridden methods in RecyclerViewPagerAdapter to have proper null checks before accessing the wrapper adapter. But RecyclerViewPagerAdapter assumes the wrapper adapter is non-null.
Here's a reflection workaround for anyone interested:
If you try to set null adapter, it will throw NPE in
RecyclerViewPagerAdapter
's constructor at the.hasStableIds()
call. But setting a null adapter is a perfectly correct usage, especially when your adapter has references to context and other dependencies. Nulling it out in theRecyclerViewPager
prevents memory leaks. One way to be fixed is all overridden methods inRecyclerViewPagerAdapter
to have proper null checks before accessing the wrapper adapter. ButRecyclerViewPagerAdapter
assumes the wrapper adapter is non-null.Here's a reflection workaround for anyone interested:
p.s. You'll need also to add this in your ProGuard config: