diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2014-04-24 12:16:07 +0200 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2014-04-24 12:16:07 +0200 |
| commit | 56984c893b40b8b692baf3c9ed6b65726c7b4027 (patch) | |
| tree | 954056069e843383aecba31a9d9a2aaf441c7f70 /main/src/cgeo/geocaching | |
| parent | 06cd3b2c0e6d7e0a8eb6f495f932068120cd3dab (diff) | |
| download | cgeo-56984c893b40b8b692baf3c9ed6b65726c7b4027.zip cgeo-56984c893b40b8b692baf3c9ed6b65726c7b4027.tar.gz cgeo-56984c893b40b8b692baf3c9ed6b65726c7b4027.tar.bz2 | |
Add local file loading capability
This will be used in implementation of #3438.
Diffstat (limited to 'main/src/cgeo/geocaching')
| -rw-r--r-- | main/src/cgeo/geocaching/network/HtmlImage.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/network/HtmlImage.java b/main/src/cgeo/geocaching/network/HtmlImage.java index 8ee2ba7..ae9821b 100644 --- a/main/src/cgeo/geocaching/network/HtmlImage.java +++ b/main/src/cgeo/geocaching/network/HtmlImage.java @@ -25,10 +25,12 @@ import rx.Scheduler; import rx.Scheduler.Inner; import rx.Subscriber; import rx.functions.Action1; +import rx.functions.Func0; import rx.functions.Func1; import rx.schedulers.Schedulers; import rx.subjects.PublishSubject; import rx.subscriptions.CompositeSubscription; +import rx.util.async.Async; import android.content.res.Resources; import android.graphics.Bitmap; @@ -132,6 +134,18 @@ public class HtmlImage implements Html.ImageGetter { return Observable.from(getTransparent1x1Image(resources)); } + // Explicit local file URLs are loaded from the filesystem regardless of their age. The IO part is short + // enough to make the whole operation on the computation scheduler. + if (url.startsWith("file://")) { + return Async.fromCallable(new Func0<BitmapDrawable>() { + @Override + public BitmapDrawable call() { + final Bitmap bitmap = loadCachedImage(new File(url.substring(7)), true).getLeft(); + return bitmap != null ? ImageUtils.scaleBitmapToFitDisplay(bitmap) : null; + } + }, RxUtils.computationScheduler); + } + final boolean shared = url.contains("/images/icons/icon_"); final String pseudoGeocode = shared ? SHARED : geocode; |
