Giter VIP home page Giter VIP logo

shutterbug's Introduction

Shutterbug - Remote image loader with caching for Android

Shutterbug is an Android library that lets you fetch remote images and cache them. It is particularly suited for displaying remote images in lists or grids as it includes a convenience subclass of ImageView (FetchableImageView) that make implementation a one-liner.

A dual memory and disk cache was implemented. It makes use of two backports of Android classes: LruCache for the memory part and DiskLruCache for the disk part. LruCache was introduced by API Level 12, but we provide it here as a standalone class so you can use the library under lower level APIs. Both LruCache and DiskLruCache are licensed under the Apache Software License, 2.0.

Shutterbug was inspired by SDWebImage which does the same thing on iOS. It uses the same structure and interface. People who are familiar with SDWebImage on iOS will feel at home with Shutterbug on Android.

How to use

First, ensure that the following permissions were added to your AndroidManifest.xml file:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

Then, you just have to add the jar or the library project to your project.

Basic usage

You only need a context, an url and an ImageView:

ShutterbugManager.getSharedImageManager(context).download(url, imageView);

Using FetchableImageView

  1. Instantiate the subclass (either in your code or in an xml file, for example by replacing ImageView by com.applidium.shutterbug.FetchableImageView).
  2. Fetch the image (setImage(String url) or setImage(String url, Drawable placeholderDrawable) if you need to add a placeholder while waiting for the image to be fetched)
  3. That's it!

We also provide you with a listener interface (FetchableImageViewListener) which will help you refresh your UI if need.

Using ShutterbugManager

If you need to do more advanced coding, you can use ShutterbugManager. It is a singleton class whose instance is accessed by the static method ShutterbugManager.getSharedManager(context). Downloading and caching is done by calling download(String url, ShutterbugManagerListener listener) on this instance.

shutterbug's People

Contributors

acq avatar

Watchers

James Cloos avatar  avatar

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.