blob: 4c43acfd367de9b9bdcd417cd5f6af7aeaa81059 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
package cgeo.geocaching.settings;
import cgeo.geocaching.R;
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 {
private 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;
}
}
|