ManuelPeinado / MultiChoiceAdapter

Android - A ListView adapter with support for multiple choice modal selection
Apache License 2.0
849 stars 260 forks source link

Fix crash when first loading AlphabetIndexer sample #11

Closed intrications closed 11 years ago

intrications commented 11 years ago

On Google Edition HTC One, the AlphabetIndexer sample crashes the first time it is opened:

    E  android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
                    E   at android.database.AbstractCursor.checkPosition(AbstractCursor.java:430)
                    E   at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:136)
                    E   at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:50)
                    E   at android.database.CursorWrapper.getString(CursorWrapper.java:118)
                    E   at android.widget.AlphabetIndexer.getSectionForPosition(AlphabetIndexer.java:258)
                    E   at com.manuelpeinado.multichoiceadapter.demo.alphabetindexersample.AlphabetIndexerCursorAdapter.getSectionForPosition(AlphabetIndexerCursorAdapter.j
                       ava:93)
                    E   at android.widget.FastScroller.getThumbPositionForListPosition(FastScroller.java:647)
                    E   at android.widget.FastScroller.onScroll(FastScroller.java:457)
                    E   at android.widget.AbsListView.invokeOnItemScrollListener(AbsListView.java:1452)
                    [.....]

Not sure this is the best way to fix it but it did stop the crash.

ManuelPeinado commented 11 years ago

There is something weird going on with the content provider / loader. I'm not sure what it is, but your change set does indeed provide a workaround. Thanks a lot!