Hi
Using Firemonkey, I'm programmatically creating "TTMSFNCImage"s on a TVertScrollBox and downloading images to each one from URLs using the TTMSFNCImage.Bitmap.LoadFromURL function. I have the following issue. Sometimes, some of the images are not being loaded, sometimes only a part of the image is being loaded.
Any way to make sure that all images are downloaded?
Moreover, how can I make sure that the first 2-3 images load before the other images are downloaded and loaded?
This is an example of the code I'm using:
procedure TForm1.LoadAllImages;
var
i: integer;
CurrentImage: TTMSFNCImage;
begin
for i:= 1 to 20 do begin
CurrentImage:= TTMSFNCImage.Create(VertScrollBox1);
TTask.Run(
procedure
begin
CurrentImage.Bitmap.LoadFromURL('https://mywebsite.com/Image'+i.ToString+'.jpg');
end);
CurrentImage.Parent:= VertScrollBox1;
end;
end;
Btw, the reason I'm using TTask is that if I don't use it, I'm getting an android.os.NetworkOnMainThread exception on Android.