luberda-molinet / FFImageLoading

Image loading, caching & transforming library for Xamarin and Windows
MIT License
1.42k stars 377 forks source link

FileWriteFinished is never being called #446

Closed Almis90 closed 7 years ago

Almis90 commented 7 years ago

The image url is http://media2.giphy.com/media/26BROh4qLWbwq7A1a/200w_d.gif

 var control = itemView.FindViewById<GifImageView>(Resource.Id.giphy_gif_image_view);
 var vm = DataContext as Giphy;

ImageService.Instance.LoadUrl(vm.Images.FixedWidthDownsampled.Url, TimeSpan.FromHours(1)).Success(async (arg1, arg2) =>
{
    await Task.Delay(2000);
    if (arg1.FilePath != null)
    {
        control.SetBytes(File.ReadAllBytes(arg1.FilePath));
        control.StartAnimation();
    }
}).FileWriteFinished((fwi) => {

}).DownloadOnly();

I put breakpoint but it not breaks there.

Edit: Missed the DownloadOnly() from code

EmmanVazz commented 7 years ago

You need put that image into a view. So you need a .Into(_imageView) at the end of the LoadUrl, like in the wiki.

Almis90 commented 7 years ago

It may work but why it should fire only when you loading into a view? The method name suggests that it will fire whenever file finishes writing.

daniel-luberda commented 7 years ago

@Almis90 @EmmanVazz

Calling just ImageService.Instance.LoadUrl only creates image loading task, doesn't run it. To run task you have to call:

Preload / DownloadOnly will allow you to load image without loading it into a view.

Almis90 commented 7 years ago

Sorry I don't know how I missed it from my code but at the end I already have DownloadOnly(). It seems like it sometimes work and sometimes not (Most times not). I will make a repo and post it here.

akshay2000 commented 7 years ago

I have a similar problem. I have the image already assigned to an ImageView but also want to download it. I see following behavior:

The behavior above is on Android.