Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-1569] Android: Implement Image Cache

GitHub Issuen/a
TypeNew Feature
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:56:32.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.5.0 M04
ComponentsAndroid
Labelsandroid, feature
ReporterDon Thorp
AssigneeDon Thorp
Created2011-04-15T02:56:16.000+0000
Updated2011-04-17T01:56:32.000+0000

Description

Remote images are currently downloaded, but not cached. Add support for better background downloading and caching of images.

Comments

  1. Don Thorp 2011-04-15

    My prototype code for the feature is on this branch https://github.com/appcelerator/titanium_mobile/tree/dst-cachit">dst-cachit it was done in 1_4_X so it'll have to be ported to 1.5.

    The goal of this support was to replace the current background download of images which doesn't know if something is already downloaded. I also wanted to provide a cleanup thread and some cache configuration parameters like max # items, max mbs, scan frequency. We should also add a clear method that could be invoked. Eventually we'll turn this into a media agnostic cache manager, but the initial need is for remote images. Especially wrt to TableViews use of them.

  2. Bill Dawson 2011-04-15

    The remote image test in KS (Base UI - Views - Image Views - Remote Image). Is it related to changes made for this ticket? Tested with c680f8c in 2.1 emulator. I verified that my emulator has an sdcard.

    There should also be a drillbit test for remote image.

    Logcat:

       E/TiDrawableReference(  326): java.io.FileNotFoundException: /sdcard/com.appcelerator.titanium/remote-image-cache/46b7e15e92d07bc31815c72c06be3693b5f73bed.hdr
       E/TiDrawableReference(  326):   at org.apache.harmony.luni.platform.OSFileSystem.open(OSFileSystem.java:244)
       E/TiDrawableReference(  326):   at java.io.FileInputStream.<init>(FileInputStream.java:77)
       E/TiDrawableReference(  326):   at java.io.FileReader.<init>(FileReader.java:42)
       E/TiDrawableReference(  326):   at org.appcelerator.titanium.util.TiResponseCache.get(TiResponseCache.java:179)
       E/TiDrawableReference(  326):   at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getFromCache(HttpURLConnection.java:848)
       E/TiDrawableReference(  326):   at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:755)
       E/TiDrawableReference(  326):   at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1051)
       E/TiDrawableReference(  326):   at java.net.URL.openStream(URL.java:653)
       E/TiDrawableReference(  326):   at org.appcelerator.titanium.util.TiFileHelper.openInputStream(TiFileHelper.java:147)
       E/TiDrawableReference(  326):   at org.appcelerator.titanium.view.TiDrawableReference.getInputStream(TiDrawableReference.java:359)
       E/TiDrawableReference(  326):   at org.appcelerator.titanium.view.TiDrawableReference.getBitmap(TiDrawableReference.java:171)
       E/TiDrawableReference(  326):   at org.appcelerator.titanium.view.TiDrawableReference.getBitmap(TiDrawableReference.java:233)
       E/TiDrawableReference(  326):   at org.appcelerator.titanium.util.TiBackgroundImageLoadTask.doInBackground(TiBackgroundImageLoadTask.java:71)
       E/TiDrawableReference(  326):   at org.appcelerator.titanium.util.TiBackgroundImageLoadTask.doInBackground(TiBackgroundImageLoadTask.java:28)
       
  3. Bill Dawson 2011-04-15

    This also affects the "Basic" image view test, since it uses a remote url. And the Facebook login test. (Probably other tests too...)

  4. Bill Dawson 2011-04-15

    (from [116948f0cb8a79ceff779c6f8955420d5aab547f]) [#1569] TiResponseCache.get() should return null when cache doesn't contain item. If cachedir doesn't exist, create it. https://github.com/appcelerator/titanium_mobile/commit/116948f0cb8a79ceff779c6f8955420d5aab547f"> https://github.com/appcelerator/titanium_mobile/commit/116948f0cb8a...

  5. Bill Dawson 2011-04-15

    (from [8e66e2c70caf59e50fd9b98641cc2e64acd2311f]) [#1569] Test to guard against TiResponseCache crashing https://github.com/appcelerator/titanium_mobile/commit/8e66e2c70caf59e50fd9b98641cc2e64acd2311f"> https://github.com/appcelerator/titanium_mobile/commit/8e66e2c70caf...

  6. Jeff Haynie 2011-04-15

    (from [a0f4151a5b12ab0a7ed4a77d752ff74c1aeae581]) [#1569 state:fixed-in-qa] work around android SDK bug which calls abort() even on success https://github.com/appcelerator/titanium_mobile/commit/a0f4151a5b12ab0a7ed4a77d752ff74c1aeae581"> https://github.com/appcelerator/titanium_mobile/commit/a0f4151a5b12...

  7. Thomas Huelbert 2011-04-15

    closed against (1.5.0.7d08f15) ks tests used: Basic image test, remote image

  8. Michael Del Tito 2011-04-15

    this is still an issue it seems under 1.5.1

    remote images loaded in a scrollableView are re-downloaded on each scroll

  9. Dawson Toth 2011-04-15

    Michael, are your images getting scaled at all? Or are they the precise size that will be used?

JSON Source