Skip to content

Commit

Permalink
crdroid: Fix displaying units for CustomSeekBarPreference
Browse files Browse the repository at this point in the history
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
  • Loading branch information
neobuddy89 committed Feb 13, 2019
1 parent 37bfb69 commit ad8b895
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/com/crdroid/settings/preferences/CustomSeekBarPreference.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public CustomSeekBarPreference(Context context, AttributeSet attrs, int defStyle
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CustomSeekBarPreference);
try {
mShowSign = a.getBoolean(R.styleable.CustomSeekBarPreference_showSign, mShowSign);
String units = a.getString(R.styleable.CustomSeekBarPreference_units);
if (units != null)
mUnits = " " + units;
mContinuousUpdates = a.getBoolean(R.styleable.CustomSeekBarPreference_continuousUpdates, mContinuousUpdates);
} finally {
a.recycle();
Expand All @@ -77,7 +80,6 @@ public CustomSeekBarPreference(Context context, AttributeSet attrs, int defStyle
} catch (Exception e) {
Log.e(TAG, "Invalid interval value", e);
}
mUnits = getAttributeStringValue(attrs, SETTINGS_NS, "units", "");
mMinValue = attrs.getAttributeIntValue(SETTINGS_NS, "min", mMinValue);
mMaxValue = attrs.getAttributeIntValue(ANDROIDNS, "max", mMaxValue);
if (mMaxValue < mMinValue)
Expand Down Expand Up @@ -151,16 +153,6 @@ public void onBindViewHolder(PreferenceViewHolder holder) {
mPlusImageView.setOnLongClickListener(this);
}

private String getAttributeStringValue(AttributeSet attrs, String namespace, String name,
String defaultValue) {
String value = attrs.getAttributeValue(namespace, name);

if (value == null)
value = defaultValue;

return value;
}

protected int getLimitedValue(int v) {
return v < mMinValue ? mMinValue : (v > mMaxValue ? mMaxValue : v);
}
Expand Down

0 comments on commit ad8b895

Please sign in to comment.