Skip to content

Commit

Permalink
slideTo preconditions
Browse files Browse the repository at this point in the history
  • Loading branch information
PierfrancescoSoffritti committed Jul 1, 2016
1 parent a6c33e9 commit bff2fd6
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,11 @@ protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
* @param finalYNormalized Normalized value (between 0.0 and 1.0) representing the final slide position
*/
public void slideTo(float finalYNormalized) {
if(finalYNormalized == Float.NaN)
throw new IllegalArgumentException("Bad value. Can't slide to NaN");
if(finalYNormalized < 0 || finalYNormalized > 1)
throw new IllegalArgumentException("Bad value. Can't slide to " +finalYNormalized +". Value must be between 0 and 1");

ValueAnimator va = ValueAnimator.ofFloat(currentSlide, finalYNormalized);
va.setInterpolator(new DecelerateInterpolator(1.5f));
va.setDuration(300);
Expand Down

0 comments on commit bff2fd6

Please sign in to comment.