1 | import { SliderBase, valueProperty, minValueProperty, maxValueProperty } from './slider-common';
|
2 | import { colorProperty, backgroundColorProperty, backgroundInternalProperty } from '../styling/style-properties';
|
3 | import { Color } from '../../color';
|
4 | export * from './slider-common';
|
5 | let SeekBar;
|
6 | let SeekBarChangeListener;
|
7 | function initializeListenerClass() {
|
8 | if (!SeekBarChangeListener) {
|
9 | var SeekBarChangeListenerImpl = (function (_super) {
|
10 | __extends(SeekBarChangeListenerImpl, _super);
|
11 | function SeekBarChangeListenerImpl() {
|
12 | var _this = _super.call(this) || this;
|
13 | return global.__native(_this);
|
14 | }
|
15 | SeekBarChangeListenerImpl.prototype.onProgressChanged = function (seekBar, progress, fromUser) {
|
16 | var owner = seekBar.owner;
|
17 | if (owner && !owner._supressNativeValue) {
|
18 | var newValue = progress + owner.minValue;
|
19 | valueProperty.nativeValueChange(owner, newValue);
|
20 | }
|
21 | };
|
22 | SeekBarChangeListenerImpl.prototype.onStartTrackingTouch = function (seekBar) {
|
23 |
|
24 | };
|
25 | SeekBarChangeListenerImpl.prototype.onStopTrackingTouch = function (seekBar) {
|
26 |
|
27 | };
|
28 | SeekBarChangeListenerImpl = __decorate([
|
29 | Interfaces([android.widget.SeekBar.OnSeekBarChangeListener]),
|
30 | __metadata("design:paramtypes", [])
|
31 | ], SeekBarChangeListenerImpl);
|
32 | return SeekBarChangeListenerImpl;
|
33 | }(java.lang.Object));
|
34 | SeekBarChangeListener = new SeekBarChangeListenerImpl();
|
35 | }
|
36 | }
|
37 | function getListener() {
|
38 | return SeekBarChangeListener;
|
39 | }
|
40 | export class Slider extends SliderBase {
|
41 | createNativeView() {
|
42 | if (!SeekBar) {
|
43 | SeekBar = android.widget.SeekBar;
|
44 | }
|
45 | return new SeekBar(this._context);
|
46 | }
|
47 | initNativeView() {
|
48 | super.initNativeView();
|
49 | const nativeView = this.nativeViewProtected;
|
50 | nativeView.owner = this;
|
51 | initializeListenerClass();
|
52 | const listener = getListener();
|
53 | nativeView.setOnSeekBarChangeListener(listener);
|
54 | }
|
55 | disposeNativeView() {
|
56 | this.nativeViewProtected.owner = null;
|
57 | super.disposeNativeView();
|
58 | }
|
59 | resetNativeView() {
|
60 | super.resetNativeView();
|
61 | const nativeView = this.nativeViewProtected;
|
62 | nativeView.setMax(100);
|
63 | nativeView.setProgress(0);
|
64 | nativeView.setKeyProgressIncrement(1);
|
65 | }
|
66 | |
67 |
|
68 |
|
69 |
|
70 |
|
71 | setNativeValuesSilently() {
|
72 | this._supressNativeValue = true;
|
73 | const nativeView = this.nativeViewProtected;
|
74 | try {
|
75 | nativeView.setMax(this.maxValue - this.minValue);
|
76 | nativeView.setProgress(this.value - this.minValue);
|
77 | }
|
78 | finally {
|
79 | this._supressNativeValue = false;
|
80 | }
|
81 | }
|
82 | [valueProperty.setNative](value) {
|
83 | this.setNativeValuesSilently();
|
84 | }
|
85 | [minValueProperty.setNative](value) {
|
86 | this.setNativeValuesSilently();
|
87 | }
|
88 | [maxValueProperty.getDefault]() {
|
89 | return 100;
|
90 | }
|
91 | [maxValueProperty.setNative](value) {
|
92 | this.setNativeValuesSilently();
|
93 | }
|
94 | [colorProperty.getDefault]() {
|
95 | return -1;
|
96 | }
|
97 | [colorProperty.setNative](value) {
|
98 | if (value instanceof Color) {
|
99 | this.nativeViewProtected.getThumb().setColorFilter(value.android, android.graphics.PorterDuff.Mode.SRC_IN);
|
100 | }
|
101 | else {
|
102 | this.nativeViewProtected.getThumb().clearColorFilter();
|
103 | }
|
104 | }
|
105 | [backgroundColorProperty.getDefault]() {
|
106 | return -1;
|
107 | }
|
108 | [backgroundColorProperty.setNative](value) {
|
109 | if (value instanceof Color) {
|
110 | this.nativeViewProtected.getProgressDrawable().setColorFilter(value.android, android.graphics.PorterDuff.Mode.SRC_IN);
|
111 | }
|
112 | else {
|
113 | this.nativeViewProtected.getProgressDrawable().clearColorFilter();
|
114 | }
|
115 | }
|
116 | [backgroundInternalProperty.getDefault]() {
|
117 | return null;
|
118 | }
|
119 | [backgroundInternalProperty.setNative](value) {
|
120 |
|
121 | }
|
122 | }
|
123 |
|
\ | No newline at end of file |