forked from nstudio/nativescript-pulltorefresh
-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.android.ts
59 lines (49 loc) · 1.53 KB
/
index.android.ts
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
import {
PullToRefreshBase,
indicatorColorProperty,
indicatorFillColorProperty,
refreshingProperty,
} from './index.common';
export * from './index.common';
export class PullToRefresh extends PullToRefreshBase {
public createNativeView() {
const swipeRefreshLayout =
new com.nativescript.swiperefreshlayout.CarouselFriendlySwipeRefreshLayout(
this._context,
);
return swipeRefreshLayout;
}
public initNativeView() {
super.initNativeView();
const androidXListener =
new androidx.swiperefreshlayout.widget.SwipeRefreshLayout.OnRefreshListener(
{
onRefresh: () => {
this.refreshing = true;
this.notify({
eventName: PullToRefreshBase.refreshEvent,
object: this,
});
},
},
);
this.nativeViewProtected.setOnRefreshListener(androidXListener);
this.nativeViewProtected.refreshListener = androidXListener;
}
public disposeNativeView() {
this.nativeViewProtected.refreshListener = null;
super.disposeNativeView();
}
[refreshingProperty.setNative](value: boolean) {
this.nativeViewProtected.setRefreshing(value);
}
[indicatorColorProperty.setNative](value: any) {
const colors = [];
value && colors.push(value.android);
this.nativeViewProtected.setColorSchemeColors(colors);
}
[indicatorFillColorProperty.setNative](value: any) {
const color = value ? value.android : null;
this.nativeViewProtected.setProgressBackgroundColorSchemeColor(color);
}
}