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

Progress step(increment) value #30

Open
vladut-dascalescu opened this issue Feb 27, 2017 · 2 comments
Open

Progress step(increment) value #30

vladut-dascalescu opened this issue Feb 27, 2017 · 2 comments

Comments

@vladut-dascalescu
Copy link

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 !

@hamz250
Copy link

hamz250 commented Dec 21, 2017

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) {

        }
    });
}

@vladut-dascalescu
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants