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

Remove state number limit #58

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Refactor & suppress warnings
adrien1018 committed Feb 22, 2021
commit d195fe9a05c126104c0a6a9ad61b6ab18c9aa57a
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@
* Created by Kofi Gyan on 4/19/2016.
*/

@SuppressWarnings({"DanglingJavadoc", "unused", "RedundantSuppression"})
public class StateProgressBar extends View {


@@ -74,7 +75,7 @@ public class StateProgressBar extends View {
private static final String IS_STATE_NUMBER_DESCENDING_KEY = "mIsStateNumberDescending";
private static final String INSTANCE_STATE = "saved_instance";

private ArrayList<String> mStateDescriptionData = new ArrayList<String>();
private ArrayList<String> mStateDescriptionData = new ArrayList<>();

private float mStateRadius;
private float mStateSize;
@@ -592,6 +593,7 @@ public boolean isDescriptionMultiline() {
}


@SuppressWarnings("SameParameterValue")
private void updateDescriptionMultilineStatus(boolean multiline) {
mIsDescriptionMultiline = multiline;
}
@@ -743,16 +745,18 @@ public boolean performClick() {


private boolean isPointInCircle(int clickX, int clickY) {
boolean isTouched = false;
for (int i = 0; i < mMaxStateNumber; i++) {
isTouched = (!(clickX < mCellWidth * (i + 1) - (mCellWidth / 2) - mStateRadius || clickX > mCellWidth * (i + 1) - (mCellWidth / 2) + mStateRadius || clickY < mCellHeight / 2 - mStateRadius || clickY > mCellHeight / 2 + mStateRadius));
boolean isTouched = (!(clickX < mCellWidth * (i + 1) - (mCellWidth / 2) - mStateRadius ||
clickX > mCellWidth * (i + 1) - (mCellWidth / 2) + mStateRadius ||
clickY < mCellHeight / 2 - mStateRadius ||
clickY > mCellHeight / 2 + mStateRadius));
if (isTouched) {
mStateItemClickedNumber = mIsStateNumberDescending ? mMaxStateNumber - i : i + 1;
return isTouched;
return true;
}

}
return isTouched;
return false;
}


@@ -809,7 +813,7 @@ private StateItem getStateItem(int stateItemClickedNumber) {
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);

mCellWidth = getWidth() / mMaxStateNumber;
mCellWidth = (float)getWidth() / mMaxStateNumber;
mNextCellWidth = mCellWidth;
}

@@ -854,23 +858,22 @@ private int getCellHeight() {


private boolean checkForDescriptionMultiLine(ArrayList<String> stateDescriptionData) {
boolean isMultiLine = false;
for (String stateDescription : stateDescriptionData) {
isMultiLine = stateDescription.contains(STATE_DESCRIPTION_LINE_SEPARATOR);
boolean isMultiLine = stateDescription.contains(STATE_DESCRIPTION_LINE_SEPARATOR);
if (isMultiLine) {
updateDescriptionMultilineStatus(isMultiLine);
return isMultiLine;
updateDescriptionMultilineStatus(true);
return true;
}
}
return isMultiLine;
return false;
}


private int getMaxDescriptionLine(List<String> stateDescriptionData) {
int maxLine = 1;
for (String stateDescription : stateDescriptionData) {
int lineSize = stateDescription.split(STATE_DESCRIPTION_LINE_SEPARATOR).length;
maxLine = lineSize > maxLine ? lineSize : maxLine;
maxLine = Math.max(lineSize, maxLine);
}
mMaxDescriptionLine = maxLine;
return maxLine;
@@ -1198,7 +1201,7 @@ private Paint selectPaintType(int currentState, int statePosition, boolean check
Paint backgroundPaint = mIsStateNumberDescending ? mStateNumberForegroundPaint : mStateNumberBackgroundPaint;

if (checkStateCompleted) {
return applyCheckStateCompletedPaintType(currentState, statePosition, checkStateCompleted);
return applyCheckStateCompletedPaintType(currentState, statePosition, true);
} else {
if (statePosition + 1 == currentState || statePosition + 1 < currentState) {
return foregroundPaint;
@@ -1210,6 +1213,7 @@ private Paint selectPaintType(int currentState, int statePosition, boolean check
}


@SuppressWarnings("SameParameterValue")
private Paint applyCheckStateCompletedPaintType(int currentState, int statePosition, boolean checkStateCompleted) {
if (checkStateCompleted(currentState, statePosition, checkStateCompleted)) {
return mStateCheckedForegroundPaint;
@@ -1223,15 +1227,10 @@ private Paint applyCheckStateCompletedPaintType(int currentState, int statePosit

private boolean checkStateCompleted(int currentState, int statePosition, boolean checkStateCompleted) {
if (!mIsStateNumberDescending) {
if ((mEnableAllStatesCompleted && checkStateCompleted) || (statePosition + 1 < currentState && checkStateCompleted)) {
return true;
}
return (mEnableAllStatesCompleted && checkStateCompleted) || (statePosition + 1 < currentState && checkStateCompleted);
} else {
if ((mEnableAllStatesCompleted && checkStateCompleted) || (statePosition + 1 > currentState + 1 && checkStateCompleted)) {
return true;
}
return (mEnableAllStatesCompleted && checkStateCompleted) || (statePosition + 1 > currentState + 1 && checkStateCompleted);
}
return false;
}


@@ -1259,7 +1258,7 @@ private void stopAnimation() {


private class Animator implements Runnable {
private Scroller mScroller;
private final Scroller mScroller;
private boolean mRestartAnimation = false;

public Animator() {