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

Commit bb4e526

Browse files
authored
Merge pull request #22 from kefahB/master
Fixing dismiss multiple instances
2 parents e3790f5 + f1c662e commit bb4e526

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/loading-indicator.android.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export class LoadingIndicator {
2929
private _messageId: number;
3030
private _detailsId: number;
3131
private _customViewId: number;
32+
private _loadersInstances: android.widget.PopupWindow[];
3233

3334
constructor() {
3435
this._defaultProgressColor = new Color('#007DD6');
@@ -48,6 +49,7 @@ export class LoadingIndicator {
4849
if (!this._popOver) {
4950
setTimeout(() => {
5051
this._createPopOver(context, options);
52+
this._loadersInstances.push(this._popOver);
5153
});
5254
} else {
5355
this._updatePopOver(context, options);
@@ -56,12 +58,28 @@ export class LoadingIndicator {
5658
}
5759

5860
hide() {
59-
if (this._popOver) {
60-
this._popOver.dismiss();
61+
let i = 0;
62+
try {
63+
this._loadersInstances.forEach(loader => {
64+
if(loader) {
65+
if (this._isShowing(loader)) {
66+
loader.dismiss();
67+
}
68+
}
69+
this._loadersInstances.splice(i, 1);
70+
i++;
71+
});
72+
6173
this._popOver = null;
6274
this._currentProgressColor = null;
75+
} catch(e) {
76+
console.log(e)
6377
}
6478
}
79+
80+
private _isShowing(loader: android.widget.PopupWindow) {
81+
return loader.isShowing();
82+
}
6583

6684
private _createPopOver(context, options?: OptionsCommon) {
6785
this._popOver = new android.widget.PopupWindow();

0 commit comments

Comments
 (0)