Fix gpx selection issue
This commit is contained in:
parent
13491399bd
commit
8b9c9a0e27
3 changed files with 45 additions and 18 deletions
|
@ -324,7 +324,7 @@ public class GpxSelectionHelper {
|
|||
selectedGPXFiles.add(savingTrackHelper.getCurrentTrack());
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
} catch (Exception e) {
|
||||
app.getSettings().SELECTED_GPX.set("");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -337,10 +337,10 @@ public class GpxSelectionHelper {
|
|||
if(s.gpxFile != null && !s.notShowNavigationDialog) {
|
||||
JSONObject obj = new JSONObject();
|
||||
try {
|
||||
if(!Algorithms.isEmpty(s.gpxFile.path)) {
|
||||
obj.put(FILE, s.gpxFile.path);
|
||||
} else {
|
||||
if(s.isShowCurrentTrack()) {
|
||||
obj.put(CURRENT_TRACK, true);
|
||||
} else if(!Algorithms.isEmpty(s.gpxFile.path)) {
|
||||
obj.put(FILE, s.gpxFile.path);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -410,10 +410,14 @@ public class GpxSelectionHelper {
|
|||
if(gpxFile.tracks.size() > 0) {
|
||||
this.color = gpxFile.tracks.get(0).getColor(0);
|
||||
}
|
||||
processPoints();
|
||||
}
|
||||
|
||||
public void processPoints() {
|
||||
this.processedPointsToDisplay = gpxFile.proccessPoints();
|
||||
if(this.processedPointsToDisplay.isEmpty()) {
|
||||
this.processedPointsToDisplay = gpxFile.processRoutePoints();
|
||||
routePoints = true;
|
||||
routePoints = !this.processedPointsToDisplay.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -437,6 +441,11 @@ public class GpxSelectionHelper {
|
|||
return gpxFile;
|
||||
}
|
||||
|
||||
public GPXFile getModifiableGpxFile() {
|
||||
// call process points after
|
||||
return gpxFile;
|
||||
}
|
||||
|
||||
public boolean isShowCurrentTrack() {
|
||||
return showCurrentTrack;
|
||||
}
|
||||
|
|
|
@ -376,20 +376,23 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
assert track.segments.size() == points.size();
|
||||
if (points.size() == 0 || newSegment) {
|
||||
points.add(new ArrayList<WptPt>());
|
||||
}
|
||||
if(track.segments.size() == 0 || newSegment) {
|
||||
track.segments.add(new TrkSegment());
|
||||
}
|
||||
if (pt != null) {
|
||||
int ind = points.size() - 1;
|
||||
List<WptPt> last = points.get(ind);
|
||||
last.add(pt);
|
||||
track.segments.get(ind).points.add(pt);
|
||||
TrkSegment lt = track.segments.get(track.segments.size() - 1);
|
||||
lt.points.add(pt);
|
||||
}
|
||||
}
|
||||
|
||||
public void insertPointData(double lat, double lon, long time, String description) {
|
||||
final WptPt pt = new WptPt(lat, lon, time, Double.NaN, 0, Double.NaN);
|
||||
pt.name = description;
|
||||
currentTrack.getGpxFile().points.add(pt);
|
||||
currentTrack.getModifiableGpxFile().points.add(pt);
|
||||
execWithClose(updatePointsScript, new Object[] { lat, lon, time, description });
|
||||
}
|
||||
|
||||
|
@ -409,9 +412,10 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
public void loadGpxFromDatabase(){
|
||||
Map<String, GPXFile> files = collectRecordedData();
|
||||
for (Map.Entry<String, GPXFile> entry : files.entrySet()){
|
||||
currentTrack.getGpxFile().points.addAll(entry.getValue().points);
|
||||
currentTrack.getGpxFile().tracks.addAll(entry.getValue().tracks);
|
||||
currentTrack.getModifiableGpxFile().points.addAll(entry.getValue().points);
|
||||
currentTrack.getModifiableGpxFile().tracks.addAll(entry.getValue().tracks);
|
||||
}
|
||||
currentTrack.processPoints();
|
||||
}
|
||||
|
||||
public boolean getIsRecording() {
|
||||
|
|
|
@ -141,7 +141,8 @@ public class GpxUiHelper {
|
|||
if(showCurrentGpx){
|
||||
allGpxList.add(0, activity.getString(R.string.show_current_gpx_title));
|
||||
}
|
||||
final ContextMenuAdapter adapter = createGpxContextMenuAdapter(activity, allGpxList, selectedGpxList, multipleChoice);
|
||||
final ContextMenuAdapter adapter = createGpxContextMenuAdapter(activity, allGpxList, selectedGpxList, multipleChoice,
|
||||
showCurrentGpx);
|
||||
|
||||
return createDialog(activity, showCurrentGpx, multipleChoice, callbackWithObject, allGpxList, adapter);
|
||||
}
|
||||
|
@ -161,14 +162,16 @@ public class GpxUiHelper {
|
|||
list.add(0, activity.getString(R.string.show_current_gpx_title));
|
||||
}
|
||||
|
||||
final ContextMenuAdapter adapter = createGpxContextMenuAdapter(activity, list, null, multipleChoice);
|
||||
final ContextMenuAdapter adapter = createGpxContextMenuAdapter(activity, list, null, multipleChoice,
|
||||
showCurrentGpx);
|
||||
return createDialog(activity, showCurrentGpx, multipleChoice, callbackWithObject, list, adapter);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static ContextMenuAdapter createGpxContextMenuAdapter(Activity activity, List<String> allGpxList,
|
||||
List<String> selectedGpxList, boolean multipleChoice) {
|
||||
List<String> selectedGpxList, boolean multipleChoice,
|
||||
boolean showCurrentTrack) {
|
||||
final ContextMenuAdapter adapter = new ContextMenuAdapter(activity);
|
||||
//element position in adapter
|
||||
int i = 0;
|
||||
|
@ -184,6 +187,20 @@ public class GpxUiHelper {
|
|||
|
||||
//if there's some selected files - need to mark them as selected
|
||||
if (selectedGpxList != null) {
|
||||
updateSelection(selectedGpxList, showCurrentTrack, adapter, i, fileName);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return adapter;
|
||||
}
|
||||
|
||||
protected static void updateSelection(List<String> selectedGpxList, boolean showCurrentTrack,
|
||||
final ContextMenuAdapter adapter, int i, String fileName) {
|
||||
if(i == 0 && showCurrentTrack) {
|
||||
if(selectedGpxList.contains("")) {
|
||||
adapter.setSelection(i, 1);
|
||||
}
|
||||
} else {
|
||||
for (String file : selectedGpxList) {
|
||||
if (file.endsWith(fileName)) {
|
||||
adapter.setSelection(i, 1);
|
||||
|
@ -191,9 +208,6 @@ public class GpxUiHelper {
|
|||
}
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return adapter;
|
||||
}
|
||||
|
||||
private static void setDescripionInDialog(final ArrayAdapter<?> adapter, final ContextMenuAdapter cmAdapter, Activity activity,
|
||||
|
|
Loading…
Reference in a new issue