abouttreesummaryrefslogcommitdiff
path: root/srcs
diff options
context:
space:
mode:
authorJules Aguillon2021-04-24 23:12:06 +0200
committerJules Aguillon2021-04-24 23:12:06 +0200
commit5688e181fae8cc2f26b5f15b7c59d5b30e1952de (patch)
tree3beface11fb648fc62da951b2132659261726b46 /srcs
parent87b237494aa4e227a838296d75968cdbb3880b6b (diff)
downloadunexpected-keyboard-5688e181fae8cc2f26b5f15b7c59d5b30e1952de.tar.gz
unexpected-keyboard-5688e181fae8cc2f26b5f15b7c59d5b30e1952de.zip
SlideBarPreference: Reduce the number of step
To have cleaner values.
Diffstat (limited to 'srcs')
-rw-r--r--srcs/juloo.common/SlideBarPreference.java8
1 files changed, 4 insertions, 4 deletions
diff --git a/srcs/juloo.common/SlideBarPreference.java b/srcs/juloo.common/SlideBarPreference.java
index 765f758..650f28b 100644
--- a/srcs/juloo.common/SlideBarPreference.java
+++ b/srcs/juloo.common/SlideBarPreference.java
@@ -25,7 +25,7 @@ import android.widget.SeekBar;
public class SlideBarPreference extends DialogPreference
implements SeekBar.OnSeekBarChangeListener
{
- private static final int SEEKBAR_MAX = 100000;
+ private static final int STEPS = 100;
private LinearLayout _layout;
private TextView _textView;
@@ -45,7 +45,7 @@ public class SlideBarPreference extends DialogPreference
_textView.setPadding(48, 40, 48, 40);
_seekBar = new SeekBar(context);
_seekBar.setOnSeekBarChangeListener(this);
- _seekBar.setMax(SEEKBAR_MAX);
+ _seekBar.setMax(STEPS);
_min = float_of_string(attrs.getAttributeValue(null, "min"));
_value = _min;
_max = Math.max(1f, float_of_string(attrs.getAttributeValue(null, "max")));
@@ -58,7 +58,7 @@ public class SlideBarPreference extends DialogPreference
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
{
- _value = (progress * _max) / SEEKBAR_MAX + _min;
+ _value = Math.round(progress * (_max - _min)) / (float)STEPS + _min;
updateText();
}
@@ -84,7 +84,7 @@ public class SlideBarPreference extends DialogPreference
_value = (Float)defaultValue;
persistFloat(_value);
}
- _seekBar.setProgress((int)((_value - _min) * SEEKBAR_MAX / _max));
+ _seekBar.setProgress((int)((_value - _min) * STEPS / (_max - _min)));
updateText();
}