@@ -30,6 +30,7 @@ export class LoadingIndicator {
30
30
private _detailsId : number ;
31
31
private _customViewId : number ;
32
32
private _loadersInstances : android . widget . PopupWindow [ ] ;
33
+ private _isCreatingPopOver : boolean ;
33
34
34
35
constructor ( ) {
35
36
this . _defaultProgressColor = new Color ( '#007DD6' ) ;
@@ -38,6 +39,7 @@ export class LoadingIndicator {
38
39
this . _detailsId = android . view . View . generateViewId ( ) ;
39
40
this . _customViewId = android . view . View . generateViewId ( ) ;
40
41
this . _loadersInstances = [ ] ;
42
+ this . _isCreatingPopOver = false ;
41
43
}
42
44
43
45
show ( options ?: OptionsCommon ) {
@@ -47,14 +49,28 @@ export class LoadingIndicator {
47
49
options . android = options . android || { } ;
48
50
options . userInteractionEnabled =
49
51
options . userInteractionEnabled !== undefined || true ;
52
+
50
53
if ( ! this . _popOver ) {
51
- setTimeout ( ( ) => {
52
- this . _createPopOver ( context , options ) ;
53
- this . _loadersInstances . push ( this . _popOver ) ;
54
+ this . _isCreatingPopOver = true ;
55
+ new Promise ( ( resolve ) => {
56
+ setTimeout ( ( ) => {
57
+ this . _createPopOver ( context , options ) ;
58
+ this . _loadersInstances . push ( this . _popOver ) ;
59
+ resolve ( ) ;
60
+ } ) ;
61
+ } ) . then ( ( ) => {
62
+ this . _isCreatingPopOver = false ;
63
+ } ) . catch ( ( error ) => {
64
+ // Ensure this is left in a clean state.
65
+ this . _isCreatingPopOver = false ;
66
+ const message = error && error . message ? `: ${ error . message } ` : '' ;
67
+ console . error ( `Error creating Loading Indicator Pop Over${ message } ` ) ;
54
68
} ) ;
55
- } else {
56
- this . _updatePopOver ( context , options ) ;
69
+ return ;
57
70
}
71
+ this . _updatePopOver ( context , options ) ;
72
+ }
73
+ }
58
74
}
59
75
}
60
76
0 commit comments