Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private xui As XUI
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
Private WebView1 As WebView
Private wex As WebViewExtras
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
wex.addWebChromeClient(WebView1,"wex")
wex.addJavascriptInterface(WebView1,"b4a")
Dim html As String=File.ReadString(File.DirAssets,"index.html")
WebView1.Loadhtml(html)
End Sub
Private Sub WebView1_PageFinished (Url As String)
wex.executeJavascript(WebView1,$"
window.onscroll = function() {
if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
// We've reached the bottom of the page
alert('scroll end');
console.log("End of scrolling");
b4a.CallSub('WebViewEndScrolling', false);
}
};
"$)
wex.executeJavascript(WebView1, $"
window.alert = function(message) { b4a.CallSub('ShowAlertMessage', true, message); };
console.log = function(message) { b4a.CallSub('LogMessage', true, message); };
"$)
End Sub
Private Sub ShowAlertMessage(msg As String)
Log($"ShowAlertMessage ${msg}"$)
End Sub
Private Sub LogMessage(msg As String)
Log($"LogMessage ${msg}"$)
End Sub
Private Sub WebViewEndScrolling
Log("End of Webview reached")
End Sub