diff options
author | Samuel Tardieu <sam@rfc1149.net> | 2012-06-17 13:18:43 +0200 |
---|---|---|
committer | Samuel Tardieu <sam@rfc1149.net> | 2012-06-17 13:18:43 +0200 |
commit | d802aa775188458c6639338821d8f13f5191c9bf (patch) | |
tree | 310ac6d5191a321fca3e5aa9beec3a7a964ec50b /main/src/cgeo/geocaching | |
parent | 4cfa9802ed20d1ba979ca95c75b39e5d2facd890 (diff) | |
parent | 903ac4252151004f27e975384f71defbfb11f1e1 (diff) | |
download | cgeo-d802aa775188458c6639338821d8f13f5191c9bf.zip cgeo-d802aa775188458c6639338821d8f13f5191c9bf.tar.gz cgeo-d802aa775188458c6639338821d8f13f5191c9bf.tar.bz2 |
Merge branch 'release' into upstream
Conflicts:
main/res/values/strings.xml
Diffstat (limited to 'main/src/cgeo/geocaching')
-rw-r--r-- | main/src/cgeo/geocaching/network/HtmlImage.java | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/main/src/cgeo/geocaching/network/HtmlImage.java b/main/src/cgeo/geocaching/network/HtmlImage.java index b9ce732..288336d 100644 --- a/main/src/cgeo/geocaching/network/HtmlImage.java +++ b/main/src/cgeo/geocaching/network/HtmlImage.java @@ -96,7 +96,9 @@ public class HtmlImage implements Html.ImageGetter { if (statusCode == 200) { LocalStorage.saveEntityToFile(httpResponse, file); } else if (statusCode == 304) { - file.setLastModified(System.currentTimeMillis()); + if (!file.setLastModified(System.currentTimeMillis())) { + makeFreshCopy(file); + } } } } catch (Exception e) { @@ -128,6 +130,21 @@ public class HtmlImage implements Html.ImageGetter { return imagePre != null ? ImageHelper.scaleBitmapToFitDisplay(imagePre) : null; } + /** + * Make a fresh copy of the file to reset its timestamp. On some storage, it is impossible + * to modify the modified time after the fact, in which case a brand new file must be + * created if we want to be able to use the time as validity hint. + * + * See Android issue 1699. + * + * @param file the file to refresh + */ + private static void makeFreshCopy(final File file) { + final File tempFile = new File(file.getParentFile(), file.getName() + "-temp"); + file.renameTo(tempFile); + LocalStorage.copy(tempFile, file); + tempFile.delete(); + } private Bitmap getTransparent1x1Image() { return BitmapFactory.decodeResource(resources, R.drawable.image_no_placement); |