oli107 / material-range-bar

Android widget for selecting a range of values.
Apache License 2.0
1.68k stars 370 forks source link

Clicking on the range-bar to the left of the pins while the values are equal moves the wrong pin #126

Open mdpearce opened 6 years ago

mdpearce commented 6 years ago

Currently on the range bar, if the pins are both set to the same value and the user clicks on the bar to the left of the pins, the right pin would move to the click position instead of the left. This means that the right pin is actually to the left of the left pin.

I have created https://github.com/oli107/material-range-bar/pull/125 to address the issue.

PJHaynes304 commented 6 years ago

@mdpearce +1 Can confirm this after running into an issue... Printing pin index when clicking on rangeBar to the left of pins :- I/System.out: LeftPinIndex: 2 RightPinIndex: 2 I/System.out: LeftPinIndex: 2 RightPinIndex: 1 I/System.out: LeftPinIndex: 2 RightPinIndex: 0

PJHaynes304 commented 6 years ago

Just thought I'd share my workaround for this issue. It's not a hard problem to solve but an easy solution for anyone until the commit is merged

Before I do a request using the rangebar values as parameters I just get a min and max for the pinIndexes rather than using left and right.

int minPinIndex = leftPinIndex; int maxPinIndex = rightPinIndex; if (leftPinIndex > rightPinIndex) { minPinIndex = rightPinIndex; maxPinIndex = leftPinIndex; }