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