Permalink
Browse files

Fix underline draw attempt being made on pages that might not exist. …

…Refs #50.
  • Loading branch information...
1 parent 9fe68ae commit 8aab6c904e6fdc384ac15d6ce2100412843fdf3a @JakeWharton JakeWharton committed Jan 26, 2012
Showing with 4 additions and 3 deletions.
  1. +4 −3 library/src/com/viewpagerindicator/TitlePageIndicator.java
@@ -321,10 +321,11 @@ protected void onDraw(Canvas canvas) {
//Calculate views bounds
ArrayList<RectF> bounds = calculateAllBounds(mPaintText);
+ final int boundsSize = bounds.size();
//Make sure we're on a page that still exists
- if (mCurrentPage >= bounds.size()) {
- setCurrentItem(bounds.size()-1);
+ if (mCurrentPage >= boundsSize) {
+ setCurrentItem(boundsSize - 1);
}
final int countMinusOne = count - 1;
@@ -445,7 +446,7 @@ protected void onDraw(Canvas canvas) {
break;
case Underline:
- if (!currentSelected) {
+ if (!currentSelected || page >= boundsSize) {
break;
}

0 comments on commit 8aab6c9

Please sign in to comment.