Fix small issues
This commit is contained in:
parent
a6dadcc4c8
commit
2676542d5e
4 changed files with 24 additions and 22 deletions
|
@ -100,7 +100,7 @@ public class OsMoControlDevice implements OsMoReactor {
|
|||
}
|
||||
return true;
|
||||
} else if(command.equals("GPX_GET")) {
|
||||
plugin.getDownloadGpxTask().execute(obj);
|
||||
plugin.getDownloadGpxTask(true).execute(obj);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -286,7 +286,7 @@ public class OsMoGroups implements OsMoReactor, OsmoTrackerListener {
|
|||
}
|
||||
}
|
||||
if(obj.has(TRACK)){
|
||||
plugin.getDownloadGpxTask().execute(obj.getJSONObject(TRACK));
|
||||
plugin.getDownloadGpxTask(true).execute(obj.getJSONObject(TRACK));
|
||||
}
|
||||
if(deleteUsers) {
|
||||
for(OsMoDevice s : toDelete.values()) {
|
||||
|
|
|
@ -324,7 +324,7 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
|
|||
return service;
|
||||
}
|
||||
|
||||
public AsyncTask<JSONObject, GPXFile, String> getDownloadGpxTask() {
|
||||
public AsyncTask<JSONObject, GPXFile, String> getDownloadGpxTask(final boolean makeVisible) {
|
||||
|
||||
return new AsyncTask<JSONObject, GPXFile, String> (){
|
||||
|
||||
|
@ -338,14 +338,15 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
|
|||
for(JSONObject obj : params) {
|
||||
try {
|
||||
File f = new File(fl, obj.getString("name"));
|
||||
long timestamp = obj.getLong("timestamp") * 1000;
|
||||
long timestamp = obj.getLong("created") * 1000;
|
||||
boolean visible = obj.has("visible");
|
||||
boolean changed = false;
|
||||
if(!f.exists() || (fl.lastModified() != timestamp) ) {
|
||||
boolean sizeEqual = f.exists() && obj.has("size") && obj.getLong("size") == f.length();
|
||||
if(sizeEqual && !f.setLastModified(timestamp - 1)){
|
||||
// false alarm
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
changed = true;
|
||||
String url = obj.getString("url");
|
||||
DownloadFileHelper df = new DownloadFileHelper(app);
|
||||
InputStream is = df.getInputStreamToDownload(new URL(url), false);
|
||||
|
@ -358,11 +359,12 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
|
|||
fout.close();
|
||||
is.close();
|
||||
f.setLastModified(timestamp);
|
||||
if(visible) {
|
||||
}
|
||||
}
|
||||
if(visible && (changed || makeVisible)) {
|
||||
GPXFile selectGPXFile = GPXUtilities.loadGPXFile(app, f);
|
||||
app.setGpxFileToDisplay(selectGPXFile, app.getSettings().SHOW_CURRENT_GPX_TRACK.get());
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
errors += e.getMessage() +"\n";
|
||||
|
|
|
@ -276,7 +276,7 @@ public class OsMoService implements OsMoReactor {
|
|||
} else if(command.equals("GET_MY_TRACKS")) {
|
||||
try {
|
||||
JSONArray ar = new JSONArray(data);
|
||||
AsyncTask<JSONObject, GPXFile, String> task = plugin.getDownloadGpxTask();
|
||||
AsyncTask<JSONObject, GPXFile, String> task = plugin.getDownloadGpxTask(false);
|
||||
JSONObject[] a = new JSONObject[ar.length()];
|
||||
for(int i = 0; i < a.length; i++) {
|
||||
a[i] = (JSONObject) ar.get(i);
|
||||
|
|
Loading…
Reference in a new issue