Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim wv AsWebView
Dim WebChromeClient1 AsDefaultWebChromeClient
Dim wve AsWebViewExtras
Dim wvs AsWebViewSettings
Private ime1 AsIME
Private ActivityParent As JavaObject
Dim VP AsAHViewPager
Dim PC AsAHPageContainer
Dim STR AsAHSwipeToRefresh
Dim LVs(4) As ListView
Dim PageRefreshing As Int
EndSub
Sub Activity_Create(FirstTime As Boolean)
STR.Initialize("STR")
Activity.AddView(STR, 0, 0, 100%x, 100%y)
STR.SetColorScheme2(Array As Int(Colors.Red, Colors.Green, Colors.Blue, Colors.Magenta, Colors.Cyan, Colors.Yellow))
Dim url_selected = "http://www.bbc.co.uk/" As String
wv.Initialize("wv")
wve.Initialize(wv)
WebChromeClient1.Initialize("WebChromeClient1")
wve.SetWebChromeClient(WebChromeClient1)
wve.LoadUrl(url_selected)
STR.AddView(wve)
'PC.AddPage(wv,"Test bbc")
EndSub
Sub Activity_Resume
EndSub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub STR_Refresh
Log("Refresh started for Page " & VP.CurrentPage)
'Start the timer. Normally you will start your asynchronous job here
tm.Initialize("Timer", 3000)
tm.Enabled = True
'Disable the STR object so we can not start a new refresh process
STR.Enabled = False
'We have to remember which page caused the refreshing
PageRefreshing = VP.CurrentPage
End Sub
'The timer tick simulates the end of the refreshing process
Sub Timer_Tick
Log("Refresh stopped for Page " & PageRefreshing)
'Stop Timer and refresh the listview data
tm.Enabled = False
RefreshListView(PageRefreshing, LVs(PageRefreshing))
'Stop the spinning disc and enable the STR object again.
STR.Refreshing = False
STR.Enabled = True
End Sub
Sub RefreshListView(page As Int, lv As ListView)
lv.Clear
For i = 0 To 100
lv.AddTwoLines("Page: " & page & " - Item: " & i, "Value: " & Rnd(0, 100))
Next
End Sub
' The STR object "asks" if the refresh should be triggered.
Sub STR_CanChildScrollUp As Boolean
'Is the Listview of the current page at top. If yes, we can swipe to refresh, otherwise we have to scroll up first.
Dim jo AsJavaObject
Dim pos, offset As Int
'We are not at the top of the LV. So the LV can scroll up further and we return True here.
Return True
End Sub