Hey list,
I hope you all had a nice christmas and didn't spend too much time
digging through some code these days. :o)
Here's the latest update concerning the improved download function in
callback-android: The cancel() function!
var ft = FileTransfer();
ft.download("http://foo.bar/download.zip", progessCB, errorCB);
Now the download starts and calls progressCB with a FileDownloadResult
(see my last message) periodically. You can now do:
ft.cancel()
And the download thread is stopped! This calls errorCB once.
I am looking forward to your feedback and it would be awesome if we
could get this feature into core, as I am quite sure that almost every
user who uses the download function would like to monitor and control
the transfer.
All the best for the new year!
Jörg
PS: I have some resources available to help with coding. We just need to
agree how it should be done. I cannot make a decision, but I can make
the code after the community / project managers have made the decision.
PPS: Even though I am not an experienced Objective-C developer I'd
volunteer for the job of implementing these additional functions on
iPhone as well, if there's nobody else who can do it better and
faster. :)
Am Sonntag, den 18.12.2011, 16:29 +0100 schrieb Jörg Sawatzki:
> Hi list,
>
> first of all I'd like to thank everybody involved in the project for the
> excellent work you have done! I am using phonegap/callback for an app
> that gives teachers and students access to educational resources like
> video clips, documents, charts and interactive materials which are
> distributed online by the state of Lower Saxony (Germany).
> The app not only allows to bookmark items and manage items in folders,
> but should provide a way to download the files to the mobile device and
> use them offline.
>
> This is where the new FileTransfer.download() function comes in - it
> basically works, but has two main issues:
>
> 1. You never know when a download is finished. You can just display a
> "please be patient" message - if they download a 50 megs video clip they
> might get confused if they aren't informed about the progress.
>
> 2. There's no way to cancel a download. If somebody accidently clicked
> the download button, he has to wait until it is finished or kill the
> app/shutdown the device.
>
> I have tried to address issue 1 for the android platform:
>
> How it works:
> Use FileTransfer.download(source, target, success, error) as usual.
>
> Whenever the download changes it progress, the succes callback is called
> with a FileDownloadResult (inspired by FileUploadResult) as parameter,
> which looks like this:
>
> {
> completed: false,
> bytesReceived: 1000,
> bytesTotal: 2000,
> percentCompleted: 50.0,
> responseCode: 200,
> }
>
> When the download has finished, the "completed" property is set to true
> and the "fileEntry" property is set and contains the FileEntry object
> pointing to the downloaded file.
>
> Have a look at the commit to see how this works:
> https://github.com/joerg86/callback-android/commit/f7d94812cdbf4fc8c1e7d343065502a07b85836e
>
> Keep in mind that this is just a quick prototype that I would like to
> share and discuss with you. I'd highly appreciate if you check it out
> and tell me your ideas and thoughts.
>
> I hope this is a good starting point and we can find a good way to get
> something like this going in the callback core as soon as possible.
> Users will expect this functionality if they download more than a few
> hundred kilobytes.
>
> Thanks in advance for your feeback and have a nice day. :o)
>
> Jörg
>