Code Monkey home page Code Monkey logo

android-image-cache's Introduction

Image Cache

An image download-and-cacher that also knows how to efficiently generate and retrieve thumbnails of various sizes.

Features

  • easily integrates into content-provider backed applications, providing an adapter that can read local and web URLs from a cursor
  • automatic generation and caching of multiple sizes of images based on one downloaded asset
  • provides a disk cache as well as a memory cache
  • automatic disk cache management; no setup necessary, but parameters can be fine-tuned if desired
  • designed to work with your existing setup: no extending a custom application or activity needed
  • cursor adapter supports multiple image fields for each ImageView; skips fields that are null or empty
  • cursor adapter has an automatic progress bar when loading the cursor

Using

Please see the test/ directory for both a simple example of using it as well as some unit tests. When running the application in test/ make sure to run it as an Android activity if you want to see the demo.

Both the unit tests and the interactive test load some images from our lab's servers.

License

MEL Android Image Cache
Copyright (C) 2011-2013 MIT Mobile Experience Lab

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

android-image-cache's People

Contributors

eschlenz avatar xxv 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-image-cache's Issues

improve memory management

At the moment, the image cache doesn't do a good job handling out-of-memory conditions. It occasionally causes an Activity to crash due to memory consumption.

Some tests should be created and memory usage should be profiled to see where it can best be optimized.

add negative cache timeout

If an image URL resolves to a 404, it shouldn't pound on the server trying to download it. Instead, it should have a sane timeout for when it should retry.

This can possibly be done using the LastUpdatedMap in MelAUtils.

add sanity checks for resizing input

Instead of attempting to resize a huge image and causing an OOM error, the library should check to see if it's a reasonable size to scale and go from there.

The idea of a "reasonable size" should be determined empirically based on actual memory consumption for resizing an image using the resize technique used in the library.

It's also possible that resizing a huge image is fairly efficient and that this sanity check is unnecessary.

properly cleanup cache

At the moment, the image cache doesn't actually do any cleanup of its cache. This should be fixed, perhaps with some state persistence using file access times or something like that.

Add positive cache timeout

So that images that get cached are updated, standard HTTP caching techniques should be employed to ensure that they aren't out of date.

This includes conditional HTTP headers, e-tag storing and last-modified storing. The metadata should be stored in a way that hitting the "clear cache" button in the system UI will clear the database too.

It may even make sense to look into using a proper HTTP caching library for this part, while still using this for any resized derivatives. This library will still need to know when to refresh derivatives, so it may need to communicate with the cache.

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.