cwac-pager icon indicating copy to clipboard operation
cwac-pager copied to clipboard

NPE at getCount()

Open BraunreutherA opened this issue 8 years ago • 1 comments

Hi thanks for the great lib. Sometimes there is a null pointer exception at the getCount() method. I don't understand why - so I added the stacktrace.

Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'int java.util.ArrayList.size()' on a null object reference at com.commonsware.cwac.pager.v4.ArrayPagerAdapter.getCount(ArrayPagerAdapter.java:79) at android.support.v4.view.ViewPager.dataSetChanged(ViewPager.java:1047) at android.support.v4.view.ViewPager$PagerObserver.onChanged(ViewPager.java:3113) at android.support.v4.view.PagerAdapter.notifyDataSetChanged(PagerAdapter.java:284) at com.commonsware.cwac.pager.v4.ArrayPagerAdapter.restoreState(ArrayPagerAdapter.java:182) at android.support.v4.view.ViewPager.onRestoreInstanceState(ViewPager.java:1481) at android.view.View.dispatchRestoreInstanceState(View.java:14856)

BraunreutherA avatar Jul 10 '17 08:07 BraunreutherA

The only way that could happen is if the saved instance state Bundle does not contain the array of PageDescriptor objects, yet we are restoring from that state. I have no idea how that could happen. If you are in position to create a reproducible test case for this, upload it and I can work on it.

commonsguy avatar Jul 10 '17 16:07 commonsguy