artem-zinnatullin / jet-image-loader

WP7+ fast and powerfull image loader with memory and storage caching for your projects!
Apache License 2.0
44 stars 14 forks source link

Jet-Image Loader is not working with my Aync Methods #7

Closed its-veejay closed 10 years ago

its-veejay commented 10 years ago

Hi,

I tried to use Jet-Image Loader on my windows 8 phone application and it works fine over forms but once i try to apply the Jet-Image caching technique over the aync methods which bind information on async mode it won't work, below is the code which i am using:

XAML:

<ctl:LongListSelector x:Name="ListCards" VerticalAlignment="Center" LayoutMode="Grid" ItemsSource="{Binding greetingsList}" SelectionChanged="lstCards_SelectionChanged" GridCellSize="210,170"> ctl:LongListSelector.ItemTemplate

```
                </ctl:LongListSelector.ItemTemplate>
            </ctl:LongListSelector>
# Code:

 public class GetGreetingSchema {
    public Uri ImgPath
   {
      get { return _ImgPath; }
      set
       {
        SetProperty(ref _ImgPath, value);
       }
   }      
  }

public ObservableCollection greetingsList { get; private set; } public card_List3() { InitializeComponent(); greetingsList = new ObservableCollection(); DataContext = this; }

protected override async void OnNavigatedTo(NavigationEventArgs e)
{
    base.OnNavigatedTo(e);           
    try
    {
        await LoadDataAsync();             
    }
    catch (Exception listbindException)
    {
        ReusableMethods.LogStackTrace(listbindException);             
    }
}

private async Task LoadDataAsync()
{
    var dataSource = new Container().Resolve<IfellowsCollection>();           
    greetingsList = await dataSource.BindGreetingsList(CatId, Contenttype);
    ListCards.ItemsSource = greetingsList;
}


Please let me know if there is some solution with this approach which i am following
artem-zinnatullin commented 10 years ago

Hi, I think the problem is that your list item model has Uri typed property ImgPath with the image link, but BaseImageLoaderConverter can work only with string typed links, try to change type of ImgPath property to string from Uri and reply me if it helps :)

I will add ability to work with Uri typed links for BaseImageLoaderConverter in next release, thank you with that suggestion.

P.S. please edit your issue's markdown, at the moment, XAML and code blocks are displaying incorrectly.

artem-zinnatullin commented 10 years ago

Referencing #8

artem-zinnatullin commented 10 years ago

v0.8.3 now has support of Uri typed values for BaseJetImageLoaderConverter, just update library via NuGet and check how it works with your problem

its-veejay commented 10 years ago

Now it's working like a charm, thanks Artem.

One more point i want to be get cleared before applying Jet-Image over my App, Is Jet-Image Loader replaces the old cached image if server end changes new image which is get cached over the app..

artem-zinnatullin commented 10 years ago

If you are using LimitedStorageCache implementation for storage cache it will delete old files to keep cache size in your limits, so old images will be replaced with new ones.

With JetImageLoader v0.8.3 if your app always displays small number of images with constant URIs, JetImageLoader won't reload them.

I am planing to add support for HEAD requests in v1.0 to check was image changed on server or not without downloading it, and then JetImageLoader will be able to reload image when it was changed on server.

On this week I will add maximum storage cache lifetime, so you will be able to set for example one week cache lifetime period and JetImageLoader will reload it anyway.

Stay tuned, watch JetImageLoader or star it, I'll notify you about that issue :)

its-veejay commented 10 years ago

Maximum storage cache lifetime will be the good solution for cleaning the old images :+1: I will wait for the next JetImageLoader Nuget Update..

artem-zinnatullin commented 10 years ago

@bijendrayadav now JetImageLoader supports CacheMaxLifetimeInMillis for Storage cache, I will prepare new release today you will need to just update JetImageLoader, default cache max lifetime for LimitedStorageCacheImpl is one week.