Sub Class_Globals
Private WF As WebView
'Private WE As WebViewExtras
'Private WX As WebViewSettings
Private VARS() As String
Private CurrentURL As String
Private CurrentVARS As String
Private mHandler As Object
Private mEventName As String
Private mHtmlCode As String
Private mDefaultHtmlCode As String
Private mPnl As Panel
Private mWidth As Int
Private mHeight As Int
Private mTop As Int
Private mLeft As Int
Private SU As StringUtils
Private mTag As Object
Private mTagID As Object
Private mEnableExternalLinks As Boolean = False
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize( pPnl As Panel, pHandler As Object, pEventName As String, pLeft As Int, pTop As Int, pWidth As Int, pHeight As Int, pDefaultHtmlCode As String)
mHandler = pHandler
mEventName = pEventName
mPnl = pPnl
mLeft = pLeft
mTop = pTop
mWidth = pWidth
mHeight = pHeight
mDefaultHtmlCode= pDefaultHtmlCode
WF.Initialize("WF")
Dim Ntv5 As NativeObject = WF
'Ntv5.SetField("opaque", False)
Ntv5.GetField("scrollView").SetField("bounces", False)
'WF.setzo
'WF.ZoomEnabled = False
'WE.Initialize(WF)
'WE.ZoomEnabled = False
'WX.setSupportZoom(WF, False)
WF.LoadHtml(mDefaultHtmlCode)
mPnl.AddView(WF, mLeft, mTop, mWidth, mHeight)
End Sub
public Sub AsView As WebView
Return WF
End Sub
Public Sub getEnableExternalLinks As Boolean
Return mEnableExternalLinks
End Sub
Public Sub setEnableExternalLinks(v As Boolean)
mEnableExternalLinks = v
End Sub
private Sub WF_PageFinished (Success As Boolean, Url As String)
If SubExists(mHandler, mEventName & "_Loaded",0) And Success = True Then
CallSub(mHandler, mEventName & "_Loaded")
End If
End Sub
Private Sub WF_OverrideUrl(Url As String) As Boolean
If mEnableExternalLinks = True Then
If Url.IndexOf("http://") = 0 Or Url.IndexOf("https://") = 0 Then ' è un link esterno
If SubExists(mHandler, mEventName & "_RaiseExternalLink",1) Then
CallSub2(mHandler, mEventName & "_RaiseExternalLink", Url)
End If
Return True
End If
End If
CurrentURL = SU.DecodeUrl(Url, "utf-8")
Dim nu As String = SU.DecodeUrl(Url, "utf-8")
Dim iPos As Int = nu.IndexOf("/par?")
nu = nu.SubString(iPos+5)
VARS = Regex.Split("&",nu)
CurrentVARS = nu
If SubExists(mHandler, mEventName & "_Raise",0) Then
CallSub(mHandler, mEventName & "_Raise")
End If
Return True
End Sub
public Sub LoadHtml(pHtmlCode As String)
mHtmlCode = pHtmlCode
If mHtmlCode.IndexOf("///")>0 Then
mHtmlCode = mHtmlCode.Replace("/android_asset", File.DirAssets)
Else
mHtmlCode = mHtmlCode.Replace("android_asset", File.DirAssets)
End If
WF.LoadHtml(mHtmlCode)
End Sub
public Sub LoadHtmlFromRemoteUrl(pRemoteUrl As String, pVars() As String, pPostMode As Boolean)
WF.LoadHtml(mDefaultHtmlCode)
Dim j As HttpJob
j.Initialize("jWS", Me)
Dim xx As String
For i = 0 To pVars.Length -1
If xx <> "" Then xx = xx & "&"
xx = xx & pVars(i)
Next
If pPostMode = True Then
Dim bc As ByteConverter
Dim Data() As Byte = bc.StringToBytes(xx, "utf-8")
j.PostBytes(pRemoteUrl, Data)
j.GetRequest.SetHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8")
Else
j.PostString(pRemoteUrl, xx)
End If
End Sub
public Sub ExecuteJavaScript(l() As Object)
Dim no As NativeObject = WF
no.RunMethod("stringByEvaluatingJavaScriptFromString:", l)
End Sub
public Sub setWebBackground(color As Int)
WF.Color = color
End Sub
Private Sub JobDone(j As HttpJob)
If j.Success Then
mHtmlCode = j.GetString2("utf-8")
' Cambia android_asset
If mHtmlCode.IndexOf("///")>0 Then
mHtmlCode = mHtmlCode.Replace("/android_asset", File.DirAssets)
Else
mHtmlCode = mHtmlCode.Replace("android_asset", File.DirAssets)
End If
WF.LoadHtml(mHtmlCode)
End If
j.Release
End Sub
public Sub getTag As Object
Return mTag
End Sub
public Sub setTag(pTag As Object)
mTag = pTag
End Sub
public Sub getTagID As Object
Return mTagID
End Sub
public Sub setTagID(pTag As Object)
mTagID = pTag
End Sub
public Sub GetVars As String()
Return VARS
End Sub
public Sub GetValue( varName As String ) As String
Dim sRet As String = ""
If VARS.Length > 0 Then
For i = 0 To VARS.Length -1
Dim data() As String = Regex.Split("=", VARS(i))
If data.Length = 2 Then
If varName.ToLowerCase() = data(0).ToLowerCase() Then
sRet = data(1)
Exit
End If
End If
Next
End If
Return sRet
End Sub
#End if