Android Question Custom B4XPages.Delegate

fbritop

Active Member
Licensed User
Longtime User
I was going through delegates and I came up with an idea, which I don´t know if it is possible.

I have a View Class, which basically constructs a card panel with some local events attach to them. This card is called multiple times from a B4XPage. These cards are generated in various B4XPages around the App. These cards contain location distance to a point.

At the present time, I have fused location running under "Main". Every time it receives a locationUpdate I need to check with B4Xpage is on top, and according to that, call a Sub in that B4XPage to update the cards.

Seeing this, I was thinking, how can our own Sub in the Main, can be delegated? For example, if I want to delegate fusedLocatin_LocationChanged so that every time this sub is called, it delegates the event to each class that has this event? Or is there any other simple way other than querying which B4Xpage is on top?

Thanks in advance
FBP
 

fbritop

Active Member
Licensed User
Longtime User
What should I be missing??
B4X:
Sub FusedLocation_LocationChanged(Location1 As Location)
   'This sub is within [B]Main[/B]
    Log(Location1.Latitude & "," & Location1.Longitude)
    kvs.Put("lat", Location1.Latitude+(Rnd(-9,9)/100))
    kvs.Put("lon", Location1.Longitude+(Rnd(-9,9)/100))
    If Location1.AccuracyValid=True Then
        kvs.Put("accuracy", localLocation.Accuracy)
    Else
        kvs.Put("accuracy", 0)
    End If
    B4XPages.GetManager.RaiseEvent(B4XPages.GetManager.GetTopPage, "LocationChanged", Null)
End Sub


In DEBUG it works perfect, but in RELEASE it never calls the Sub. Logs says:
"*** mainpage: LocationChanged [mainpage]"

There is a sub in B4XMainpage, but never gets the call in RELEASE


B4X:
Sub LocationChanged
    Log("LocationChanged B4XMainPage")
    updateDistances
End Sub
 
Upvote 0
Top