I have a progressbar class which is running from a B4XPage.
The progressbar class has a layout, which needs to be loaded.
When I load the layout first from the B4XPage and then make calls to the progressbar class there is no problem and all runs fine.
As this progress bar in various places in the project I thought I could do the loading of the layout in the progressbar class instead
and save some lines of code.
When I do this however I run into this error:
This is the code in the B4XPage:
And this the relevant code in the progressbar class:
I made ResumableSubs in case there was a timing issue, but to no avail.
Thanks for any insight in this problem.
RBS
The progressbar class has a layout, which needs to be loaded.
When I load the layout first from the B4XPage and then make calls to the progressbar class there is no problem and all runs fine.
As this progress bar in various places in the project I thought I could do the loading of the layout in the progressbar class instead
and save some lines of code.
When I do this however I run into this error:
B4X:
b4xprogressbar$ResumableSub_Load_Layoutresume (java line: 648)
java.lang.RuntimeException: java.lang.NullPointerException: Attempt to read from field 'java.lang.Object anywheresoftware.b4a.BA.eventsTarget' on a null object reference in method 'anywheresoftware.b4a.keywords.LayoutBuilder$LayoutValuesAndMap anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(java.lang.String, anywheresoftware.b4a.BA, boolean, android.view.ViewGroup, java.util.LinkedHashMap)'
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:155)
at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:134)
at anywheresoftware.b4a.objects.B4XViewWrapper.LoadLayout(B4XViewWrapper.java:329)
at b4a.exampleljjll.b4xprogressbar$ResumableSub_Load_Layout.resume(b4xprogressbar.java:648)
at b4a.exampleljjll.b4xprogressbar._load_layout(b4xprogressbar.java:625)
at b4a.exampleljjll.b4xprogressbar$ResumableSub_Show.resume(b4xprogressbar.java:840)
at b4a.exampleljjll.b4xprogressbar._show(b4xprogressbar.java:800)
at b4a.exampleljjll.p_map$ResumableSub_LogMissingTilesInPolygon.resume(p_map.java:7526)
at b4a.exampleljjll.p_map._logmissingtilesinpolygon(p_map.java:6880)
at b4a.exampleljjll.p_map$ResumableSub_ShowAreaTiles.resume(p_map.java:13288)
at b4a.exampleljjll.p_map._showareatiles(p_map.java:13223)
at b4a.exampleljjll.p_map$ResumableSub_PatientsInAreaDialog.resume(p_map.java:8523)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:275)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:215)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
at anywheresoftware.b4a.keywords.Common$15.run(Common.java:1804)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:230)
at android.os.Looper.loop(Looper.java:319)
at android.app.ActivityThread.main(ActivityThread.java:9063)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:588)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
Caused by: java.lang.NullPointerException: Attempt to read from field 'java.lang.Object anywheresoftware.b4a.BA.eventsTarget' on a null object reference in method 'anywheresoftware.b4a.keywords.LayoutBuilder$LayoutValuesAndMap anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(java.lang.String, anywheresoftware.b4a.BA, boolean, android.view.ViewGroup, java.util.LinkedHashMap)'
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:133)
... 23 more
Starter, LogError, strErrorMsg: java.lang.RuntimeException: java.lang.NullPointerException: Attempt to read from field 'java.lang.Object anywheresoftware.b4a.BA.eventsTarget' on a null object reference in method 'anywheresoftware.b4a.keywords.LayoutBuilder$LayoutValuesAndMap anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(java.lang.String, anywheresoftware.b4a.BA, boolean, android.view.ViewGroup, java.util.LinkedHashMap)'
This is the code in the B4XPage:
B4X:
'Root.LoadLayout("ProgressBar") 'With this (and not loading the layout in clsProgressBar) it runs all fine
Dim rs As ResumableSub = clsProgressBar.Show(Root, iMaxTilesToCheck, False, 1, "Find missing tiles", "", "/", " done")
Wait For (rs) Complete (bDone As Boolean)
And this the relevant code in the progressbar class:
B4X:
Sub Load_Layout(vParent As B4XView) As ResumableSub
' Log("vParent.Tag: " & vParent.Tag)
vParent.LoadLayout("ProgressBar")
Return True
End Sub
Public Sub Show(Parent As B4XView, _
iMax As Int, _
bAnimateValues As Boolean, _
iProgressPosition As Int, _
strTitle As String, _
strDone As String, _
strValuesSeparator As String, _
strToDo As String) As ResumableSub
' Parent.LoadLayout("ProgressBar")
' Log("Show")
' Log("Parent.Tag: " & Parent.Tag)
Dim rs As ResumableSub = Load_Layout(Parent)
Wait For (rs) Complete (bDone As Boolean)
I made ResumableSubs in case there was a timing issue, but to no avail.
Thanks for any insight in this problem.
RBS