Git Product home page Git Product logo

jet-image-loader's Introduction

JetImageLoader load, cache, show, do it again!

Fast and powerful image loader with memory and storage caching for your Windows Phone 7+ projects!

(Many ideas were taken from UniversalImageLoader for Android)

####Like a boss:

  • Load images
  • Cache them in memory
  • Cache them on storage
  • Do it asynchronously

sample screenshot

##Why JetImageLoader is super?##

####0) It was created to work as Converter! Look:

<Image Source="{Binding YourImageUri, Converter={StaticResource MyAppJetImageLoaderConverter}}"/>

#####WOW, yeah? Super awesome!

##How to add && configure JetImageLoader in your project?

  1. Easy to add to your project and start using it in only 4 simple steps:
  • 1.1) Add reference to JetImageLoader.dll or use nuget: PM> Install-Package WP-JetImagLoader
  • 1.2) Extend JetImageLoaderConverter and configure it:
    public class MyAppJetImageLoaderConverter : BaseJetImageLoaderConverter
    {
        protected override JetImageLoaderConfig GetJetImageLoaderConfig()
        {
            return new JetImageLoaderConfig.Builder
            {
                IsLogEnabled     = true,
                CacheMode        = CacheMode.MemoryAndStorageCache,
                DownloaderImpl   = new HttpWebRequestDownloader(),
                MemoryCacheImpl  = new WeakMemoryCache(),
                StorageCacheImpl = new LimitedStorageCache(IsolatedStorageFile.GetUserStoreForApplication(), 
                                   "\\image_cache", new SHA1CacheFileNameGenerator(), 1024 * 1024 * 10), // == 10 MB
            }.Build();
        }
    }
  • 1.3) Declare MyAppJetImageLoaderConverter in App.xaml:
    ````
    
    
    ...````
  • 1.4) Set it as Converter for Image:
    ````````

aaand that is all, now it can load images from network, cache them in memory and storage and then load them from cache!

  1. You can use your own implementations:
    Downloader implementation    — just implement IDownloader interface
    Memory cache implementation  — just extend BaseMemoryCache abstract class
    Storage cache implementation — just extend BaseStorageCache abstract class
  1. JetImageLoader already has basic implementations for all this things:
    1 Downloader implemetation      — HttpWebRequestDownloader based on HttpWebRequest class
    1 Memory cache implementation   — WeakMemoryCache based on WeakRefDictionary with weak references
                                     and auto GC cleaning (very cool)
    2 Storage cache implementations — LimitedStorageCache with configurable limit in bytes to store on disk
                                     and stupid UnlimitedStorageCache implementation

####NuGet: PM> Install-Package WP-JetImagLoader

jet-image-loader's People

Contributors

artem-zinnatullin avatar nearga avatar rahulpnath avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jet-image-loader's Issues

Invalid XAML

I'm trying to implement jet on my project but i have this error:

A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in System.Windows.ni.dll

Additional information: Cannot create instance of type 'Cartao_de_Visitas.Classes.JetImageLoaderConverter' [Line: 12 Position: 44]

And my page have this area as invalid XAML

                <DataTemplate>
                    <Grid Margin="12 0 12 0">
                        <Image Height="200" Source="{Binding ImageUrl, Converter={StaticResource JetImageLoaderConverter}}"/>
                    </Grid>
                </DataTemplate>

Different cache folders or something like that

Copy from: fbcdda4#commitcomment-4651297

"Hey Artem.. Is it Possible to cache Images over Isolated Storage as per the categories in which they comes from so i can be able to use those cached images over application where i have needed.

For Ex. Currently i am caching Facebook friends over device and want to show them over some of internal tiles but the "images_cache" folder is having all files which comes from different categories and i can't track them which are Facebook friends images, If it's categorized it can save my application network usage."

Image does not finish downloading

Sometimes when there is limited connectivity, an image will not finish downloading and it will cache as an incomplete image. Most of the time it will show half of the image, and the rest of the image will be gray. How can I fix this issue?

Frequent Crashing due to Image Loader

I installed BugSense in my app and have been tracking my crashes. This image loader is the biggest culprit. Here is my stack trace, any ideas?

0System.AggregateException: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. ---> System.IO.IsolatedStorage.IsolatedStorageException: Operation not permitted on IsolatedStorageFileStream.
1 at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, IsolatedStorageFile isf)
2 at JetImageLoader.Cache.Storage.BaseStorageCache.d__0.MoveNext()
3--- End of stack trace from previous location where exception was thrown ---
4 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
5 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
6 at JetImageLoader.Cache.Storage.CacheImpl.LimitedStorageCache.d__2.MoveNext()
7 --- End of inner exception stack trace ---
8---> (Inner Exception #0) System.IO.IsolatedStorage.IsolatedStorageException: Operation not permitted on IsolatedStorageFileStream.
9 at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, IsolatedStorageFile isf)
10 at JetImageLoader.Cache.Storage.BaseStorageCache.d__0.MoveNext()
11--- End of stack trace from previous location where exception was thrown ---
12 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
13 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
14 at JetImageLoader.Cache.Storage.CacheImpl.LimitedStorageCache.d__2.MoveNext()<---
15
16--- Inner exception of type System.IO.IsolatedStorage.IsolatedStorageException start ---
17--- Message: Operation not permitted on IsolatedStorageFileStream. ---
18System.IO.IsolatedStorage.IsolatedStorageException: Operation not permitted on IsolatedStorageFileStream.
19 at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, IsolatedStorageFile isf)
20 at JetImageLoader.Cache.Storage.BaseStorageCache.d__0.MoveNext()
21--- End of stack trace from previous location where exception was thrown ---
22 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
23 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
24 at JetImageLoader.Cache.Storage.CacheImpl.LimitedStorageCache.d__2.MoveNext()
25--- End of inner exception stack trace ---

