Hi,
I'm using LabelExtra for showing some HTML content. Everything is working fine but getting an error while showing img tag.
Here is the code:
Getting this error:
If I use wait for (getImage) complete(result as object) then I have to change the return type of Sub ImageGetter_GetDrawable(Source As String) As Object to resumable sub. But as per the library example this return type has to be an Object.
So is there any solution?
I'm using LabelExtra for showing some HTML content. Everything is working fine but getting an error while showing img tag.
Here is the code:
B4X:
Dim htmlParser As Html
Dim desc As Label
desc.Initialize("")
desc.Text = htmlParser.FromHtml2(htmlString,"ImageGetter","TagGetter")
Sub ImageGetter_GetDrawable(Source As String) As Object
Dim data As Object = getImage(Source)
If data=Null Then
Return Null
Else
Dim b As BitmapDrawable = data '<- getting error on this line
Return b
End If
End Sub
Sub getImage(Source As String) As ResumableSub
Dim j As HttpJob
Dim BitmapDrawable1 As BitmapDrawable
j.Initialize("", Me)
j.Download(Source)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
BitmapDrawable1.Initialize(j.GetBitmap)
Dim l As LabelExtras:l.SetDrawableBounds(BitmapDrawable1, 0, 0, j.GetBitmap.Width, j.GetBitmap.Height)
j.Release
Return BitmapDrawable1
Else
j.Release
Return Null
End If
End Sub
Getting this error:
B4X:
java.lang.ClassCastException: anywheresoftware.b4a.keywords.Common$ResumableSubWrapper cannot be cast to android.graphics.drawable.Drawable
If I use wait for (getImage) complete(result as object) then I have to change the return type of Sub ImageGetter_GetDrawable(Source As String) As Object to resumable sub. But as per the library example this return type has to be an Object.
So is there any solution?