Fix add wpt issue
This commit is contained in:
parent
ae8cb8149d
commit
a6bada4c20
2 changed files with 21 additions and 21 deletions
|
@ -27,7 +27,6 @@ import net.osmand.plus.GPXUtilities;
|
|||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
@ -174,11 +173,16 @@ public class GpxUiHelper {
|
|||
public static AlertDialog selectSingleGPXFile(final Activity activity,
|
||||
final boolean showCurrentGpx, final CallbackWithObject<GPXFile[]> callbackWithObject) {
|
||||
OsmandApplication app = (OsmandApplication) activity.getApplication();
|
||||
final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
|
||||
final List<String> list = getSortedGPXFilenames(dir, false);
|
||||
if (!list.isEmpty() || showCurrentGpx) {
|
||||
int gpxDirLength = app.getAppPath(IndexConstants.GPX_INDEX_DIR).getAbsolutePath().length();
|
||||
List<SelectedGpxFile> selectedGpxFiles = app.getSelectedGpxHelper().getSelectedGPXFiles();
|
||||
final List<String> list = new ArrayList<>(selectedGpxFiles.size() + 1);
|
||||
if (!selectedGpxFiles.isEmpty() || showCurrentGpx) {
|
||||
if (showCurrentGpx) {
|
||||
list.add(0, activity.getString(R.string.shared_string_currently_recording_track));
|
||||
list.add(activity.getString(R.string.shared_string_currently_recording_track));
|
||||
}
|
||||
|
||||
for (SelectedGpxFile selectedGpx : selectedGpxFiles) {
|
||||
list.add(selectedGpx.getGpxFile().path.substring(gpxDirLength + 1));
|
||||
}
|
||||
|
||||
final ContextMenuAdapter adapter = createGpxContextMenuAdapter(activity, list, null, false,
|
||||
|
|
|
@ -6,13 +6,13 @@ import android.view.View;
|
|||
import android.widget.LinearLayout;
|
||||
|
||||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
|
@ -29,7 +29,6 @@ import net.osmand.plus.views.ContextMenuLayer;
|
|||
import net.osmand.plus.views.OsmandMapLayer;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -53,7 +52,6 @@ public class MapContextMenu extends MenuTitleController {
|
|||
private LatLon myLocation;
|
||||
private Float heading;
|
||||
private boolean inLocationUpdate = false;
|
||||
private long locationUpdateTime;
|
||||
|
||||
private int favActionIconId;
|
||||
|
||||
|
@ -401,20 +399,18 @@ public class MapContextMenu extends MenuTitleController {
|
|||
}
|
||||
|
||||
public void addWptPt() {
|
||||
if (object == null) {
|
||||
String title = getTitleStr();
|
||||
if (pointDescription.isWpt() || title.equals(addressNotKnownStr)) {
|
||||
title = "";
|
||||
}
|
||||
String title = getTitleStr();
|
||||
if (pointDescription.isWpt() || title.equals(addressNotKnownStr)) {
|
||||
title = "";
|
||||
}
|
||||
|
||||
final File dir = mapActivity.getMyApplication().getAppPath(IndexConstants.GPX_INDEX_DIR);
|
||||
final List<String> list = GpxUiHelper.getSortedGPXFilenames(dir, false);
|
||||
if (list.isEmpty()) {
|
||||
GPXFile gpxFile = mapActivity.getMyApplication().getSavingTrackHelper().getCurrentGpx();
|
||||
getWptPtPointEditor().add(gpxFile, latLon, title);
|
||||
} else {
|
||||
addNewWptToGPXFile(title);
|
||||
}
|
||||
final List<SelectedGpxFile> list
|
||||
= mapActivity.getMyApplication().getSelectedGpxHelper().getSelectedGPXFiles();
|
||||
if (list.isEmpty()) {
|
||||
GPXFile gpxFile = mapActivity.getMyApplication().getSavingTrackHelper().getCurrentGpx();
|
||||
getWptPtPointEditor().add(gpxFile, latLon, title);
|
||||
} else {
|
||||
addNewWptToGPXFile(title);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue