DavidPacioianu/InkPageIndicator

Page count could be zero which causes crash

Opened this issue · 1 comments

yllow commented

I was working on dynamic view pager. Since the library is listening to the adapter changes, i notice that there is a function called reset state where the pageCount - 1 should handle properly as the page count could go to zero.

I've fixed this quite simply. Just change the first line of resetState() method to:

private void resetState() {
        joiningFractions = new float[pageCount == 0 ? 0 : (pageCount - 1)];

the default implementation is:

joiningFractions = new float[pageCount - 1];

and it caused exception when pageCount was 0