support for sbpSteps value
This commit is contained in:
parent
a04aa57f7a
commit
bcd400ef00
@ -2,6 +2,7 @@
|
||||
<resources>
|
||||
<declare-styleable name="SeekBarPreference">
|
||||
<attr name="sbpMaxValue" format="integer"/>
|
||||
<attr name="sbpSteps" format="integer" />
|
||||
<attr name="sbpSummaryValueMultiplication" format="float"/>
|
||||
<attr name="sbpSummaryValueAddition" format="float"/>
|
||||
<attr name="sbpSummaryText" format="string"/>
|
||||
|
@ -51,6 +51,10 @@ public class SeekBarPreference extends DialogPreference implements SeekBar.OnSee
|
||||
* The initially configured value (updated on dialog close)
|
||||
*/
|
||||
private int mInitialValue;
|
||||
/**
|
||||
* Steps to take for the value
|
||||
*/
|
||||
private int mSteps;
|
||||
/**
|
||||
* The format to use for the summary
|
||||
*/
|
||||
@ -89,6 +93,7 @@ public class SeekBarPreference extends DialogPreference implements SeekBar.OnSee
|
||||
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.SeekBarPreference);
|
||||
|
||||
mMaxValue = a.getInteger(R.styleable.SeekBarPreference_sbpMaxValue, 0);
|
||||
mSteps = a.getInteger(R.styleable.SeekBarPreference_sbpSteps, 1);
|
||||
mSummaryValueMultiplication = a.getFloat(R.styleable.SeekBarPreference_sbpSummaryValueMultiplication, 0f);
|
||||
mSummaryValueAddition = a.getFloat(R.styleable.SeekBarPreference_sbpSummaryValueAddition, 0f);
|
||||
mSummaryFormat = a.getString(R.styleable.SeekBarPreference_sbpSummaryFormat);
|
||||
@ -166,6 +171,8 @@ public class SeekBarPreference extends DialogPreference implements SeekBar.OnSee
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
|
||||
{
|
||||
if (fromUser) {
|
||||
progress = (progress/mSteps) * mSteps;
|
||||
seekBar.setProgress(progress);
|
||||
setValue(progress);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user