Skip to content

Commit fbfb731

Browse files
Fixes bug: seek bar not responding to click events
1 parent ee4d13c commit fbfb731

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

rangebar/src/com/appyvet/rangebar/RangeBar.java

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,7 @@ public void setPinColor(int pinColor) {
592592
mPinColor = pinColor;
593593
createPins();
594594
}
595+
595596
/**
596597
* Set the color of the text within the pin.
597598
*
@@ -705,12 +706,12 @@ public int getTickCount() {
705706
public void setRangePinsByIndices(int leftPinIndex, int rightPinIndex) {
706707
if (indexOutOfRange(leftPinIndex, rightPinIndex)) {
707708
Log.e(TAG,
708-
"Pin index left " + leftPinIndex + ", or right "+rightPinIndex
709+
"Pin index left " + leftPinIndex + ", or right " + rightPinIndex
709710
+ " is out of bounds. Check that it is greater than the minimum ("
710711
+ mTickStart + ") and less than the maximum value ("
711712
+ mTickEnd + ")");
712713
throw new IllegalArgumentException(
713-
"Pin index left " + leftPinIndex + ", or right "+rightPinIndex
714+
"Pin index left " + leftPinIndex + ", or right " + rightPinIndex
714715
+ " is out of bounds. Check that it is greater than the minimum ("
715716
+ mTickStart + ") and less than the maximum value ("
716717
+ mTickEnd + ")");
@@ -778,15 +779,15 @@ public void setSeekPinByIndex(int pinIndex) {
778779
public void setRangePinsByValue(float leftPinValue, float rightPinValue) {
779780
if (valueOutOfRange(leftPinValue, rightPinValue)) {
780781
Log.e(TAG,
781-
"Pin value left " + leftPinValue + ", or right "+rightPinValue
782+
"Pin value left " + leftPinValue + ", or right " + rightPinValue
782783
+ " is out of bounds. Check that it is greater than the minimum ("
783784
+ mTickStart + ") and less than the maximum value ("
784785
+ mTickEnd + ")");
785786
throw new IllegalArgumentException(
786-
"Pin value left " + leftPinValue + ", or right "+rightPinValue
787-
+ " is out of bounds. Check that it is greater than the minimum ("
788-
+ mTickStart + ") and less than the maximum value ("
789-
+ mTickEnd + ")");
787+
"Pin value left " + leftPinValue + ", or right " + rightPinValue
788+
+ " is out of bounds. Check that it is greater than the minimum ("
789+
+ mTickStart + ") and less than the maximum value ("
790+
+ mTickEnd + ")");
790791
} else {
791792
if (mFirstSetTickCount) {
792793
mFirstSetTickCount = false;
@@ -876,14 +877,13 @@ public double getTickInterval() {
876877
}
877878

878879
@Override
879-
public void setEnabled(boolean enabled){
880-
if(!enabled) {
880+
public void setEnabled(boolean enabled) {
881+
if (!enabled) {
881882
mBarColor = DEFAULT_BAR_COLOR;
882883
mConnectingLineColor = DEFAULT_BAR_COLOR;
883884
mCircleColor = DEFAULT_BAR_COLOR;
884885
mTickColor = DEFAULT_BAR_COLOR;
885-
}
886-
else{
886+
} else {
887887
mBarColor = mActiveBarColor;
888888
mConnectingLineColor = mActiveConnectingLineColor;
889889
mCircleColor = mActiveCircleColor;
@@ -1147,11 +1147,9 @@ private void onActionUp(float x, float y) {
11471147
float leftThumbXDistance = mIsRangeBar ? Math.abs(mLeftThumb.getX() - x) : 0;
11481148
float rightThumbXDistance = Math.abs(mRightThumb.getX() - x);
11491149

1150-
if (leftThumbXDistance < rightThumbXDistance) {
1151-
if (mIsRangeBar) {
1152-
mLeftThumb.setX(x);
1153-
releasePin(mLeftThumb);
1154-
}
1150+
if (leftThumbXDistance < rightThumbXDistance && mIsRangeBar) {
1151+
mLeftThumb.setX(x);
1152+
releasePin(mLeftThumb);
11551153
} else {
11561154
mRightThumb.setX(x);
11571155
releasePin(mRightThumb);
@@ -1278,8 +1276,8 @@ public void onAnimationUpdate(ValueAnimator animation) {
12781276
*/
12791277
private String getPinValue(int tickIndex) {
12801278
float tickValue = (tickIndex == (mTickCount - 1))
1281-
? mTickEnd
1282-
: (tickIndex * mTickInterval) + mTickStart;
1279+
? mTickEnd
1280+
: (tickIndex * mTickInterval) + mTickStart;
12831281
String xValue = mTickMap.get(tickValue);
12841282
if (xValue == null) {
12851283
if (tickValue == Math.ceil(tickValue)) {
@@ -1319,6 +1317,6 @@ private void movePin(PinView thumb, float x) {
13191317
public static interface OnRangeBarChangeListener {
13201318

13211319
public void onRangeChangeListener(RangeBar rangeBar, int leftPinIndex,
1322-
int rightPinIndex, String leftPinValue, String rightPinValue);
1320+
int rightPinIndex, String leftPinValue, String rightPinValue);
13231321
}
13241322
}

0 commit comments

Comments
 (0)