diff options
| author | koem <koem@petoria.de> | 2013-06-21 18:57:50 -0600 |
|---|---|---|
| committer | rsudev <rasch@munin-soft.de> | 2013-07-09 21:49:26 +0200 |
| commit | ece37925442507a71f12a2a2f531ea213c48cad5 (patch) | |
| tree | d901c0f18e9e8c1af65c15f0de25ad3abc04a14f /main/src/cgeo/geocaching/settings/WpThresholdPreference.java | |
| parent | 3abe2f0eb20b351bb8d7b8d5283dcbd102241d27 (diff) | |
| download | cgeo-ece37925442507a71f12a2a2f531ea213c48cad5.zip cgeo-ece37925442507a71f12a2a2f531ea213c48cad5.tar.gz cgeo-ece37925442507a71f12a2a2f531ea213c48cad5.tar.bz2 | |
Implements #750, use preference activity
Diffstat (limited to 'main/src/cgeo/geocaching/settings/WpThresholdPreference.java')
| -rw-r--r-- | main/src/cgeo/geocaching/settings/WpThresholdPreference.java | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/settings/WpThresholdPreference.java b/main/src/cgeo/geocaching/settings/WpThresholdPreference.java new file mode 100644 index 0000000..867714f --- /dev/null +++ b/main/src/cgeo/geocaching/settings/WpThresholdPreference.java @@ -0,0 +1,73 @@ +package cgeo.geocaching.settings; + +import cgeo.geocaching.R; +import cgeo.geocaching.settings.Settings; + +import android.content.Context; +import android.preference.Preference; +import android.util.AttributeSet; +import android.view.View; +import android.view.ViewGroup; +import android.widget.SeekBar; +import android.widget.SeekBar.OnSeekBarChangeListener; +import android.widget.TextView; + +public class WpThresholdPreference extends Preference { + + TextView valueView; + + public WpThresholdPreference(Context context) { + super(context); + init(); + } + + public WpThresholdPreference(Context context, AttributeSet attrs) { + super(context, attrs); + init(); + } + + public WpThresholdPreference(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + init(); + } + + private void init() { + setPersistent(false); + } + + @Override + protected View onCreateView(ViewGroup parent) { + View v = super.onCreateView(parent); + + // get views + SeekBar seekBar = (SeekBar) v.findViewById(R.id.wp_threshold_seekbar); + valueView = (TextView) v.findViewById(R.id.wp_threshold_value_view); + + // init seekbar + seekBar.setMax(Settings.SHOW_WP_THRESHOLD_MAX); + + // set initial value + int threshold = Settings.getWayPointsThreshold(); + valueView.setText(String.valueOf(threshold)); + seekBar.setProgress(threshold); + + seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { + @Override + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + if (fromUser) { + valueView.setText(String.valueOf(progress)); + } + } + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + } + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + Settings.setShowWaypointsThreshold(seekBar.getProgress()); + } + }); + + return v; + } + +} |
