oli107 / material-range-bar

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

Seekbar mode => thumb not moving when user touching the x axis(value) #59

Open KarolMB opened 8 years ago

KarolMB commented 8 years ago

If u will disable RangeBar Mode isRangeBar = false

Visible thumb on seekbar moving only when u do something like drag and drog.. It should also moving like in RangeBar Mode ( click on the axis x Value and thumb moving to this value).

FAST SOLUTION:

private void onActionMove(float x) {

    // Move the pressed thumb to the new x-position.
    if (mIsRangeBar && mLeftThumb.isPressed()) {
        movePin(mLeftThumb, x);
    } else if (mRightThumb.isPressed()) {
        movePin(mRightThumb, x);
   **  add This condition to onActionMove**
    } else if ( mIsRangeBar == false){
        movePin(mRightThumb, x);
    }
summers314 commented 8 years ago

That; and also, in the onActionUp: Add this:

if (leftThumbXDistance < rightThumbXDistance) { Log.i(TAG, "onActionUp:if:1");

            if (mIsRangeBar) 
            {
                Log.i(TAG, "onActionUp:if:2A");
                mLeftThumb.setX(x);
                releasePin(mLeftThumb);
            }else {
              //Added this else statement
                Log.i(TAG, "onActionUp:if:2B");
                mRightThumb.setX(x);
                releasePin(mRightThumb);
            }

        } else {
            Log.i(TAG, "onActionUp:if:3");
            mRightThumb.setX(x);
            releasePin(mRightThumb);
        }

This will allow the pin the move to the closest point when you click the seekBar in cases when mIsRangeBar = false