Move processSplit method to gpxSelectionHelper
This commit is contained in:
parent
53b091a47f
commit
4fac998ac9
3 changed files with 31 additions and 33 deletions
|
@ -1,8 +1,6 @@
|
|||
package net.osmand.plus;
|
||||
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
|
||||
import net.osmand.plus.api.SQLiteAPI.SQLiteCursor;
|
||||
|
@ -457,36 +455,6 @@ public class GPXDatabase {
|
|||
return items;
|
||||
}
|
||||
|
||||
public void processSplit() {
|
||||
List<GpxDataItem> items = getItems();
|
||||
for (GpxDataItem dataItem : items) {
|
||||
if (dataItem.getSplitType() != 0) {
|
||||
GpxSelectionHelper gpxSelectionHelper = context.getSelectedGpxHelper();
|
||||
SelectedGpxFile selectedGpxFile = gpxSelectionHelper.getSelectedFileByPath(dataItem.file.getAbsolutePath());
|
||||
if (selectedGpxFile != null && selectedGpxFile.getGpxFile() != null) {
|
||||
GPXUtilities.GPXFile gpxFile = selectedGpxFile.getGpxFile();
|
||||
List<GpxDisplayGroup> groups = context.getSelectedGpxHelper().collectDisplayGroups(gpxFile);
|
||||
if (dataItem.getSplitType() == GPX_SPLIT_TYPE_NO_SPLIT) {
|
||||
for (GpxDisplayGroup model : groups) {
|
||||
model.noSplit(context);
|
||||
}
|
||||
selectedGpxFile.setDisplayGroups(groups);
|
||||
} else if (dataItem.getSplitType() == GPX_SPLIT_TYPE_DISTANCE) {
|
||||
for (GpxDisplayGroup model : groups) {
|
||||
model.splitByDistance(context, dataItem.getSplitInterval());
|
||||
}
|
||||
selectedGpxFile.setDisplayGroups(groups);
|
||||
} else if (dataItem.getSplitType() == GPX_SPLIT_TYPE_TIME) {
|
||||
for (GpxDisplayGroup model : groups) {
|
||||
model.splitByTime(context, (int) dataItem.getSplitInterval());
|
||||
}
|
||||
selectedGpxFile.setDisplayGroups(groups);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public GpxDataItem getItem(File file) {
|
||||
GpxDataItem result = null;
|
||||
SQLiteConnection db = openConnection(true);
|
||||
|
|
|
@ -12,6 +12,7 @@ import net.osmand.plus.GPXUtilities.Route;
|
|||
import net.osmand.plus.GPXUtilities.Track;
|
||||
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.OsmandSettings.MetricsConstants;
|
||||
import net.osmand.plus.activities.SavingTrackHelper;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
|
@ -82,6 +83,35 @@ public class GpxSelectionHelper {
|
|||
return null;
|
||||
}
|
||||
|
||||
public void processSplit() {
|
||||
List<GpxDataItem> items = app.getGpxDatabase().getItems();
|
||||
for (GpxDataItem dataItem : items) {
|
||||
if (dataItem.getSplitType() != 0) {
|
||||
SelectedGpxFile selectedGpxFile = getSelectedFileByPath(dataItem.getFile().getAbsolutePath());
|
||||
if (selectedGpxFile != null && selectedGpxFile.getGpxFile() != null) {
|
||||
GPXFile gpxFile = selectedGpxFile.getGpxFile();
|
||||
List<GpxDisplayGroup> groups = app.getSelectedGpxHelper().collectDisplayGroups(gpxFile);
|
||||
if (dataItem.getSplitType() == GPXDatabase.GPX_SPLIT_TYPE_NO_SPLIT) {
|
||||
for (GpxDisplayGroup model : groups) {
|
||||
model.noSplit(app);
|
||||
}
|
||||
selectedGpxFile.setDisplayGroups(groups);
|
||||
} else if (dataItem.getSplitType() == GPXDatabase.GPX_SPLIT_TYPE_DISTANCE) {
|
||||
for (GpxDisplayGroup model : groups) {
|
||||
model.splitByDistance(app, dataItem.getSplitInterval());
|
||||
}
|
||||
selectedGpxFile.setDisplayGroups(groups);
|
||||
} else if (dataItem.getSplitType() == GPXDatabase.GPX_SPLIT_TYPE_TIME) {
|
||||
for (GpxDisplayGroup model : groups) {
|
||||
model.splitByTime(app, (int) dataItem.getSplitInterval());
|
||||
}
|
||||
selectedGpxFile.setDisplayGroups(groups);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String getString(int resId, Object... formatArgs) {
|
||||
return app.getString(resId, formatArgs);
|
||||
}
|
||||
|
|
|
@ -193,7 +193,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
cache.clear();
|
||||
currentTrackColor = view.getSettings().CURRENT_TRACK_COLOR.get();
|
||||
if (!selectedGPXFiles.isEmpty()) {
|
||||
view.getApplication().getGpxDatabase().processSplit();
|
||||
selectedGpxHelper.processSplit();
|
||||
drawSelectedFilesSegments(canvas, tileBox, selectedGPXFiles, settings);
|
||||
canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
|
||||
if (trackChartPoints != null) {
|
||||
|
|
Loading…
Reference in a new issue