forked from tidev/titanium-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TiView.java
52 lines (44 loc) · 1.69 KB
/
TiView.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
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2012 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 ti.modules.titanium.ui.widget;
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.proxy.TiViewProxy;
import org.appcelerator.titanium.util.TiConvert;
import org.appcelerator.titanium.view.TiCompositeLayout;
import org.appcelerator.titanium.view.TiCompositeLayout.LayoutArrangement;
import org.appcelerator.titanium.view.TiCompositeLayout.LayoutParams;
import org.appcelerator.titanium.view.TiUIView;
import android.view.View;
public class TiView extends TiUIView
{
public TiView(TiViewProxy proxy, LayoutArrangement arrangement, LayoutParams params) {
super(proxy);
this.layoutParams = params;
processLayout = false;
setNativeView(new TiCompositeLayout(proxy.getActivity(), arrangement, proxy));
}
public TiView(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, proxy));
}
@Override
protected void setOpacity(View view, float opacity)
{
super.setOpacity(view, opacity);
TiCompositeLayout layout = (TiCompositeLayout) nativeView;
layout.setAlphaCompat(opacity);
}
}