Skip to content

Commit

Permalink
Getter and setter for visibleDotThreshold. Redraw view when dot count…
Browse files Browse the repository at this point in the history
… < visibleDotThreshold.
  • Loading branch information
Nikita Olifer committed Apr 28, 2018
1 parent 19fbc90 commit 4b04291
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,31 @@ public void setVisibleDotCount(int visibleDotCount) {
}
}

/**
* The minimum number of dots which should be visible.
* If pager has less pages than visibleDotThreshold, no dots will be shown.
*
* @return visible dot threshold.
*/
public int getVisibleDotThreshold() {
return visibleDotThreshold;
}

/**
* Sets the minimum number of dots which should be visible.
* If pager has less pages than visibleDotThreshold, no dots will be shown.
*
* @param visibleDotThreshold visible dot threshold.
*/
public void setVisibleDotThreshold(int visibleDotThreshold) {
this.visibleDotThreshold = visibleDotThreshold;
if (attachRunnable != null) {
reattach();
} else {
requestLayout();
}
}

/**
* Attaches indicator to ViewPager
*
Expand Down Expand Up @@ -435,6 +460,8 @@ private void initDots(int count) {
dotScale = new float[dotOffset.length];

if (count < visibleDotThreshold) {
requestLayout();
invalidate();
return;
}

Expand Down Expand Up @@ -492,6 +519,7 @@ private void scaleDotByOffset(int position, float offset) {

/**
* Interface for attaching to custom pagers.
*
* @param <T> custom pager's class
*/
public interface PagerAttacher<T> {
Expand Down

0 comments on commit 4b04291

Please sign in to comment.