Fix #11337
This commit is contained in:
parent
658b157bb2
commit
7525c925ca
4 changed files with 21 additions and 31 deletions
|
@ -291,10 +291,12 @@ public class GpxSelectionHelper {
|
|||
return group;
|
||||
}
|
||||
|
||||
private String getGroupName(GPXFile g) {
|
||||
public String getGroupName(GPXFile g) {
|
||||
String name = g.path;
|
||||
if (g.showCurrentTrack) {
|
||||
name = getString(R.string.shared_string_currently_recording_track);
|
||||
} else if (Algorithms.isEmpty(name)) {
|
||||
name = getString(R.string.current_route);
|
||||
} else {
|
||||
int i = name.lastIndexOf('/');
|
||||
if (i >= 0) {
|
||||
|
|
|
@ -79,6 +79,7 @@ import net.osmand.plus.ContextMenuItem;
|
|||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.GpxDbHelper;
|
||||
import net.osmand.plus.GpxDbHelper.GpxDataItemCallback;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
|
@ -2228,18 +2229,19 @@ public class GpxUiHelper {
|
|||
return dataSet;
|
||||
}
|
||||
|
||||
public static GpxDisplayItem makeGpxDisplayItem(OsmandApplication app, GPXUtilities.GPXFile gpx) {
|
||||
GpxDisplayItem gpxItem = null;
|
||||
String groupName = app.getString(R.string.current_route);
|
||||
GpxDisplayGroup group = app.getSelectedGpxHelper().buildGpxDisplayGroup(gpx, 0, groupName);
|
||||
public static GpxDisplayItem makeGpxDisplayItem(OsmandApplication app, GPXFile gpxFile) {
|
||||
GpxSelectionHelper helper = app.getSelectedGpxHelper();
|
||||
String groupName = helper.getGroupName(gpxFile);
|
||||
GpxDisplayGroup group = helper.buildGpxDisplayGroup(gpxFile, 0, groupName);
|
||||
if (group != null && group.getModifiableList().size() > 0) {
|
||||
gpxItem = group.getModifiableList().get(0);
|
||||
GpxDisplayItem gpxItem = group.getModifiableList().get(0);
|
||||
if (gpxItem != null) {
|
||||
gpxItem.route = true;
|
||||
}
|
||||
}
|
||||
return gpxItem;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void saveAndShareGpx(@NonNull final Context context, @NonNull final GPXFile gpxFile) {
|
||||
OsmandApplication app = (OsmandApplication) context.getApplicationContext();
|
||||
|
|
|
@ -7,12 +7,13 @@ import android.os.AsyncTask;
|
|||
import androidx.annotation.NonNull;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -24,7 +25,6 @@ import net.osmand.plus.settings.backend.OsmandSettings;
|
|||
import net.osmand.plus.track.TrackMenuFragment;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -93,28 +93,15 @@ public class SelectedGpxMenuController extends MenuController {
|
|||
|
||||
@Override
|
||||
protected GpxSelectionHelper.GpxDisplayItem doInBackground(Void... voids) {
|
||||
GpxSelectionHelper.GpxDisplayGroup gpxDisplayGroup = null;
|
||||
GPXUtilities.GPXFile gpxFile = null;
|
||||
GPXUtilities.Track generalTrack = null;
|
||||
if (selectedGpxFile.getGpxFile().path != null) {
|
||||
gpxFile = GPXUtilities.loadGPXFile(new File(selectedGpxFile.getGpxFile().path));
|
||||
}
|
||||
if (gpxFile != null) {
|
||||
generalTrack = gpxFile.getGeneralTrack();
|
||||
}
|
||||
if (generalTrack != null) {
|
||||
gpxFile.addGeneralTrack();
|
||||
gpxDisplayGroup = app.getSelectedGpxHelper().buildGeneralGpxDisplayGroup(gpxFile, generalTrack);
|
||||
} else if (gpxFile != null && gpxFile.tracks.size() > 0) {
|
||||
gpxDisplayGroup = app.getSelectedGpxHelper().buildGeneralGpxDisplayGroup(gpxFile, gpxFile.tracks.get(0));
|
||||
}
|
||||
List<GpxSelectionHelper.GpxDisplayItem> items = null;
|
||||
if (gpxDisplayGroup != null) {
|
||||
items = gpxDisplayGroup.getModifiableList();
|
||||
}
|
||||
if (items != null && items.size() > 0) {
|
||||
GPXFile gpxFile = selectedGpxFile.getGpxFile();
|
||||
if (gpxFile.tracks.size() > 0) {
|
||||
GpxDisplayGroup gpxDisplayGroup = app.getSelectedGpxHelper().buildGeneralGpxDisplayGroup(gpxFile, gpxFile.tracks.get(0));
|
||||
|
||||
List<GpxDisplayItem> items = gpxDisplayGroup.getModifiableList();
|
||||
if (!Algorithms.isEmpty(items)) {
|
||||
return items.get(0);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,6 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
|
||||
import static net.osmand.plus.liveupdates.LiveUpdatesFragment.getDefaultIconColorId;
|
||||
import static net.osmand.plus.myplaces.GPXTabItemType.GPX_TAB_ITEM_SPEED;
|
||||
|
||||
public class GpxBlockStatisticsBuilder {
|
||||
|
||||
|
|
Loading…
Reference in a new issue