Not showing images when using DesignData

At design time, when I use code below in xaml, images are dissapear, hoping design time will use MemoryCacheImpl.

d:DataContext="{d:DesignData /Samples/Data.xaml}"

converter is :

        if (!System.ComponentModel.DesignerProperties.IsInDesignTool)
        {
            return new JetImageLoaderConfig.Builder
            {
                IsLogEnabled = true,
                CacheMode = CacheMode.MemoryAndStorageCache,
                DownloaderImpl = new HttpWebRequestDownloader(),
                MemoryCacheImpl = memoryCacheImpl,
                StorageCacheImpl = new LimitedStorageCache(IsolatedStorageFile.GetUserStoreForApplication(),
                    "\\CacheImages", new SHA1CacheFileNameGenerator(), 1024 * 1024 * 10), // == 10 MB
            }.Build();
        }
        else
            return new JetImageLoaderConfig.Builder 
            {
                IsLogEnabled = true,
                CacheMode = CacheMode.OnlyMemoryCache,
                DownloaderImpl = new HttpWebRequestDownloader(),
                MemoryCacheImpl = memoryCacheImpl
            }.Build();

set default/loading/fail-image?

Hi,

Is it possible to set specific images to be displayed while an image is loading/loading failed/etc.?

Android-Universal-Image-Loader has this option in DisplayImageOptions via:
.showImageOnLoading(R.drawable.ic_stub) // resource or drawable
.showImageForEmptyUri(R.drawable.ic_empty) // resource or drawable
.showImageOnFail(R.drawable.ic_error) // resource or drawable

Thanks for this great project & your hard work!

Works only for SilverLight applications

Can't use on Windows Phone 8.1 (non-silverlight) due to system libraries not matching .
For example IValueConverter namespace is different between
wpa81: Windows.UI.Xaml.Data.IValueConverter (non-silverlight)
wp80 : System.Windows.Data.IValueConverter (silverlight)

Screen is flickering once presses back button

I found one more issue and below is the scenario to replicate it, please have a look on it.

Step 1: Bind a List with Data Template

                            </StackPanel>
                        </DataTemplate>

Step 2: On press of any list item image click it will show some other Panorma Item and once user press back button to see the list of images it will bind the list and while binding images from cache it Flicker and looks annoying as per user prospective.

Jet-Image Loader is not working with my Aync Methods

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


                            </StackPanel>
                        </DataTemplate>
                    </ctl:LongListSelector.ItemTemplate>
                </ctl:LongListSelector>

Code:

public class GetGreetingSchema {

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

public ObservableCollection<GetGreetingSchema> greetingsList { get; private set; }
    public card_List3()
    {
        InitializeComponent();
        greetingsList = new ObservableCollection<GetGreetingSchema>();
        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

Use TimeSpan instead of long

It would be more user friendly to set TimeSpan.FromDays(7) (and/or to add extension TimeSpan.FromWeeks, or maybe even implement own Period class).

[wp7] IsoStorageException "An error occured while accessing IsoStorage"

http://clip2net.com/clip/m0/1384008861-clip-47kb.png

Appears on Lumia 800.

Callstack:
System.IO.IsolatedStorage.IsolatedStorageException occurred
Message=An error occurred while accessing IsolatedStorage.
StackTrace:
at System.IO.IsolatedStorage.IsolatedStorageFile.GetLastAccessTime(String path)
at JetImageLoader.Cache.Storage.CacheImpl.LimitedStorageCache.b__7()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
at System.Threading.Tasks.Task.ExecuteWithThreadLocal()
at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
at System.Threading.Tasks.TaskScheduler.TryExecuteTask(Task task)
at System.Threading.Tasks.ThreadPoolTaskScheduler.<.ctor>b__0(Object state)
at System.Threading.ThreadPool.WorkItem.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadPool.WorkItem.doWork(Object o)
at System.Threading.Timer.ring()

Possible System.IndexOutOfRangeException

BaseJetImageLoaderConverter: Deployment.Current.Dispatcher.BeginInvoke(() => bitmapImage.SetSource(getImageStreamTask.Result); can produce System.IndexOutOfRangeException

Windows Phone 7 Support

Is there any chance for WP7 support or does this toolkit require something from WP8 that is unavailable in WP7? Attempting to use this now in a WP7 app results in this error:

The primary reference "JetImageLoader" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Windows, Version=2.0.6.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e" which has a higher version "2.0.6.0" than the version "2.0.5.0" in the current target framework.

Error referencing JetImageLoader

Hi, I'm trying to use this lib with WP7, but the next warning appears in the Error list:

The primary reference "JetImageLoader" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Windows, Version=2.0.6.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e" which has a higher version "2.0.6.0" than the version "2.0.5.0" in the current target framework.

This shouldn't be a problem if this error won't let me compile the project (I'm trying to reference JetImageLoader in my converter exactly as it is explained in the README):

The type or namespace name 'JetImageLoader' could not be found (are you missing a using directive or an assembly reference?)

I'm using the BCL library from Microsoft to use async/await, if that is important. I've read all the issues here, but none of them has helped me.

Can any of you guide mi in the right direction?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.