Android Question how multi webview and webw.extras progress

Tayfur

Well-Known Member
Licensed User
Longtime User
I have multi webview in a activity.
And they in has list

B4X:
Public Sub AddWebPage(Web_Url As String)
   
    Dim ww As WebView
    ww.Initialize("WebPage")
    ww.Tag=WebPages.Size+1

    Display.AddView(ww,left_point,0,Display_Boyut.Panel_Width,Display_Boyut.Panel_Height)
      Dim WebViewExtras1 As WebViewExtras
   WebViewExtras1.addWebChromeClient(ww, "WebViewExtras1")
   ww.LoadUrl(Web_Url)
    WebPages.Add(ww) ' <<< webPAges as list

End Sub

How can I detecet webpage.tag/no in "Sub WebViewExtras1_ProgressChanged(NewProgress As Int)"
 

Tayfur

Well-Known Member
Licensed User
Longtime User
The Sender keyword will return the WebView that raised the event (if the event is implemented correctly in the library).

I used Sender. So I get some error .

error.JPG
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
The Sender keyword will return the WebView that raised the event (if the event is implemented correctly in the library).

The WebViewExtras ProgressChanged event Sender is the WebChromeClient NOT the WebView.

@Tayfur
I've attached an updated version of WebViewExtras.
It raises a new event:

ProgressChanged2 (WebView1 As WebView, NewProgress As Int)

Replace your sub
ProgressChanged (NewProgress As Int)
with
ProgressChanged2 (WebView1 As WebView, NewProgress As Int)

Post with your results - if it works as expected then i'll upload the update to the WebViewExtras thread.
 
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
The WebViewExtras ProgressChanged event Sender is the WebChromeClient NOT the WebView.

@Tayfur
I've attached an updated version of WebViewExtras.
It raises a new event:

ProgressChanged2 (WebView1 As WebView, NewProgress As Int)

Replace your sub
ProgressChanged (NewProgress As Int)
with
ProgressChanged2 (WebView1 As WebView, NewProgress As Int)

Post with your results - if it works as expected then i'll upload the update to the WebViewExtras thread.


java.lang.Exception: Sub webviewextras1_progresschanged2 signature does not match expected signature.

I recied an error many times. (I updated your lib, Own lib was v.1.41)
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
java.lang.Exception: Sub webviewextras1_progresschanged2 signature does not match expected signature.

That implies that the parameters to your ProgressChanged2 event do not match the expected parameters:

ProgressChanged2 (WebView1 As WebView, NewProgress As Int)

Can you post your ProgressChanged2 event sub?
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
By the way - post #4 currently shows that no-one has downloaded the v1.42 update.
That must be a glitch with the forum software...
 
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
By the way - post #4 currently shows that no-one has downloaded the v1.42 update.
That must be a glitch with the forum software...

My code is

B4X:
Public Sub AddWebPage(Web_Url As String)
  
'    Dim Panels(Max(NumberOfPanels,2)) As Panel
'    vYpos = Display.Height/2
'    vWidth = Display.Width
'    For c = 0 To Panels.Length-1
'        Panels(c).Initialize(EventTouch)
'        Panels(c).Tag = c
'        Display.AddView(Panels(c),vWidth,0,vWidth,Display.Height)
'    Next
    Dim wpn, left_point As Int
    If PanelsCount=0 Then
            left_point=0
        Else
            Web=WebPages.Get(PanelsCount-1)
            left_point=Web.Left+Display_Boyut.Panel_Width
    End If
    wpn=PanelsCount
  
    Dim ww As WebView
    ww.Initialize("WebPage")
    Dim webtag As Map
    webtag.Initialize
    webtag.Clear
    webtag.Put("URL",Web_Url)
    webtag.Put("LOADING",True)
    webtag.Put("LOADRATE",0)
    'ww.Tag=WebPages.Size+1
    ww.Tag=webtag
'      WebPages.Get(wpn).Initialize("Webpage")
'    WebPages.Get(wpn).Tag=wpn
    Display.AddView(ww,left_point,0,Display_Boyut.Panel_Width,Display_Boyut.Panel_Height)
    Dim WebViewExtras1 As WebViewExtras
    WebViewExtras1.addWebChromeClient(ww, "WebViewExtras1")
   'wextra.addWebChromeClient(ww,"WebPage")
 
    ww.LoadUrl(Web_Url)
    WebPages.Add(ww)
    PanelsCount=WebPages.Size
    'Log(PanelsCount&"-- web pages")
    TouchPanel.BringToFront
End Sub

Sub WebViewExtras1_ProgressChanged2(WebView1 As WebView, NewProgress As Int)
Log("ok")
'    Log("webviwetag:"&WebView1.Tag)
End Sub


Error and lib screeshot:

error.JPG

libarary
error.JPG
 
Last edited:
Upvote 0

warwound

Expert
Licensed User
Longtime User
Try this revised update.
I just tested in a simple b4a project and it works on my old Tab3 (kitkat).
 

Attachments

  • WebViewExtras_v1_42.zip
    7.8 KB · Views: 262
Upvote 0
Top