circularseekbar icon indicating copy to clipboard operation
circularseekbar copied to clipboard

Progress step(increment) value

Open vladut-dascalescu opened this issue 8 years ago • 2 comments

Hello,

Is there any way to set the step value ? I mean if I have values from 0-200 and the step of 25, on stop trackingtouch to get only values multiple of 25 (0, 25, 50, 75...). This is how I temporally implemented on my app :

`circularSeekBar.setOnSeekBarChangeListener(new CircularSeekBar.OnCircularSeekBarChangeListener() { @Override public void onProgressChanged(CircularSeekBar circularSeekBar, int progress, boolean fromUser) { selectedAmount = (progress / 25) * 25; amount.setText(String.valueOf(selectedAmount)); }

        @Override
        public void onStopTrackingTouch(CircularSeekBar seekBar) {
            seekBar.setProgress(selectedAmount);
        }

        @Override
        public void onStartTrackingTouch(CircularSeekBar seekBar) {

        }
    });

`

Selected amount is an int where I keep the current progress of the seekbar and amount is a textview where I show it. With this implementation I get the values smaller or equal ... so if it's a value inside 25-49 I return 25. It's not the best solution, but it works...

Thanks !

vladut-dascalescu avatar Feb 27 '17 16:02 vladut-dascalescu

You can do it this way on the onProgressChanged method:

   mCircularSeekBar.setOnSeekBarChangeListener(new CircularSeekBar.CircleSeekBarListener() {
        @Override
        public void onProgressChanged(CircularSeekBar circularSeekBar, int progress, boolean fromUser) {
            mCircularSeekBar.setProgress((progress / 10) * 10);
            String cardPercentage = String.valueOf(mCircularSeekBar.getProgress()) + " %";
            String checkPercentage = String.valueOf(100 - mCircularSeekBar.getProgress()) + " %";
            mCardPercentageTextView.setText(cardPercentage);
            mCheckPercentageTextView.setText(checkPercentage);
        }

        @Override
        public void onStopTrackingTouch(CircularSeekBar seekBar) {

        }

        @Override
        public void onStartTrackingTouch(CircularSeekBar seekBar) {

        }
    });
}

hamz250 avatar Dec 21 '17 15:12 hamz250

Hi @hamz250 ,

Your implementation is exactly like mine. I don't see any improvement (your post looks better because you used the "insert code" function correctly). My question was if there is any way to set the step (the workaround how to apply a function to get it, found it pretty fast). I was looking for a method like "mCircularSeekBar.setStep(step)", like "mCircularSeekBar.setProgress(progress)".

Anyways, thanks for the answer, Have a nice day!

vladut-dascalescu avatar Dec 21 '17 16:12 vladut-dascalescu