Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a method to make possible to set a text to show into the bubble #114

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions bubbleseekbar/src/main/java/com/xw/repo/BubbleSeekBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1006,8 +1007,6 @@ public void onAnimationStart(Animator animation) {
mWindowManager.addView(mBubbleView, mLayoutParams);
}
}).start();
mBubbleView.setProgressText(isShowProgressInFloat ?
String.valueOf(getProgressFloat()) : String.valueOf(getProgress()));
}

/**
Expand Down Expand Up @@ -1158,6 +1157,19 @@ private float processProgress() {
return progress;
}

public void setProgressText(@NonNull String text) throws ProgressTextLengthException {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The progress text will be updated only the text is not null, is not empty and length is less or equal than 5

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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.xw.repo.exception;

public class ProgressTextLengthException extends Exception {

public ProgressTextLengthException(String message) {
super(message);
}
}