From ac6fdbe4e529d6006f38c0a5d52786435d8a50de Mon Sep 17 00:00:00 2001 From: Lucas Bicca Date: Wed, 28 Feb 2018 23:50:56 -0300 Subject: [PATCH 1/3] Adding a method to make possible to set a text to show into the bubble --- .../src/main/java/com/xw/repo/BubbleSeekBar.java | 11 +++++++++++ .../repo/exception/ProgressTextLengthException.java | 8 ++++++++ 2 files changed, 19 insertions(+) create mode 100644 bubbleseekbar/src/main/java/com/xw/repo/exception/ProgressTextLengthException.java diff --git a/bubbleseekbar/src/main/java/com/xw/repo/BubbleSeekBar.java b/bubbleseekbar/src/main/java/com/xw/repo/BubbleSeekBar.java index ec03648..011a276 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; @@ -1158,6 +1159,16 @@ private float processProgress() { return progress; } + public void setProgressText(@NonNull String text) throws ProgressTextLengthException { + 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); + } +} From 9490a64325a2333a6eec380f50925d13fe581849 Mon Sep 17 00:00:00 2001 From: Lucas Bicca Date: Thu, 1 Mar 2018 00:26:02 -0300 Subject: [PATCH 2/3] Validanting if the text is null --- bubbleseekbar/src/main/java/com/xw/repo/BubbleSeekBar.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bubbleseekbar/src/main/java/com/xw/repo/BubbleSeekBar.java b/bubbleseekbar/src/main/java/com/xw/repo/BubbleSeekBar.java index 011a276..9407abb 100644 --- a/bubbleseekbar/src/main/java/com/xw/repo/BubbleSeekBar.java +++ b/bubbleseekbar/src/main/java/com/xw/repo/BubbleSeekBar.java @@ -1160,6 +1160,9 @@ private float processProgress() { } 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"); } From 39a401c91a19d49908dcc272680a3a4ed676ff9d Mon Sep 17 00:00:00 2001 From: Lucas bicca Date: Tue, 20 Mar 2018 16:47:30 -0300 Subject: [PATCH 3/3] The setProgressText was removed from showBubble() --- bubbleseekbar/src/main/java/com/xw/repo/BubbleSeekBar.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/bubbleseekbar/src/main/java/com/xw/repo/BubbleSeekBar.java b/bubbleseekbar/src/main/java/com/xw/repo/BubbleSeekBar.java index 9407abb..839f7c3 100644 --- a/bubbleseekbar/src/main/java/com/xw/repo/BubbleSeekBar.java +++ b/bubbleseekbar/src/main/java/com/xw/repo/BubbleSeekBar.java @@ -1007,8 +1007,6 @@ public void onAnimationStart(Animator animation) { mWindowManager.addView(mBubbleView, mLayoutParams); } }).start(); - mBubbleView.setProgressText(isShowProgressInFloat ? - String.valueOf(getProgressFloat()) : String.valueOf(getProgress())); } /**