support: CustomSeekbarPreference: Fix displaying units
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
diff --git a/src/com/bliss/support/preferences/CustomSeekBarPreference.java b/src/com/bliss/support/preferences/CustomSeekBarPreference.java
index f8de8ea..bf7a5e6 100644
--- a/src/com/bliss/support/preferences/CustomSeekBarPreference.java
+++ b/src/com/bliss/support/preferences/CustomSeekBarPreference.java
@@ -66,6 +66,9 @@
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();
@@ -78,7 +81,6 @@
} 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)
@@ -152,16 +154,6 @@
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);
}