Smile-SA / cordova-plugin-fileopener

24 stars 28 forks source link

Do something while file is downloading... #8

Closed ultrasamad closed 8 years ago

ultrasamad commented 8 years ago

Is there a way of calling a function or showing a loading spinner when the app is downloading the file from a server? Which method should I invoke?

marob commented 8 years ago

Nothing is designed for this in the plugin, but you could try:

var onSuccess = function(data) {
    hideSpinner();
    // Do something
};
function onError(error) {
    hideSpinner();
    // Do something
}
showSpinner();
window.cordova.plugins.FileOpener.openFile("http://www.website.com/file.pdf", onSuccess, onError);

with showSpinner and hideSpinner, 2 functions that manages the spinner display.

ultrasamad commented 8 years ago

Thanks , I will try it. On Jan 20, 2016 7:05 PM, "Maxime Robert" notifications@github.com wrote:

Nothing is designed for this in the plugin, but you could try:

var onSuccess = function(data) { hideSpinner(); // Do something };function onError(error) { hideSpinner(); // Do something }showSpinner();window.cordova.plugins.FileOpener.openFile("http://www.website.com/file.pdf", onSuccess, onError);

with showSpinner and hideSpinner, 2 functions that manages the spinner display.

— Reply to this email directly or view it on GitHub https://github.com/Smile-SA/cordova-plugin-fileopener/issues/8#issuecomment-173326515 .

ultrasamad commented 8 years ago

That works perfect. I love this plugin

marob commented 8 years ago

Thanks!