diff --git a/bubbleseekbar/src/main/java/com/xw/repo/BubbleSeekBar.java b/bubbleseekbar/src/main/java/com/xw/repo/BubbleSeekBar.java index ec03648..839f7c3 100644 --- a/bubbleseekbar/src/main/java/com/xw/repo/BubbleSeekBar.java +++ b/bubbleseekbar/src/main/java/com/xw/repo/BubbleSeekBar.java @@ -34,6 +34,7 @@ import android.view.animation.LinearInterpolator; import com.xw.repo.bubbleseekbar.R; +import com.xw.repo.exception.ProgressTextLengthException; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -1006,8 +1007,6 @@ public void onAnimationStart(Animator animation) { mWindowManager.addView(mBubbleView, mLayoutParams); } }).start(); - mBubbleView.setProgressText(isShowProgressInFloat ? - String.valueOf(getProgressFloat()) : String.valueOf(getProgress())); } /** @@ -1158,6 +1157,19 @@ private float processProgress() { return progress; } + public void setProgressText(@NonNull String text) throws ProgressTextLengthException { + if (text == null) { + throw new ProgressTextLengthException("Text can't be null"); + } + if (text.length() == 0) { + throw new ProgressTextLengthException("Text must have a content"); + } + if (text.length() > 5) { + throw new ProgressTextLengthException("The text is too long"); + } + mBubbleView.setProgressText(text); + } + public OnProgressChangedListener getOnProgressChangedListener() { return mProgressListener; } diff --git a/bubbleseekbar/src/main/java/com/xw/repo/exception/ProgressTextLengthException.java b/bubbleseekbar/src/main/java/com/xw/repo/exception/ProgressTextLengthException.java new file mode 100644 index 0000000..3984774 --- /dev/null +++ b/bubbleseekbar/src/main/java/com/xw/repo/exception/ProgressTextLengthException.java @@ -0,0 +1,8 @@ +package com.xw.repo.exception; + +public class ProgressTextLengthException extends Exception { + + public ProgressTextLengthException(String message) { + super(message); + } +}