diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2014-01-19 23:57:34 +0100 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2014-01-19 23:57:34 +0100 |
| commit | 92e5ae8fc4ae77a6fe5cf7d961f9e90468eb3b30 (patch) | |
| tree | 78c865cc8cffe2441395ba5c1ae1df4e0d993fd8 | |
| parent | 69749c97db51b8c7116acc14cda415ad2d39eac0 (diff) | |
| download | cgeo-92e5ae8fc4ae77a6fe5cf7d961f9e90468eb3b30.zip cgeo-92e5ae8fc4ae77a6fe5cf7d961f9e90468eb3b30.tar.gz cgeo-92e5ae8fc4ae77a6fe5cf7d961f9e90468eb3b30.tar.bz2 | |
fix #3540: corrupted images on image tab
| -rw-r--r-- | main/src/cgeo/geocaching/network/HtmlImage.java | 12 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/ui/ImagesList.java | 7 |
2 files changed, 8 insertions, 11 deletions
diff --git a/main/src/cgeo/geocaching/network/HtmlImage.java b/main/src/cgeo/geocaching/network/HtmlImage.java index 9f60200..bebce42 100644 --- a/main/src/cgeo/geocaching/network/HtmlImage.java +++ b/main/src/cgeo/geocaching/network/HtmlImage.java @@ -78,7 +78,6 @@ public class HtmlImage implements Html.ImageGetter { final private boolean returnErrorImage; final private int listId; final private boolean onlySave; - final private BitmapFactory.Options bfOptions; final private int maxWidth; final private int maxHeight; final private Resources resources; @@ -97,10 +96,6 @@ public class HtmlImage implements Html.ImageGetter { this.listId = listId; this.onlySave = onlySave; - bfOptions = new BitmapFactory.Options(); - bfOptions.inTempStorage = new byte[16 * 1024]; - bfOptions.inPreferredConfig = Bitmap.Config.RGB_565; - Point displaySize = Compatibility.getDisplaySize(); this.maxWidth = displaySize.x - 25; this.maxHeight = displaySize.y - 25; @@ -299,7 +294,10 @@ public class HtmlImage implements Html.ImageGetter { private Bitmap loadCachedImage(final File file, final boolean forceKeep) { if (file.exists()) { if (listId >= StoredList.STANDARD_LIST_ID || file.lastModified() > (new Date().getTime() - (24 * 60 * 60 * 1000)) || forceKeep) { - setSampleSize(file); + final BitmapFactory.Options bfOptions = new BitmapFactory.Options(); + bfOptions.inTempStorage = new byte[16 * 1024]; + bfOptions.inPreferredConfig = Bitmap.Config.RGB_565; + setSampleSize(file, bfOptions); final Bitmap image = BitmapFactory.decodeFile(file.getPath(), bfOptions); if (image == null) { Log.e("Cannot decode bitmap from " + file.getPath()); @@ -310,7 +308,7 @@ public class HtmlImage implements Html.ImageGetter { return null; } - private void setSampleSize(final File file) { + private void setSampleSize(final File file, final BitmapFactory.Options bfOptions) { //Decode image size only BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; diff --git a/main/src/cgeo/geocaching/ui/ImagesList.java b/main/src/cgeo/geocaching/ui/ImagesList.java index 3848398..1cd5a48 100644 --- a/main/src/cgeo/geocaching/ui/ImagesList.java +++ b/main/src/cgeo/geocaching/ui/ImagesList.java @@ -9,7 +9,7 @@ import cgeo.geocaching.utils.Log; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; -import rx.android.schedulers.AndroidSchedulers; +import rx.android.observables.AndroidObservable; import rx.subscriptions.CompositeSubscription; import rx.util.functions.Action1; @@ -97,14 +97,13 @@ public class ImagesList { descView.setVisibility(View.VISIBLE); } - subscriptions.add(imgGetter.fetchDrawable(img.getUrl()) - .observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<BitmapDrawable>() { + subscriptions.add(AndroidObservable.fromActivity(activity, imgGetter.fetchDrawable(img.getUrl())) + .subscribe(new Action1<BitmapDrawable>() { @Override public void call(final BitmapDrawable image) { display(image, img, rowView); } })); - imagesView.addView(rowView); } } |
