-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhome.lua
More file actions
executable file
·145 lines (92 loc) · 3.13 KB
/
home.lua
File metadata and controls
executable file
·145 lines (92 loc) · 3.13 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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
local composer = require("composer")
local widget = require( "widget" )
local scene = composer.newScene()
--https://www.java.com/pt_BR/download/
local page
local bg
--local title
function scene:create( event )
local sceneGroup = self.view
bg = display.newRect(sceneGroup, 0, 0, display.contentWidth, display.contentHeight)
bg.anchorX = 0
bg.anchorY = 0
bg:setFillColor(1,0,0)
function networkListener( event )
if ( event.isError ) then
print( "Network error: ", event.response )
else
local dados = event.response
local pageLimited = string.match(dados,"<h4 class=\"sub\">......................")
local pageLimited2 = string.sub(pageLimited,18,38)
local pageLimited3 = string.gsub(pageLimited2,"\n","")
local dataFormatted = "Java: " .. pageLimited3
--local title = display.newText(sceneGroup, dataFormatted, display.contentCenterX, display.contentCenterY, native.systemFont, 14 )
local path = system.pathForFile( "versions.txt", system.DocumentsDirectory )
local file, errorString = io.open( path, "w" )
if not file then
print( "File error: " .. errorString )
else
file:write( dataFormatted)
io.close( file )
end
file = nil
end
end
network.request( "https://www.java.com/pt_BR/download/", "GET", networkListener )
end
function scene:show( event )
local sceneGroup = self.view
local phase = event.phase
if ( phase == "will" ) then
elseif ( phase == "did" ) then
local path = system.pathForFile( "versions.txt", system.DocumentsDirectory )
local file, errorString = io.open( path, "r" )
if not file then
print( "File error: " .. errorString )
else
contents = file:read( "*a" )
io.close( file )
end
file = nil
local function onRowRender( event )
local row = event.row
local rowHeight = row.contentHeight
local rowWidth = row.contentWidth
local rowTitle = display.newText( row, contents, 0, 0, nil, 14 )
rowTitle:setFillColor( 0 )
rowTitle.anchorX = 0
rowTitle.x = 8
rowTitle.y = rowHeight * 0.5
end
local tableView = widget.newTableView(
{
left = 0,
top = display.contentCenterY + 20,
height = display.contentHeight - display.contentCenterY + 12,
width = display.contentWidth,
>
>
listener = scrollListener
}
)
for i = 1, 1 do
tableView:insertRow{}
end
end
end
function scene:hide( event )
local sceneGroup = self.view
local phase = event.phase
if ( phase == "will" ) then
elseif ( phase == "did" ) then
end
end
-- destroy()
function scene:destroy( event )
local sceneGroup = self.view
end
scene:addEventListener( "create", scene )
scene:addEventListener( "show", scene )
scene:addEventListener( "hide", scene )
scene:addEventListener( "destroy", scene )
return scene
You can’t perform that action at this time.