/
ActivityIndicatorProxy.java
100 lines (89 loc) 路 2.25 KB
/
ActivityIndicatorProxy.java
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/**
* Titanium SDK
* Copyright TiDev, Inc. 04/07/2022-Present. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
package ti.modules.titanium.ui;
import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.proxy.TiViewProxy;
import org.appcelerator.titanium.view.TiUIView;
import ti.modules.titanium.ui.widget.TiUIActivityIndicator;
import android.app.Activity;
import android.os.Message;
@Kroll.proxy(creatableInModule = UIModule.class,
propertyAccessors = {
TiC.PROPERTY_MESSAGE,
TiC.PROPERTY_MESSAGEID,
TiC.PROPERTY_COLOR,
TiC.PROPERTY_FONT,
TiC.PROPERTY_STYLE,
TiC.PROPERTY_INDICATOR_COLOR
})
@Kroll.dynamicApis(methods = { "hide", "show" })
public class ActivityIndicatorProxy extends TiViewProxy
{
private static final int MSG_FIRST_ID = TiViewProxy.MSG_LAST_ID + 1;
private static final int MSG_SHOW = MSG_FIRST_ID + 100;
boolean visible = false;
public ActivityIndicatorProxy()
{
super();
defaultValues.put(TiC.PROPERTY_VISIBLE, false);
}
@Override
public TiUIView createView(Activity activity)
{
TiUIView view = new TiUIActivityIndicator(this);
if (visible) {
getMainHandler().obtainMessage(MSG_SHOW).sendToTarget();
}
return view;
}
@Override
public boolean handleMessage(Message msg)
{
switch (msg.what) {
case MSG_SHOW:
handleShow(null);
return true;
}
return super.handleMessage(msg);
}
@Override
protected KrollDict getLangConversionTable()
{
KrollDict table = new KrollDict();
table.put(TiC.PROPERTY_MESSAGE, TiC.PROPERTY_MESSAGEID);
return table;
}
@Override
protected void handleShow(KrollDict options)
{
visible = true;
if (view == null) {
TiUIActivityIndicator ai = (TiUIActivityIndicator) getOrCreateView();
ai.show();
return;
}
super.handleShow(options);
}
@Override
protected void handleHide(KrollDict options)
{
visible = false;
if (view == null) {
TiUIActivityIndicator ai = (TiUIActivityIndicator) getOrCreateView();
ai.hide();
return;
}
super.handleHide(options);
}
@Override
public String getApiName()
{
return "Ti.UI.ActivityIndicator";
}
}