aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/network/HtmlImage.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/network/HtmlImage.java')
-rw-r--r--main/src/cgeo/geocaching/network/HtmlImage.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/network/HtmlImage.java b/main/src/cgeo/geocaching/network/HtmlImage.java
index 8ee2ba7..9c55fe9 100644
--- a/main/src/cgeo/geocaching/network/HtmlImage.java
+++ b/main/src/cgeo/geocaching/network/HtmlImage.java
@@ -25,6 +25,7 @@ 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;
@@ -132,6 +133,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 (FileUtils.isFileUrl(url)) {
+ return Observable.defer(new Func0<Observable<? extends BitmapDrawable>>() {
+ @Override
+ public Observable<? extends BitmapDrawable> call() {
+ final Bitmap bitmap = loadCachedImage(FileUtils.urlToFile(url), true).getLeft();
+ return bitmap != null ? Observable.from(ImageUtils.scaleBitmapToFitDisplay(bitmap)) : Observable.<BitmapDrawable>empty();
+ }
+ }).subscribeOn(RxUtils.computationScheduler);
+ }
+
final boolean shared = url.contains("/images/icons/icon_");
final String pseudoGeocode = shared ? SHARED : geocode;