Skip to content
This repository was archived by the owner on Dec 19, 2021. It is now read-only.

Commit 4a03e17

Browse files
committed
fix(android-loading-indicator): Add internal creation status property.
Wrap popOver creation in a promise to cleanly update property.
1 parent eed98f2 commit 4a03e17

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/loading-indicator.android.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export class LoadingIndicator {
3030
private _detailsId: number;
3131
private _customViewId: number;
3232
private _loadersInstances: android.widget.PopupWindow[];
33+
private _isCreatingPopOver: boolean;
3334

3435
constructor() {
3536
this._defaultProgressColor = new Color('#007DD6');
@@ -38,6 +39,7 @@ export class LoadingIndicator {
3839
this._detailsId = android.view.View.generateViewId();
3940
this._customViewId = android.view.View.generateViewId();
4041
this._loadersInstances = [];
42+
this._isCreatingPopOver = false;
4143
}
4244

4345
show(options?: OptionsCommon) {
@@ -47,14 +49,28 @@ export class LoadingIndicator {
4749
options.android = options.android || {};
4850
options.userInteractionEnabled =
4951
options.userInteractionEnabled !== undefined || true;
52+
5053
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}`);
5468
});
55-
} else {
56-
this._updatePopOver(context, options);
69+
return;
5770
}
71+
this._updatePopOver(context, options);
72+
}
73+
}
5874
}
5975
}
6076

0 commit comments

Comments
 (0)