Add points to download
This commit is contained in:
parent
dca5eff5a4
commit
8a13b24b75
3 changed files with 30 additions and 13 deletions
|
@ -9,6 +9,7 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="osmo_gpx_points_downloaded">OsMo points %1$s downloaded.</string>
|
||||
<string name="osmo_auto_connect_descr">Automatically connect to the service after application startup</string>
|
||||
<string name="osmo_auto_connect">Auto-connect</string>
|
||||
<string name="osmo_start_service">OsMo service</string>
|
||||
|
|
|
@ -13,6 +13,7 @@ import net.osmand.plus.GPXUtilities.WptPt;
|
|||
import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoDevice;
|
||||
import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoGroup;
|
||||
import net.osmand.plus.osmo.OsMoTracker.OsmoTrackerListener;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
@ -327,6 +328,9 @@ public class OsMoGroups implements OsMoReactor, OsmoTrackerListener {
|
|||
if (jobj.has("name")) {
|
||||
pt.name = jobj.getString("name");
|
||||
}
|
||||
if (jobj.has("color")) {
|
||||
pt.setColor(Algorithms.parseColor(jobj.getString("color")));
|
||||
}
|
||||
if (jobj.has("description")) {
|
||||
pt.desc = jobj.getString("description");
|
||||
}
|
||||
|
@ -336,8 +340,9 @@ public class OsMoGroups implements OsMoReactor, OsmoTrackerListener {
|
|||
if (jobj.has("visible")) {
|
||||
pt.getExtensionsToWrite().put("visible", a[i].getBoolean("visible") + "");
|
||||
}
|
||||
points.add(pt);
|
||||
}
|
||||
plugin.getSaveGpxTask(gr.groupId + "_points", modify).execute(points.toArray(new WptPt[0]));
|
||||
plugin.getSaveGpxTask(gr.groupId + "_points", modify).execute(points.toArray(new WptPt[points.size()]));
|
||||
}
|
||||
if(deleteUsers) {
|
||||
for(OsMoDevice s : toDelete.values()) {
|
||||
|
|
|
@ -335,15 +335,25 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
|
|||
}
|
||||
|
||||
public AsyncTask<WptPt, String, String> getSaveGpxTask(final String name, final long timestamp) {
|
||||
return new AsyncTask<WptPt, String, String> (){
|
||||
return new AsyncTask<WptPt, String, String>() {
|
||||
|
||||
protected void onProgressUpdate(String... values) {
|
||||
if (values != null) {
|
||||
String t = "";
|
||||
for (String s : values) {
|
||||
t += s + "\n";
|
||||
}
|
||||
app.showToastMessage(t.trim());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doInBackground(WptPt... params) {
|
||||
final File fl = app.getAppPath(IndexConstants.GPX_INDEX_DIR+"/osmo");
|
||||
if(!fl.exists()) {
|
||||
final File fl = app.getAppPath(IndexConstants.GPX_INDEX_DIR + "/osmo");
|
||||
if (!fl.exists()) {
|
||||
fl.mkdirs();
|
||||
}
|
||||
File ps = new File(fl, name+".gpx");
|
||||
File ps = new File(fl, name + ".gpx");
|
||||
String errors = "";
|
||||
boolean changed = false;
|
||||
if (!ps.exists() || ps.lastModified() != timestamp) {
|
||||
|
@ -352,14 +362,15 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
|
|||
g.points.addAll(Arrays.asList(params));
|
||||
errors = GPXUtilities.writeGpxFile(ps, g, app);
|
||||
ps.setLastModified(timestamp);
|
||||
if(errors == null ) {
|
||||
if (errors == null) {
|
||||
errors = "";
|
||||
}
|
||||
publishProgress(app.getString(R.string.osmo_gpx_points_downloaded, name));
|
||||
}
|
||||
SelectedGpxFile byPath = app.getSelectedGpxHelper().getSelectedFileByPath(ps.getAbsolutePath());
|
||||
if(byPath == null || changed) {
|
||||
if (byPath == null || changed) {
|
||||
GPXFile selectGPXFile = GPXUtilities.loadGPXFile(app, ps);
|
||||
if(byPath != null) {
|
||||
if (byPath != null) {
|
||||
app.getSelectedGpxHelper().selectGpxFile(selectGPXFile, false, false);
|
||||
}
|
||||
app.getSelectedGpxHelper().setGpxFileToDisplay(selectGPXFile);
|
||||
|
@ -369,8 +380,8 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
|
|||
|
||||
@Override
|
||||
protected void onPostExecute(String result) {
|
||||
if(result.length() > 0) {
|
||||
app.showToastMessage(app.getString(R.string.osmo_io_error)+ result);
|
||||
if (result.length() > 0) {
|
||||
app.showToastMessage(app.getString(R.string.osmo_io_error) + result);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue