Android Open Source - interdroid-swan Seek Bar Preference From Project Back to project page interdroid-swan .
License The source code is released under:
Copyright (c) 2008-2011 Vrije Universiteit, The Netherlands
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided
that the follo...
If you think the Android project interdroid-swan listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code /* The following code was written by Matthew Wiggins
* and is released under the APACHE 2.0 license
* / * f r o m w w w . j a v a 2 s . c o m * /
* http://www.apache.org/licenses/LICENSE-2.0
*/
package interdroid.swan.util;
import android.content.Context;
import android.preference.DialogPreference;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.TextView;
public class SeekBarPreference extends DialogPreference implements
SeekBar.OnSeekBarChangeListener {
private static final String androidns = "http://schemas.android.com/apk/res/android" ;
private SeekBar mSeekBar;
private TextView mSplashText, mValueText;
private Context mContext;
private String mDialogMessage, mSuffix;
private String mDefault;
private int mMax, mValue = 0;
public SeekBarPreference(Context context, AttributeSet attrs) {
super (context, attrs);
mContext = context;
mDialogMessage = attrs.getAttributeValue(androidns, "dialogMessage" );
mSuffix = attrs.getAttributeValue(androidns, "text" );
mDefault = ""
+ attrs.getAttributeIntValue(androidns, "defaultValue" , 0);
mMax = attrs.getAttributeIntValue(androidns, "max" , 100);
}
@Override
protected View onCreateDialogView() {
LinearLayout.LayoutParams params;
LinearLayout layout = new LinearLayout(mContext);
layout.setOrientation(LinearLayout.VERTICAL);
layout.setPadding(6, 6, 6, 6);
mSplashText = new TextView(mContext);
if (mDialogMessage != null)
mSplashText.setText(mDialogMessage);
layout.addView(mSplashText);
mValueText = new TextView(mContext);
mValueText.setGravity(Gravity.CENTER_HORIZONTAL);
mValueText.setTextSize(32);
params = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
layout.addView(mValueText, params);
mSeekBar = new SeekBar(mContext);
mSeekBar.setOnSeekBarChangeListener(this );
layout.addView(mSeekBar, new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
if (shouldPersist())
mValue = Integer.parseInt(getPersistedString(mDefault));
mSeekBar.setMax(mMax);
mSeekBar.setProgress(mValue);
return layout;
}
@Override
protected void onBindDialogView(View v) {
super.onBindDialogView(v);
mSeekBar.setMax(mMax);
mSeekBar.setProgress(mValue);
}
@Override
protected void onSetInitialValue(boolean restore, Object defaultValue) {
super.onSetInitialValue(restore, defaultValue);
if (restore)
mValue = shouldPersist() ? Integer
.parseInt(getPersistedString(mDefault)) : 0;
else
mValue = (Integer ) defaultValue;
}
public void onProgressChanged(SeekBar seek, int value, boolean fromTouch) {
String t = String.valueOf(value);
mValueText.setText(mSuffix == null ? t : t.concat(mSuffix));
if (shouldPersist())
persistString("" + value);
callChangeListener(t + mSuffix);
}
public void onStartTrackingTouch(SeekBar seek) {
}
public void onStopTrackingTouch(SeekBar seek) {
}
public void setMax(int max) {
mMax = max;
}
public int getMax() {
return mMax;
}
public void setProgress(int progress) {
mValue = progress;
if (mSeekBar != null)
mSeekBar.setProgress(progress);
}
public int getProgress() {
return mValue;
}
}
Java Source Code List interdroid.swan.ExpressionListener.java interdroid.swan.ExpressionManager.java interdroid.swan.SensorConfigurationException.java interdroid.swan.SensorInfo.java interdroid.swan.SwanException.java interdroid.swan.TriStateExpressionListener.java interdroid.swan.ValueExpressionListener.java interdroid.swan.crossdevice.Converter.java interdroid.swan.crossdevice.CrossDeviceReceiver.java interdroid.swan.crossdevice.Pusher.java interdroid.swan.crossdevice.Registry.java interdroid.swan.crossdevice.SwanGCMConstants.java interdroid.swan.crossdevice.SwanLakeActivity.java interdroid.swan.engine.EvaluationEngineReceiver.java interdroid.swan.engine.EvaluationEngineService.java interdroid.swan.engine.EvaluationManager.java interdroid.swan.engine.ExpressionViewerActivity.java interdroid.swan.engine.QueuedExpression.java interdroid.swan.engine.SensorSetupFailedException.java interdroid.swan.engine.SensorViewerActivity.java interdroid.swan.engine.TextProgressBar.java interdroid.swan.sensors.AbstractConfigurationActivity.java interdroid.swan.sensors.AbstractCuckooSensor.java interdroid.swan.sensors.AbstractMemorySensor.java interdroid.swan.sensors.AbstractSensorBase.java interdroid.swan.sensors.AbstractVdbSensor.java interdroid.swan.sensors.MonitorThread.java interdroid.swan.sensors.SensorInterface.java interdroid.swan.sensors.TimeSensor.java interdroid.swan.sensors.impl.BatterySensor.java interdroid.swan.sensors.impl.BluetoothSensor.java interdroid.swan.sensors.impl.CalendarSensor.java interdroid.swan.sensors.impl.CallSensor.java interdroid.swan.sensors.impl.GyroscopeSensor.java interdroid.swan.sensors.impl.IntentSensor.java interdroid.swan.sensors.impl.LightSensor.java interdroid.swan.sensors.impl.LocationSensor.java interdroid.swan.sensors.impl.LogCatSensor.java interdroid.swan.sensors.impl.MagnetometerSensor.java interdroid.swan.sensors.impl.MovementSensor.java interdroid.swan.sensors.impl.PolarHeartRate.java interdroid.swan.sensors.impl.PressureSensor.java interdroid.swan.sensors.impl.ProximitySensor.java interdroid.swan.sensors.impl.ScreenSensor.java interdroid.swan.sensors.impl.SignalStrengthSensor.java interdroid.swan.sensors.impl.SmartLocationSensor.java interdroid.swan.sensors.impl.SoundSensor.java interdroid.swan.sensors.impl.TemperatureSensor.java interdroid.swan.sensors.impl.TwitterSensor.java interdroid.swan.sensors.impl.WifiSensor.java interdroid.swan.sensors.impl.package-info.java interdroid.swan.swansong.BinaryLogicOperator.java interdroid.swan.swansong.ComparatorResult.java interdroid.swan.swansong.Comparator.java interdroid.swan.swansong.ComparisonExpression.java interdroid.swan.swansong.ConstantValueExpression.java interdroid.swan.swansong.ExpressionFactory.java interdroid.swan.swansong.ExpressionParseException.java interdroid.swan.swansong.Expression.java interdroid.swan.swansong.HistoryReductionMode.java interdroid.swan.swansong.LogicExpression.java interdroid.swan.swansong.LogicOperator.java interdroid.swan.swansong.MathOperator.java interdroid.swan.swansong.MathValueExpression.java interdroid.swan.swansong.ParseableEnum.java interdroid.swan.swansong.Parseable.java interdroid.swan.swansong.Result.java interdroid.swan.swansong.SensorValueExpression.java interdroid.swan.swansong.TimestampedValue.java interdroid.swan.swansong.TriStateExpression.java interdroid.swan.swansong.TriState.java interdroid.swan.swansong.UnaryLogicOperator.java interdroid.swan.swansong.ValueExpression.java interdroid.swan.ui.EnterConstantDialog.java interdroid.swan.ui.ExpressionBuilderActivity.java interdroid.swan.ui.LaunchService.java interdroid.swan.ui.MergeExpressionDialog.java interdroid.swan.ui.NewExpressionDialog.java interdroid.swan.ui.NewMathExpressionDialog.java interdroid.swan.ui.SelectComparatorDialog.java interdroid.swan.ui.SelectExpressionDialog.java interdroid.swan.ui.SelectOperatorDialog.java interdroid.swan.ui.SelectSensorDialog.java interdroid.swan.ui.SelectTypedValueDialog.java interdroid.swan.ui.package-info.java interdroid.swan.util.SeekBarPreference.java interdroid.swan.util.TimePreference.java