Removed updating of deleted track. Added update after track downloaded via OsMo.

This commit is contained in:
GaidamakUA 2016-01-29 15:30:40 +02:00
parent ef9cb10426
commit a5905fbe84
2 changed files with 18 additions and 10 deletions

View file

@ -281,8 +281,8 @@ public class OsMoGroups implements OsMoReactor, OsmoTrackerListener {
helper.selectGpxFile(sg.getGpxFile(), false, false); helper.selectGpxFile(sg.getGpxFile(), false, false);
} }
} }
plugin.refreshMap();
} }
} }
private OsMoGroup parseGroup(JSONObject obj) throws JSONException { private OsMoGroup parseGroup(JSONObject obj) throws JSONException {
@ -367,18 +367,19 @@ public class OsMoGroups implements OsMoReactor, OsmoTrackerListener {
if (obj.has(TRACK)) { if (obj.has(TRACK)) {
JSONArray ar = obj.getJSONArray(TRACK); JSONArray ar = obj.getJSONArray(TRACK);
JSONObject[] a = new JSONObject[ar.length()]; List<JSONObject> a = new ArrayList<>(ar.length());
Set<String> toDeleteT = new HashSet<String>(gr.groupTracks); Set<String> toDeleteT = new HashSet<String>(gr.groupTracks);
gr.groupTracks.clear(); gr.groupTracks.clear();
for (int i = 0; i < a.length; i++) { for (int i = 0; i < ar.length(); i++) {
a[i] = (JSONObject) ar.get(i); JSONObject trackJson = (JSONObject) ar.get(i);
if (!a[i].has(DELETED)) { if (!trackJson.has(DELETED)) {
String track = a[i].getString("name") + ".gpx"; String track = trackJson.getString("name") + ".gpx";
gr.groupTracks.add(track); gr.groupTracks.add(track);
toDeleteT.remove(track); toDeleteT.remove(track);
a.add(trackJson);
} }
} }
plugin.getDownloadGpxTask(true).execute(a); plugin.getDownloadGpxTask(true).execute(a.toArray(new JSONObject[a.size()]));
disableGroupTracks(gr, toDeleteT); disableGroupTracks(gr, toDeleteT);
} }

View file

@ -171,7 +171,7 @@ public class OsMoPlugin extends OsmandPlugin implements OsMoReactor {
@Override @Override
public void mapActivityPause(MapActivity activity) { public void mapActivityPause(MapActivity activity) {
groups.removeUiListener(olayer); groups.removeUiListener(olayer);
mapActivity = activity; mapActivity = null;
} }
@Override @Override
@ -179,7 +179,7 @@ public class OsMoPlugin extends OsmandPlugin implements OsMoReactor {
if (olayer != null) { if (olayer != null) {
groups.addUiListeners(olayer); groups.addUiListeners(olayer);
} }
mapActivity = null; mapActivity = activity;
} }
/** /**
@ -445,6 +445,7 @@ public class OsMoPlugin extends OsmandPlugin implements OsMoReactor {
t += s + "\n"; t += s + "\n";
} }
app.showToastMessage(t.trim()); app.showToastMessage(t.trim());
refreshMap();
} }
}; };
@ -459,6 +460,12 @@ public class OsMoPlugin extends OsmandPlugin implements OsMoReactor {
} }
public void refreshMap() {
if (mapActivity != null) {
mapActivity.getMapView().refreshMap();
}
}
@Override @Override
public boolean acceptCommand(String command, String id, String data, JSONObject obj, OsMoThread tread) { public boolean acceptCommand(String command, String id, String data, JSONObject obj, OsMoThread tread) {
return false; return false;