cache tiles without lastModified header field for 2 months instead of
updating them every time
This commit is contained in:
parent
de521112f5
commit
90871774c3
@ -29,8 +29,15 @@ public class DownloadTile extends AsyncTask<String, Void, Boolean> {
|
||||
tileUrl = new URL(urls[0]);
|
||||
conn = tileUrl.openConnection();
|
||||
final File file = new File(mFilePath);
|
||||
// some tiles don't have the lastModified header field set
|
||||
// ...update tile every two month
|
||||
final long updateTime = 2 * 30 * 24 * 60 * 60 * 1000;
|
||||
final long systemTime = System.currentTimeMillis();
|
||||
final long urlLM = conn.getLastModified();
|
||||
final long fileLM = file.lastModified();
|
||||
if (urlLM == 0 && (fileLM > systemTime - updateTime)) return true;
|
||||
// update tile if needed, else return
|
||||
if (conn.getLastModified() < file.lastModified()) return true;
|
||||
if (urlLM < fileLM) return true;
|
||||
InputStream is = null;
|
||||
is = conn.getInputStream();
|
||||
Log.d("writing to file: " + file.toString());
|
||||
|
Loading…
x
Reference in New Issue
Block a user