aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/ui/DirectionImage.java
blob: 98b8767c17acb466012d05dd87739b8b921dc8f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package cgeo.geocaching.ui;

import cgeo.geocaching.files.LocalStorage;
import cgeo.geocaching.network.Network;

import ch.boye.httpclientandroidlib.HttpResponse;
import org.apache.commons.lang3.StringUtils;

import java.io.File;

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));
        }
    }

    public static File getDirectionFile(final String geocode, final boolean createDirs) {
        return LocalStorage.getStorageFile(geocode, "direction.png", false, createDirs);
    }

}