Cherish: Revamp UI Completely
Signed-off-by: Louis1977 <luisgonzales272@gmail.com> Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
75
src/com/cherish/settings/preferences/CherishPreference.java
Normal file
75
src/com/cherish/settings/preferences/CherishPreference.java
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (C) 2015 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cherish.settings.preferences;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.core.content.res.TypedArrayUtils;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
|
||||
public class CherishPreference extends Preference {
|
||||
|
||||
private final View.OnClickListener mClickListener = v -> performClick(v);
|
||||
|
||||
private boolean mAllowDividerAbove;
|
||||
private boolean mAllowDividerBelow;
|
||||
|
||||
public CherishPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Preference);
|
||||
|
||||
mAllowDividerAbove = TypedArrayUtils.getBoolean(a, R.styleable.Preference_allowDividerAbove,
|
||||
R.styleable.Preference_allowDividerAbove, false);
|
||||
mAllowDividerBelow = TypedArrayUtils.getBoolean(a, R.styleable.Preference_allowDividerBelow,
|
||||
R.styleable.Preference_allowDividerBelow, false);
|
||||
a.recycle();
|
||||
|
||||
setLayoutResource(R.layout.preference_cherish_seekbar);
|
||||
}
|
||||
|
||||
public CherishPreference(Context context, View view) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(PreferenceViewHolder holder) {
|
||||
super.onBindViewHolder(holder);
|
||||
holder.itemView.setOnClickListener(mClickListener);
|
||||
|
||||
final boolean selectable = isSelectable();
|
||||
holder.itemView.setFocusable(selectable);
|
||||
holder.itemView.setClickable(selectable);
|
||||
holder.setDividerAllowedAbove(mAllowDividerAbove);
|
||||
holder.setDividerAllowedBelow(mAllowDividerBelow);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Dirty Unicorns Project
|
||||
* Copyright (C) 2016-2019 crDroid Android Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,55 +18,60 @@ package com.cherish.settings.preferences;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.PorterDuff;
|
||||
import androidx.preference.*;
|
||||
import androidx.core.content.res.TypedArrayUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.ViewParent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
import androidx.preference.*;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
public class CustomSeekBarPreference extends Preference implements SeekBar.OnSeekBarChangeListener {
|
||||
private final String TAG = getClass().getName();
|
||||
public class CustomSeekBarPreference extends Preference implements SeekBar.OnSeekBarChangeListener,
|
||||
View.OnClickListener, View.OnLongClickListener {
|
||||
protected final String TAG = getClass().getName();
|
||||
private static final String SETTINGS_NS = "http://schemas.android.com/apk/res/com.android.settings";
|
||||
private static final String ANDROIDNS = "http://schemas.android.com/apk/res/android";
|
||||
private static final int DEFAULT_VALUE = 50;
|
||||
protected static final String ANDROIDNS = "http://schemas.android.com/apk/res/android";
|
||||
|
||||
private int mMin = 0;
|
||||
private int mInterval = 1;
|
||||
private int mCurrentValue;
|
||||
private int mDefaultValue = -1;
|
||||
private int mMax = 255;
|
||||
private String mUnits = "";
|
||||
private String mDefaultText = "";
|
||||
private SeekBar mSeekBar;
|
||||
private TextView mTitle;
|
||||
private TextView mStatusText;
|
||||
protected int mInterval = 1;
|
||||
protected boolean mShowSign = false;
|
||||
protected String mUnits = "";
|
||||
protected boolean mContinuousUpdates = false;
|
||||
|
||||
public CustomSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr,
|
||||
int defStyleRes) {
|
||||
protected int mMinValue = 0;
|
||||
protected int mMaxValue = 100;
|
||||
protected boolean mDefaultValueExists = false;
|
||||
protected int mDefaultValue;
|
||||
|
||||
protected int mValue;
|
||||
|
||||
protected TextView mValueTextView;
|
||||
protected ImageView mResetImageView;
|
||||
protected ImageView mMinusImageView;
|
||||
protected ImageView mPlusImageView;
|
||||
protected SeekBar mSeekBar;
|
||||
|
||||
protected boolean mTrackingTouch = false;
|
||||
protected int mTrackingValue;
|
||||
|
||||
public CustomSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
final TypedArray a = context.obtainStyledAttributes(
|
||||
attrs, R.styleable.CustomSeekBarPreference);
|
||||
|
||||
mMax = attrs.getAttributeIntValue(ANDROIDNS, "max", 255);
|
||||
mMin = attrs.getAttributeIntValue(SETTINGS_NS, "min", 0);
|
||||
mDefaultValue = attrs.getAttributeIntValue(ANDROIDNS, "defaultValue", -1);
|
||||
if (mDefaultValue > mMax) {
|
||||
mDefaultValue = mMax;
|
||||
}
|
||||
mUnits = getAttributeStringValue(attrs, SETTINGS_NS, "units", "");
|
||||
mDefaultText = getAttributeStringValue(attrs, SETTINGS_NS, "defaultText", "Def");
|
||||
|
||||
Integer id = a.getResourceId(R.styleable.CustomSeekBarPreference_units, 0);
|
||||
if (id > 0) {
|
||||
mUnits = context.getResources().getString(id);
|
||||
}
|
||||
id = a.getResourceId(R.styleable.CustomSeekBarPreference_defaultText, 0);
|
||||
if (id > 0) {
|
||||
mDefaultText = context.getResources().getString(id);
|
||||
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();
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -76,12 +81,21 @@ public class CustomSeekBarPreference extends Preference implements SeekBar.OnSee
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Invalid interval value", e);
|
||||
}
|
||||
mMinValue = attrs.getAttributeIntValue(SETTINGS_NS, "min", mMinValue);
|
||||
mMaxValue = attrs.getAttributeIntValue(ANDROIDNS, "max", mMaxValue);
|
||||
if (mMaxValue < mMinValue)
|
||||
mMaxValue = mMinValue;
|
||||
String defaultValue = attrs.getAttributeValue(ANDROIDNS, "defaultValue");
|
||||
mDefaultValueExists = defaultValue != null && !defaultValue.isEmpty();
|
||||
if (mDefaultValueExists) {
|
||||
mDefaultValue = getLimitedValue(Integer.parseInt(defaultValue));
|
||||
mValue = mDefaultValue;
|
||||
} else {
|
||||
mValue = mMinValue;
|
||||
}
|
||||
|
||||
a.recycle();
|
||||
mSeekBar = new SeekBar(context, attrs);
|
||||
mSeekBar.setMax(mMax - mMin);
|
||||
mSeekBar.setOnSeekBarChangeListener(this);
|
||||
setLayoutResource(R.layout.preference_cherish_seekbar);
|
||||
setLayoutResource(R.layout.preference_custom_seekbar);
|
||||
}
|
||||
|
||||
public CustomSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
@@ -89,43 +103,23 @@ public class CustomSeekBarPreference extends Preference implements SeekBar.OnSee
|
||||
}
|
||||
|
||||
public CustomSeekBarPreference(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
this(context, attrs, TypedArrayUtils.getAttr(context,
|
||||
androidx.preference.R.attr.preferenceStyle,
|
||||
android.R.attr.preferenceStyle));
|
||||
}
|
||||
|
||||
public CustomSeekBarPreference(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
private String getAttributeStringValue(AttributeSet attrs, String namespace, String name,
|
||||
String defaultValue) {
|
||||
String value = attrs.getAttributeValue(namespace, name);
|
||||
if (value == null)
|
||||
value = defaultValue;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDependencyChanged(Preference dependency, boolean disableDependent) {
|
||||
super.onDependencyChanged(dependency, disableDependent);
|
||||
this.setShouldDisableView(true);
|
||||
if (mTitle != null)
|
||||
mTitle.setEnabled(!disableDependent);
|
||||
if (mSeekBar != null)
|
||||
mSeekBar.setEnabled(!disableDependent);
|
||||
if (mStatusText != null)
|
||||
mStatusText.setEnabled(!disableDependent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(PreferenceViewHolder view) {
|
||||
super.onBindViewHolder(view);
|
||||
public void onBindViewHolder(PreferenceViewHolder holder) {
|
||||
super.onBindViewHolder(holder);
|
||||
try
|
||||
{
|
||||
// move our seekbar to the new view we've been given
|
||||
ViewParent oldContainer = mSeekBar.getParent();
|
||||
ViewGroup newContainer = (ViewGroup) view.findViewById(R.id.seekBarPrefBarContainer);
|
||||
|
||||
ViewGroup newContainer = (ViewGroup) holder.findViewById(R.id.seekbar);
|
||||
if (oldContainer != newContainer) {
|
||||
// remove the seekbar from the old view
|
||||
if (oldContainer != null) {
|
||||
@@ -139,115 +133,212 @@ public class CustomSeekBarPreference extends Preference implements SeekBar.OnSee
|
||||
} catch (Exception ex) {
|
||||
Log.e(TAG, "Error binding view: " + ex.toString());
|
||||
}
|
||||
mStatusText = (TextView) view.findViewById(R.id.seekBarPrefValue);
|
||||
if (mCurrentValue == mDefaultValue) {
|
||||
mStatusText.setText(mDefaultText);
|
||||
} else {
|
||||
mStatusText.setText(String.valueOf(mCurrentValue) + mUnits);
|
||||
}
|
||||
mSeekBar.setProgress(mCurrentValue - mMin);
|
||||
mTitle = (TextView) view.findViewById(android.R.id.title);
|
||||
|
||||
view.setDividerAllowedAbove(false);
|
||||
//view.setDividerAllowedBelow(false);
|
||||
|
||||
mSeekBar.setMax(getSeekValue(mMaxValue));
|
||||
mSeekBar.setProgress(getSeekValue(mValue));
|
||||
mSeekBar.setEnabled(isEnabled());
|
||||
|
||||
mValueTextView = (TextView) holder.findViewById(R.id.value);
|
||||
mResetImageView = (ImageView) holder.findViewById(R.id.reset);
|
||||
mMinusImageView = (ImageView) holder.findViewById(R.id.minus);
|
||||
mPlusImageView = (ImageView) holder.findViewById(R.id.plus);
|
||||
|
||||
updateValueViews();
|
||||
|
||||
mSeekBar.setOnSeekBarChangeListener(this);
|
||||
mResetImageView.setOnClickListener(this);
|
||||
mMinusImageView.setOnClickListener(this);
|
||||
mPlusImageView.setOnClickListener(this);
|
||||
mResetImageView.setOnLongClickListener(this);
|
||||
mMinusImageView.setOnLongClickListener(this);
|
||||
mPlusImageView.setOnLongClickListener(this);
|
||||
}
|
||||
|
||||
public void setMax(int max) {
|
||||
mMax = max;
|
||||
mSeekBar.setMax(mMax - mMin);
|
||||
protected int getLimitedValue(int v) {
|
||||
return v < mMinValue ? mMinValue : (v > mMaxValue ? mMaxValue : v);
|
||||
}
|
||||
|
||||
public void setMin(int min) {
|
||||
mMin = min;
|
||||
mSeekBar.setMax(mMax - mMin);
|
||||
protected int getSeekValue(int v) {
|
||||
return 0 - Math.floorDiv(mMinValue - v, mInterval);
|
||||
}
|
||||
|
||||
public void setIntervalValue(int value) {
|
||||
mInterval = value;
|
||||
protected String getTextValue(int v) {
|
||||
return (mShowSign && v > 0 ? "+" : "") + String.valueOf(v) + mUnits;
|
||||
}
|
||||
|
||||
public void setValue(int value) {
|
||||
mCurrentValue = value;
|
||||
protected void updateValueViews() {
|
||||
if (mValueTextView != null) {
|
||||
mValueTextView.setText(getContext().getString(R.string.custom_seekbar_value,
|
||||
(!mTrackingTouch || mContinuousUpdates ? getTextValue(mValue) +
|
||||
(mDefaultValueExists && mValue == mDefaultValue ? " (" +
|
||||
getContext().getString(R.string.custom_seekbar_default_value) + ")" : "")
|
||||
: getTextValue(mTrackingValue))));
|
||||
}
|
||||
if (mResetImageView != null) {
|
||||
if (!mDefaultValueExists || mValue == mDefaultValue || mTrackingTouch)
|
||||
mResetImageView.setVisibility(View.INVISIBLE);
|
||||
else
|
||||
mResetImageView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (mMinusImageView != null) {
|
||||
if (mValue == mMinValue || mTrackingTouch) {
|
||||
mMinusImageView.setClickable(false);
|
||||
mMinusImageView.setColorFilter(getContext().getColor(R.color.disabled_text_color),
|
||||
PorterDuff.Mode.MULTIPLY);
|
||||
} else {
|
||||
mMinusImageView.setClickable(true);
|
||||
mMinusImageView.clearColorFilter();
|
||||
}
|
||||
}
|
||||
if (mPlusImageView != null) {
|
||||
if (mValue == mMaxValue || mTrackingTouch) {
|
||||
mPlusImageView.setClickable(false);
|
||||
mPlusImageView.setColorFilter(getContext().getColor(R.color.disabled_text_color), PorterDuff.Mode.MULTIPLY);
|
||||
} else {
|
||||
mPlusImageView.setClickable(true);
|
||||
mPlusImageView.clearColorFilter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void changeValue(int newValue) {
|
||||
// for subclasses
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
int newValue = progress + mMin;
|
||||
if (newValue > mMax)
|
||||
newValue = mMax;
|
||||
else if (newValue < mMin)
|
||||
newValue = mMin;
|
||||
else if (mInterval != 1 && newValue % mInterval != 0)
|
||||
newValue = Math.round(((float) newValue) / mInterval) * mInterval;
|
||||
|
||||
// change rejected, revert to the previous value
|
||||
if (!callChangeListener(newValue)) {
|
||||
seekBar.setProgress(mCurrentValue - mMin);
|
||||
return;
|
||||
}
|
||||
// change accepted, store it
|
||||
mCurrentValue = newValue;
|
||||
if (mStatusText != null) {
|
||||
if (newValue == mDefaultValue) {
|
||||
mStatusText.setText(mDefaultText);
|
||||
} else {
|
||||
mStatusText.setText(String.valueOf(newValue) + mUnits);
|
||||
int newValue = getLimitedValue(mMinValue + (progress * mInterval));
|
||||
if (mTrackingTouch && !mContinuousUpdates) {
|
||||
mTrackingValue = newValue;
|
||||
updateValueViews();
|
||||
} else if (mValue != newValue) {
|
||||
// change rejected, revert to the previous value
|
||||
if (!callChangeListener(newValue)) {
|
||||
mSeekBar.setProgress(getSeekValue(mValue));
|
||||
return;
|
||||
}
|
||||
// change accepted, store it
|
||||
changeValue(newValue);
|
||||
persistInt(newValue);
|
||||
|
||||
mValue = newValue;
|
||||
updateValueViews();
|
||||
}
|
||||
persistInt(newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
mTrackingValue = mValue;
|
||||
mTrackingTouch = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
mTrackingTouch = false;
|
||||
if (!mContinuousUpdates)
|
||||
onProgressChanged(mSeekBar, getSeekValue(mTrackingValue), false);
|
||||
notifyChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object onGetDefaultValue(TypedArray ta, int index) {
|
||||
int defaultValue = ta.getInt(index, DEFAULT_VALUE);
|
||||
return defaultValue;
|
||||
public void onClick(View v) {
|
||||
int id = v.getId();
|
||||
if (id == R.id.reset) {
|
||||
Toast.makeText(getContext(), getContext().getString(R.string.custom_seekbar_default_value_to_set, getTextValue(mDefaultValue)),
|
||||
Toast.LENGTH_LONG).show();
|
||||
} else if (id == R.id.minus) {
|
||||
setValue(mValue - mInterval, true);
|
||||
} else if (id == R.id.plus) {
|
||||
setValue(mValue + mInterval, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
int id = v.getId();
|
||||
if (id == R.id.reset) {
|
||||
setValue(mDefaultValue, true);
|
||||
//Toast.makeText(getContext(), getContext().getString(R.string.custom_seekbar_default_value_is_set),
|
||||
// Toast.LENGTH_LONG).show();
|
||||
} else if (id == R.id.minus) {
|
||||
setValue(mMaxValue - mMinValue > mInterval * 2 && mMaxValue + mMinValue < mValue * 2 ? Math.floorDiv(mMaxValue + mMinValue, 2) : mMinValue, true);
|
||||
} else if (id == R.id.plus) {
|
||||
setValue(mMaxValue - mMinValue > mInterval * 2 && mMaxValue + mMinValue > mValue * 2 ? -1 * Math.floorDiv(-1 * (mMaxValue + mMinValue), 2) : mMaxValue, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// dont need too much shit about initial and default values
|
||||
// its all done in constructor already
|
||||
|
||||
@Override
|
||||
protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
|
||||
if (restoreValue) {
|
||||
mCurrentValue = getPersistedInt(mCurrentValue);
|
||||
}
|
||||
else {
|
||||
int temp = 0;
|
||||
try {
|
||||
temp = (Integer) defaultValue;
|
||||
} catch (Exception ex) {
|
||||
Log.e(TAG, "Invalid default value: " + defaultValue.toString());
|
||||
}
|
||||
persistInt(temp);
|
||||
mCurrentValue = temp;
|
||||
}
|
||||
}
|
||||
|
||||
public void setDefaultValue(int value) {
|
||||
mDefaultValue = value;
|
||||
if (mDefaultValue > mMax) {
|
||||
mDefaultValue = mMax;
|
||||
}
|
||||
if (mCurrentValue == mDefaultValue && mStatusText != null) {
|
||||
mStatusText.setText(mDefaultText);
|
||||
}
|
||||
if (restoreValue)
|
||||
mValue = getPersistedInt(mValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
if (mSeekBar != null && mStatusText != null && mTitle != null) {
|
||||
mSeekBar.setEnabled(enabled);
|
||||
mStatusText.setEnabled(enabled);
|
||||
mTitle.setEnabled(enabled);
|
||||
public void setDefaultValue(Object defaultValue) {
|
||||
if (defaultValue instanceof Integer)
|
||||
setDefaultValue((Integer) defaultValue, mSeekBar != null);
|
||||
else
|
||||
setDefaultValue(defaultValue == null ? (String) null : defaultValue.toString(), mSeekBar != null);
|
||||
}
|
||||
|
||||
public void setDefaultValue(int newValue, boolean update) {
|
||||
newValue = getLimitedValue(newValue);
|
||||
if (!mDefaultValueExists || mDefaultValue != newValue) {
|
||||
mDefaultValueExists = true;
|
||||
mDefaultValue = newValue;
|
||||
if (update)
|
||||
updateValueViews();
|
||||
}
|
||||
super.setEnabled(enabled);
|
||||
}
|
||||
|
||||
public void setDefaultValue(String newValue, boolean update) {
|
||||
if (mDefaultValueExists && (newValue == null || newValue.isEmpty())) {
|
||||
mDefaultValueExists = false;
|
||||
if (update)
|
||||
updateValueViews();
|
||||
} else if (newValue != null && !newValue.isEmpty()) {
|
||||
setDefaultValue(Integer.parseInt(newValue), update);
|
||||
}
|
||||
}
|
||||
|
||||
public void setMax(int max) {
|
||||
mMaxValue = max;
|
||||
mSeekBar.setMax(mMaxValue - mMinValue);
|
||||
}
|
||||
|
||||
public void setMin(int min) {
|
||||
mMinValue = min;
|
||||
mSeekBar.setMax(mMaxValue - mMinValue);
|
||||
}
|
||||
|
||||
public void setValue(int newValue) {
|
||||
mValue = getLimitedValue(newValue);
|
||||
if (mSeekBar != null) mSeekBar.setProgress(getSeekValue(mValue));
|
||||
}
|
||||
|
||||
public void setValue(int newValue, boolean update) {
|
||||
newValue = getLimitedValue(newValue);
|
||||
if (mValue != newValue) {
|
||||
if (update)
|
||||
mSeekBar.setProgress(getSeekValue(newValue));
|
||||
else
|
||||
mValue = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return mValue;
|
||||
}
|
||||
|
||||
// need some methods here to set/get other attrs at runtime,
|
||||
// but who really need this ...
|
||||
|
||||
public void refresh(int newValue) {
|
||||
// this will ...
|
||||
setValue(newValue, mSeekBar != null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user