Hello,
I have this strange problem with loaded images if i go back and forth. Better see videos to understand:
b4i version: https://share.icloud.com/photos/0abs6-ok-9luTqB60Gt3g3JVQ
b4a version working excellent: https://photos.app.goo.gl/RAiDr8RrR8VHo1nM6
Images shown OK only at initial open of the page.
It is a b4x project so it uses exact same code loading images:
As you see at iOS video, when going back, images disappeares ΤΟΟ from previous page, for no reason.
I load mediamanager in every b4xpage that is needed. I tried to load it once and call it from B4XMainPage but with same output.
Any ideas are welcome.
Thank you.
I have this strange problem with loaded images if i go back and forth. Better see videos to understand:
b4i version: https://share.icloud.com/photos/0abs6-ok-9luTqB60Gt3g3JVQ
b4a version working excellent: https://photos.app.goo.gl/RAiDr8RrR8VHo1nM6
Images shown OK only at initial open of the page.
It is a b4x project so it uses exact same code loading images:
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
'load the layout to Root
Root.Color=0xFF05030F
' imageLoader.Initialize
MediaManager.Initialize
MediaManager.DefaultBackgroundColor = xui.Color_Transparent
MediaManager.DefaultForegroundColor = xui.Color_Transparent
MediaManager.DefaultErrorRequest.Extra.Put(MediaManager.REQUEST_BACKGROUND, xui.Color_Transparent)
MediaManager.DefaultLoadingRequest.Extra.Put(MediaManager.REQUEST_BACKGROUND, xui.Color_Transparent)
MediaManager.DefaultResizeMode = "FILL_NO_DISTORTIONS"
MediaManager.AddLocalMedia(MediaManager.KEY_DEFAULT_ERROR, misc.FontToBitmap(misc.Chr32(0xF1B48),30,xui.Color_White), "image/*")
MediaManager.AddLocalMedia(MediaManager.KEY_DEFAULT_LOADING, File.ReadBytes(File.DirAssets, "loading.gif"), "image/gif")
#if b4a
CreateLayout
#End If
End Sub
Private Sub btnBack_Click
totalAnnouncements = 0
clvNotifications.Clear
B4XPages.ClosePage(Me)
End Sub
Sub B4XPage_CloseRequest As ResumableSub
totalAnnouncements = 0
clvNotifications.Clear
Return True
End Sub
Sub B4XPage_Resize (Width As Int, Height As Int)
misc.ShowProgressBar("Loading...")
#if b4i
Dim r As Rect = B4XPages.GetNativeParent(Me).SafeAreaInsets
r.Top = Max(20, r.Top)
Root.SetLayoutAnimated(0, r.Left, r.Top, Width - r.Right - r.Left, Height - r.Bottom - r.Top)
If Root.NumberOfViews = 0 Then CreateLayout
#end if
End Sub
Sub CreateLayout As ResumableSub
Root.LoadLayout("notifications")
toast.Initialize(Root)
PCLVnotifications.Initialize(Me, "PCLVnotifications", clvNotifications)
#if b4i
clvNotifications.Asview.Color = xui.Color_Transparent
clvNotifications.GetBase.Height = Root.Height- pnlToolbar.Height - B4XPages.GetNativeParent(Me).SafeAreaInsets.Bottom
btnDeleteAll.CustomLabel.Font = Font.CreateNew2("materialdesignicons",24)
btnFollows.CustomLabel.Font = Font.CreateNew2("materialdesignicons",24)
#End If
Return Null
End Sub
Sub getNotifications
Dim req As dbrequestmanager = misc.CreateRequest(Me)
Dim cmd1 As DBCommand = misc.CreateCommand("getNotifications", Array(B4XPages.MainPage.user.id))
Wait For (req.ExecuteQuery(cmd1, 0, Null)) JobDone(j As HttpJob)
If j.Success Then
req.HandleJobAsync(j, "req")
Wait For (req) req_Result(rs As DBResult)
'work with result
If rs.Rows.Size = 0 And clvNotifications.Size = 0 Then
lblNoNotifications.BringToFront
lblNoNotifications.Visible=True
Else
lblNoNotifications.SendToBack
lblNoNotifications.Visible=False
End If
For i=0 To rs.Rows.Size-1
Dim Record() As Object
Record = rs.Rows.Get(i)
Private n As notificationsData
n.Initialize
n.id = Record(rs.Columns.Get("id"))
n.id_user = Record(rs.Columns.Get("id_user"))
n.id_user_sent = Record(rs.Columns.Get("id_user_sent"))
n.surname = Record(rs.Columns.Get("surname"))
n.name = Record(rs.Columns.Get("name"))
n.typeNotification = Record(rs.Columns.Get("typeNotification"))
n.id_workout = Record(rs.Columns.Get("id_workout"))
n.photo = Record(rs.Columns.Get("photo"))
n.timestamp = Record(rs.Columns.Get("timestamp"))
#If b4a
lblNotificationDummy.Height = su.MeasureMultilineTextHeight(lblNotificationDummy,cs)
pnlNotificationDummy.Height = lblNotificationDummy.Top + lblNotificationDummy.Height + 10dip
PCLVnotifications.AddItem(pnlNotificationDummy.Height + 20dip,xui.Color_Transparent,n)
#else
lblNotificationDummy.Width = Root.Width - 80
lblNotificationDummy.AttributedText = cs
lblNotificationDummy.SizeToFit
pnlNotificationDummy.Height = lblNotificationDummy.Top + lblNotificationDummy.Height + 10
PCLVnotifications.AddItem(pnlNotificationDummy.Height + 20dip,xui.Color_Transparent,n)
#end if
Next
Else
Log("ERROR: " & j.ErrorMessage)
End If
j.Release
PCLVnotifications.ShowScrollBar = False 'no fast scrolling
PCLVnotifications.ExtraItems = 5
PCLVnotifications.Commit
misc.HideProgressBar
End Sub
Sub clvNotifications_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
For Each i As Int In PCLVnotifications.VisibleRangeChanged(FirstIndex, LastIndex)
Dim item As CLVItem = clvNotifications.GetRawListItem(i)
Dim pnl As B4XView = xui.CreatePanel("")
item.Panel.AddView(pnl, 0, 0, item.Panel.Width, item.Panel.Height)
'Create the item layout
pnl.LoadLayout("clvNotification")
Dim n As notificationsData = item.Value
If n.photo <> Null Then MediaManager.SetMediaWithExtra(pnl.GetView(0).Getview(1),$"${B4XPages.MainPage.downloadLink}?name=${n.photo}.jpg"$,"image/*",CreateMap(MediaManager.REQUEST_ROUNDIMAGE:True, MediaManager.REQUEST_HEADERS: CreateMap("command":"image","id": B4XPages.MainPage.user.id,"token":B4XPages.MainPage.user.token)))
#If b4a
pnl.GetView(0).GetView(0).Height = su.MeasureMultilineTextHeight(pnl.GetView(0).GetView(0),cs)
pnl.GetView(0).GetView(0).Text=cs
pnl.GetView(0).Height = pnl.GetView(0).GetView(0).Top + pnl.GetView(0).GetView(0).Height + 10dip
#else
pnl.GetView(0).GetView(0).As(Label).Width = Root.Width - 80
pnl.GetView(0).GetView(0).As(Label).AttributedText=cs
pnl.GetView(0).GetView(0).As(Label).SizeToFit
pnl.GetView(0).Height = pnl.GetView(0).GetView(0).Top + pnl.GetView(0).GetView(0).Height + 10
#end if
Next
MediaManager.TrimMediaCache
End Sub
As you see at iOS video, when going back, images disappeares ΤΟΟ from previous page, for no reason.
I load mediamanager in every b4xpage that is needed. I tried to load it once and call it from B4XMainPage but with same output.
Any ideas are welcome.
Thank you.
Last edited: