Hi All,
Still new in B4a, How can I adapt the code in ImageDownloader2 to load an image blob field and Label Text from a remote MySQL database?.
Because i want to load all list even image is still loading to eliminate waiting time to load the xCustomListview.
I am successfully downloading and displaying the image (BLOB) in an ImageView and Text to Label with this code in my JobDone sub:
I need to incorporate the above code into the following original code of the ImageDownloader2 JobDone sub:
(Link: https://www.b4x.com/android/forum/threads/imagedownloader-the-simple-way-to-download-images.30875/)
Hope anybody can help how to achieve this or sample code.
Still new in B4a, How can I adapt the code in ImageDownloader2 to load an image blob field and Label Text from a remote MySQL database?.
Because i want to load all list even image is still loading to eliminate waiting time to load the xCustomListview.
I am successfully downloading and displaying the image (BLOB) in an ImageView and Text to Label with this code in my JobDone sub:
B4X:
If Job.Success Then
Dim res As String
res = Job.GetString
Log("Response from server: " & res)
Dim parser As JSONParser
parser.Initialize(res)
Select Job.JobName
Case Item_details
Dim ItemList as List
Dim Image_blob as String
Dim Label1_text as String
Dim Image_bitmap as Bitmap
Dim m as Map
ItemList = parser.NextArray
For i = 1 to ItemList -1' get all db records
m = ItemList.Get(i)
Image_blob = m.Get("ProductImage") ' stored the blob text
Label1_text = m.Get("ProductName")'stored the text field
'Convert blob Base64 to bitmap
Dim buffer() As Byte
Dim b As Bitmap
Dim su As StringUtils
buffer = su.DecodeBase64(t1)
Dim In As InputStream
In.InitializeFromBytesArray(buffer, 0, buffer.Length)
b.Initialize2(In)
Image_bitmap = b 'bitmap image
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, 250dip, 250dip)
CLV1.Add(p, Image_bitmap, Label1_text )' add image and label text to CLV
Next
End Select
Else
Log(Job.ErrorMessage)
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End If
I need to incorporate the above code into the following original code of the ImageDownloader2 JobDone sub:
(Link: https://www.b4x.com/android/forum/threads/imagedownloader-the-simple-way-to-download-images.30875/)
B4X:
If Job.Success = True Then
If Job.JobName = "PageJob" Then
Dim m As Matcher = Regex.Matcher("class=\""darkbox\""><img src=\""([^""]+)""", Job.GetString)
Do While m.Find
links.Add(m.Group(1))
Loop
BuildItems
End If
Else
Log(Job.ErrorMessage)
End If
Hope anybody can help how to achieve this or sample code.
Last edited: