forked from livecode/livecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBusyIndicator.java
More file actions
76 lines (63 loc) · 2.67 KB
/
Copy pathBusyIndicator.java
File metadata and controls
76 lines (63 loc) · 2.67 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/* Copyright (C) 2003-2015 LiveCode Ltd.
This file is part of LiveCode.
LiveCode is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License v3 as published by the Free
Software Foundation.
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
package com.runrev.android;
import android.util.Log;
import android.media.*;
import android.app.*;
import android.content.*;
import android.view.KeyEvent;
import java.util.ArrayList;
public class BusyIndicator
{
protected Engine m_engine;
// PM-2014-12-10: [[ Bug 13253 ]] Allow multiple instances of mobileBusyIndicator instead of a single one
protected ArrayList<ProgressDialog> m_dialog;
protected int m_progress_dialog_array_pos;
public BusyIndicator(Engine p_engine)
{
m_engine = p_engine;
m_progress_dialog_array_pos = -1;
m_dialog = new ArrayList<ProgressDialog>();
}
public void showBusyIndicator(String p_label)
{
// PM-2014-12-10: [[ Bug 13253 ]] Dynamically populate the mobileBusyIndicator array
m_progress_dialog_array_pos++;
m_dialog.add(new ProgressDialog(m_engine.getContext()));
ProgressDialog t_dialog = ProgressDialog.show(m_engine.getContext(), "", p_label, true);
m_dialog.set(m_progress_dialog_array_pos, t_dialog);
t_dialog.setOnKeyListener(new DialogInterface.OnKeyListener()
{
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event)
{
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0)
{
// If backKey is pressed, dismiss all mobileBusyIndicators being in progress before exiting to prevent a leak.
for (ProgressDialog t_dialog : m_dialog)
t_dialog.dismiss();
m_engine.doBackPressed();
return true;
}
return false;
}
});
}
public void hideBusyIndicator()
{
if (m_dialog.get(m_progress_dialog_array_pos) != null)
{
// PM-2014-12-10: [[ Bug 13253 ]] Dismiss the most recent mobileBusyIndicator
m_dialog.get(m_progress_dialog_array_pos).dismiss();
m_progress_dialog_array_pos--;
}
}
}