/
ExampleProxy.java.ejs
104 lines (88 loc) 路 2.83 KB
/
ExampleProxy.java.ejs
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
101
102
103
104
/**
* This file was auto-generated by the Titanium Module SDK helper for Android
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2010 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*
*/
package <%- moduleId %>;
import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.KrollProxy;
import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.util.Log;
import org.appcelerator.titanium.util.TiConfig;
import org.appcelerator.titanium.util.TiConvert;
import org.appcelerator.titanium.proxy.TiViewProxy;
import org.appcelerator.titanium.view.TiCompositeLayout;
import org.appcelerator.titanium.view.TiCompositeLayout.LayoutArrangement;
import org.appcelerator.titanium.view.TiUIView;
import android.app.Activity;
// This proxy can be created by calling <%- moduleNameCamel %>.createExample({message: "hello world"})
@Kroll.proxy(creatableInModule=<%- moduleNameCamel %>Module.class)
public class ExampleProxy extends TiViewProxy
{
// Standard Debugging variables
private static final String LCAT = "ExampleProxy";
private static final boolean DBG = TiConfig.LOGD;
private class ExampleView extends TiUIView
{
public ExampleView(TiViewProxy proxy) {
super(proxy);
LayoutArrangement arrangement = LayoutArrangement.DEFAULT;
if (proxy.hasProperty(TiC.PROPERTY_LAYOUT)) {
String layoutProperty = TiConvert.toString(proxy.getProperty(TiC.PROPERTY_LAYOUT));
if (layoutProperty.equals(TiC.LAYOUT_HORIZONTAL)) {
arrangement = LayoutArrangement.HORIZONTAL;
} else if (layoutProperty.equals(TiC.LAYOUT_VERTICAL)) {
arrangement = LayoutArrangement.VERTICAL;
}
}
setNativeView(new TiCompositeLayout(proxy.getActivity(), arrangement));
}
@Override
public void processProperties(KrollDict d)
{
super.processProperties(d);
}
}
// Constructor
public ExampleProxy()
{
super();
}
@Override
public TiUIView createView(Activity activity)
{
TiUIView view = new ExampleView(this);
view.getLayoutParams().autoFillsHeight = true;
view.getLayoutParams().autoFillsWidth = true;
return view;
}
// Handle creation options
@Override
public void handleCreationDict(KrollDict options)
{
super.handleCreationDict(options);
if (options.containsKey("message")) {
Log.d(LCAT, "example created with message: " + options.get("message"));
}
}
// Methods
@Kroll.method
public void printMessage(String message)
{
Log.d(LCAT, "printing message: " + message);
}
@Kroll.getProperty @Kroll.method
public String getMessage()
{
return "Hello World from my module";
}
@Kroll.setProperty @Kroll.method
public void setMessage(String message)
{
Log.d(LCAT, "Tried setting module message to: " + message);
}
}