I am downloading a bunch of images from google drive and for each file I download, i am creating a dynamic image component, and plugging in the image in that dynamic component. Problem is, because it is taking quite some time, i want to show a download progress.
So this is a simple pseudocode for what I am doing.
for each url in list {
Create dc.image component;
set loadingProgress.text to previous value + 1;
}
Now the images come up perfectly fine but the loading progress label does not increase its value each time by 1. It seems like the app is frozen until all the files have been downloaded. I am including the aia file, in case you want to look into it.
P.S. this downloading will not occur when the app is run for the first time, because there will be about a thousand files to download, and the app will download questions only for the topics selected by the user.
I am not exactly downloading it to a specific location yet. I will do that later. For now what I am doing is setting the picture of the dynamic image component to the file stored in google drive.
Now you asked where am I doing that. See the "When clk.Timer" block, it is the green block that says "Set Image.Picture (ofComponent, to)". I hope this helps.
Loops are useless for showing the progress of long running tasks like downloads.
Instead, set aside a temporary global list to act as a download queue.
At start of downloads, load the queue with the names of the files you want.
Issue a download request for the file at item 1 of the queue.
When a file arrives, use the file name from item 1 of the queue to stash the file appropriately, then remove item 1 from the queue.
If the queue is not empty, update the display and request the next download, otherwise close the progress notifier and enable the rest of your app.
For a progress notifier text, you could use length of list of the download queue.
Inside When clk.timer, just before the if condition I have this block
set lbl_LoadingProgress.Text to join (num_FileDownloaded, endValue).
This is where I am trying to update the number of files that have been downloaded.
Sorry for misleading you. Taifun is correct. I am actually not downloading the file ... just displaying them. I will work on download later, but at the moment all I am trying to do is display the files one by one from google drive and update the number of files that have been displayed.
My question now is, while these files are coming in from Google Drive, does the app get frozen?
Like I said, I will get the files to download to the phone later, so i have not really looked into it, and therefore I do not understand what ASD, Shared folder, PrivateDir means. Will you please point me in the right direction?
I quite don't understand which block i will use other than for and while loops to do things one by one. I know I should not ask you to write the blocks for me, but what I don't understand is this bit:
Read again my previous answer, understand the concept of a Recyclerlist and use that solution... also why not displaying the images directly from the server... There is no need to download them. .
Sorry for the late reply. Which server are you talking about? Are you talking about using the upload button in the Designer/Blocks tabs? There are two problems with that. Firstly, as far as I know there is no way to upload groups of files, and I have lots and lots of them, in the vicinity of a thousand maybe. Secondly the app has a limit of 50 MB if I am not wrong, and it will seriously be impossible to manage within that size.
I have looked into it, but it seems a bit complicated right now. Actually I am a high school mathematics teacher, and I also need to taking coaching classes all day long, so whenever I get some time, I do what I can in AI2. So if nothing else works out, I will give this a shot. But till then I will wait on your reply about displaying the images directly from the server.
How many images are we talking about here - thousands?
What size are all the images together? How about downloading the images from the server first and displaying the sequential number of the images in the DownloadCompleted event? When should which and how many images be displayed (at the same time?)?