Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLayoutHelper.lua
More file actions
Latest commit
63 lines (56 loc) · 1.58 KB
/
Copy pathLayoutHelper.lua
File metadata and controls
63 lines (56 loc) · 1.58 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
localLayoutHelper={}
LayoutHelper._VERSION="1.1(alpha01)"
LayoutHelper._VERSION_CODE=1101
import"android.text.TextUtils"
import"android.util.TypedValue"
import"android.content.Context"
import"android.util.DisplayMetrics"
localScaleType=ImageView.ScaleType
localOnClickListener=View.OnClickListener
localcontext=activityorservice
localwm=context.getSystemService(Context.WINDOW_SERVICE)
localoutMetrics=DisplayMetrics()
wm.getDefaultDisplay().getMetrics(outMetrics)
localW=outMetrics.widthPixels
localH=outMetrics.heightPixels
LayoutHelper.W=W
LayoutHelper.H=H
LayoutHelper.PERCENT_W=W/100
LayoutHelper.PERCENT_H=H/100
localdm=context.getResources().getDisplayMetrics()
LayoutHelper.dm=dm
--LayoutHelper.id=0x7f000000
luajava.ids=luajava.idsor {id=0x7f000000}
localids=luajava.ids
LayoutHelper.scaleTypes=ScaleType.values()
LayoutHelper.ltrs={}
functionLayoutHelper.getClickListener(root,v)
locallistener
ifLayoutHelper.ltrs[v] then
listener=LayoutHelper.ltrs[v]
else
locall=rawget(root,v)
iftype(l)=="function" then
listener=OnClickListener{onClick=l}
elseiftype(l)=="userdata" then
listener=l
else
listener=OnClickListener{onClick=function(a)(root[v])(a)end}
end
LayoutHelper.ltrs[v]=listener
end
returnlistener
end
functionLayoutHelper.newId(idName)
ids.id=ids.id+1
returnids.id
end
localver=luajava.bindClass("android.os.Build").VERSION.SDK_INT;
functionLayoutHelper.setBackground(view,bg)
ifver<16then
view.setBackgroundDrawable(bg)
else
view.setBackground(bg)
end
end
returnLayoutHelper