diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2013-05-19 17:17:09 +0200 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2013-05-19 17:17:09 +0200 |
| commit | 7125a7adbaf3cad9687a225032c85a9e7391c603 (patch) | |
| tree | 29ed4e45e9333cc57af2087c0213aa9f48b6b49b /main/src/cgeo/geocaching/ui/DirectionImage.java | |
| parent | 4dcdf0c6220ff8c9149f91b251da39b905b71191 (diff) | |
| download | cgeo-7125a7adbaf3cad9687a225032c85a9e7391c603.zip cgeo-7125a7adbaf3cad9687a225032c85a9e7391c603.tar.gz cgeo-7125a7adbaf3cad9687a225032c85a9e7391c603.tar.bz2 | |
enhancement: share direction images for basic members
Use the regular images cache for basic members direction images in cache
list.
Part of work on #2733.
Diffstat (limited to 'main/src/cgeo/geocaching/ui/DirectionImage.java')
| -rw-r--r-- | main/src/cgeo/geocaching/ui/DirectionImage.java | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/main/src/cgeo/geocaching/ui/DirectionImage.java b/main/src/cgeo/geocaching/ui/DirectionImage.java index 98b8767..df7275d 100644 --- a/main/src/cgeo/geocaching/ui/DirectionImage.java +++ b/main/src/cgeo/geocaching/ui/DirectionImage.java @@ -1,29 +1,22 @@ package cgeo.geocaching.ui; -import cgeo.geocaching.files.LocalStorage; -import cgeo.geocaching.network.Network; +import cgeo.geocaching.StoredList; +import cgeo.geocaching.network.HtmlImage; -import ch.boye.httpclientandroidlib.HttpResponse; -import org.apache.commons.lang3.StringUtils; - -import java.io.File; +import android.graphics.drawable.BitmapDrawable; public class DirectionImage { - public static void getDrawable(final String geocode, final String code) { - if (StringUtils.isBlank(geocode) || StringUtils.isBlank(code)) { - return; - } - - final HttpResponse httpResponse = - Network.getRequest("http://www.geocaching.com/images/icons/compass/" + code + ".gif"); - if (httpResponse != null) { - LocalStorage.saveEntityToFile(httpResponse, getDirectionFile(geocode, true)); - } - } + static private HtmlImage htmlImage = new HtmlImage(HtmlImage.SHARED, false, StoredList.STANDARD_LIST_ID, false); - public static File getDirectionFile(final String geocode, final boolean createDirs) { - return LocalStorage.getStorageFile(geocode, "direction.png", false, createDirs); + /** + * Retrieve the direction image corresponding to the direction code. + * + * @param directionCode one of the eight cardinal points + * @return a drawable with the arrow pointing into the right direction + */ + public static BitmapDrawable getDrawable(final String directionCode) { + return htmlImage.getDrawable("http://www.geocaching.com/images/icons/compass/" + directionCode + ".gif"); } } |
