aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/settings/WpThresholdPreference.java
diff options
context:
space:
mode:
authorkoem <koem@petoria.de>2013-06-21 18:57:50 -0600
committerrsudev <rasch@munin-soft.de>2013-07-09 21:49:26 +0200
commitece37925442507a71f12a2a2f531ea213c48cad5 (patch)
treed901c0f18e9e8c1af65c15f0de25ad3abc04a14f /main/src/cgeo/geocaching/settings/WpThresholdPreference.java
parent3abe2f0eb20b351bb8d7b8d5283dcbd102241d27 (diff)
downloadcgeo-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.java73
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;
+ }
+
+}