AnderWeb / discreteSeekBar

Apache License 2.0
2.11k stars 400 forks source link

discreteSeekBar shows negative of max value instead of min value #67

Open Winghin2517 opened 8 years ago

Winghin2517 commented 8 years ago

This is the setup for my discreteSeekBar.

        discreteSeekBarRange = (DiscreteSeekBar) findViewById(R.id.discreteseekbar_range);
        discreteSeekBarRange.setMin(20);
        discreteSeekBarRange.setMax(50);
        discreteSeekBarRange.setProgress(sharedPreferences.getInt(getString(R.string.range_int),20));

When I navigate to the minimum value in the seekbar, it reacts correctly and displays 20.

However, when I exit my activity and come back to it, the seekbar is displaying the negative max value.

screen-shot-2016-02-15-at-5 48 07-pm

If I move the seekbar up a little, it reflects the correct value again, in my case, it reflects the value 21.

untitled-1

If I navigate to the min value, it displays 20 again.

I think this is a bug - I downloaded my sharedpreferences as well, the value inside there is 20.

How do I fix this?

srolemberg commented 8 years ago

I have the same problem in my implementation.

I tried to use the minimum value for the XML (app:dsb_min) but without success.

Winghin2517 commented 8 years ago

I also tried that myself but doesn't help at all.

srolemberg commented 8 years ago

Well, I work around this problem by setting the initial values before any listener be set.

seek.setMin(min); seek.setMax(max); seek.setProgress(max); seek.setProgress(min);

Winghin2517 commented 8 years ago

I also did the same thing but i said:

discreteSeekBarRange = (DiscreteSeekBar) findViewById(R.id.discreteseekbar_range); discreteSeekBarRange.setMin(20); discreteSeekBarRange.setMax(50); discreteSeekBarRange.setProgress(sharedPreferences.getInt(getString(R.string.range_int),20));

Still doesn't work.

On Thu, Feb 25, 2016 at 8:55 PM, Samir Rolemberg notifications@github.com wrote:

Well, I work around this problem by setting the initial values before any listener be set.

seek.setMin(min); seek.setMax(max); seek.setProgress(max); seek.setProgress(min);

— Reply to this email directly or view it on GitHub https://github.com/AnderWeb/discreteSeekBar/issues/67#issuecomment-188928830 .

srolemberg commented 8 years ago

Try to set the progress value twice as I did. Between the maximum and minimum. And in your case try a third value to its initial value.

seek.setMin(min); seek.setMax(max); seek.setProgress(max); seek.setProgress(min); seek.setProgress(mValue);

srolemberg commented 8 years ago

The component has a "problem" with the initial value. If the initial value is equal to the value of the progress it does not update. If what I did was force the update after I force at minimum.

Winghin2517 commented 8 years ago

Thanks - this actually solved it for me.

discreteSeekBarRange = (DiscreteSeekBar) findViewById(R.id.discreteseekbar_range); discreteSeekBarRange.setMin(20); discreteSeekBarRange.setMax(50); discreteSeekBarRange.setProgress(50); discreteSeekBarRange.setProgress(20); discreteSeekBarRange.setProgress(sharedPreferences.getInt(getString(R.string.range_int),20));

On Sat, Feb 27, 2016 at 12:06 AM, Samir Rolemberg notifications@github.com wrote:

The component has a "problem" with the initial value. If the initial value is equal to the value of the progress it does not update. If what I did was force the update after I force at minimum.

— Reply to this email directly or view it on GitHub https://github.com/AnderWeb/discreteSeekBar/issues/67#issuecomment-189503498 .

Manishkb commented 6 years ago

After @Winghin2517 solution, issue still persists, need this solution from library update.