Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private smm As SimpleMediaManager
Private Panel1 As B4XView
End Sub
Public Sub Initialize
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
smm.Initialize
SetImageWithRoundCorners(Panel1, "https://s8.uupload.ir/files/mov_94214_1826821-ezgif.com-webp-to-jpg-converter_01x.jpg")
End Sub
Private Sub SetImageWithRoundCorners (Target As B4XView, Url As String)
Target.Visible = False
smm.SetMediaWithExtra(Target, Url, "", CreateMap(smm.REQUEST_CALLBACK: Me, smm.REQUEST_RESIZE_MODE: "FILL_NO_DISTORTIONS"))
Wait For (Panel1) SMM_MediaReady (Success As Boolean, Media As SMMedia)
If Success Then
If Panel1.Getview(0).Tag Is B4XImageView Then
Dim iv As B4XImageView = Panel1.Getview(0).Tag
setCornerRadius(iv.mBase, 5dip, 5dip, 10dip, 10dip, 20dip, 20dip, 40dip, 40dip)
iv.mBase.As(JavaObject).RunMethod("setClipToOutline", Array(True))
Target.SetVisibleAnimated(300, True)
End If
End If
End Sub
Private Sub setCornerRadius(v As View, Rx_TopLeft As Float, Ry_TopLeft As Float, Rx_TopRight As Float, Ry_TopRight As Float, Rx_BottomRight As Float, Ry_BottomRight As Float, Rx_BottomLeft As Float, Ry_BottomLeft As Float)
Dim jo As JavaObject = v.Background
If v.Background Is ColorDrawable Or v.Background Is GradientDrawable Then
jo.RunMethod("setCornerRadii", Array As Object(Array As Float(Rx_TopLeft, Ry_TopLeft, Rx_TopRight, Ry_TopRight, Rx_BottomRight, Ry_BottomRight, Rx_BottomLeft, Ry_BottomLeft)))
End If
End Sub