Search in sources :

Example 1 with GpxSelectionHelper

use of net.osmand.plus.GpxSelectionHelper in project Osmand by osmandapp.

the class TrackActivity method getGpxFile.

public List<GpxDisplayGroup> getGpxFile(boolean useDisplayGroups) {
    if (gpxFile == null) {
        return new ArrayList<>();
    }
    if (gpxFile.modifiedTime != modifiedTime) {
        modifiedTime = gpxFile.modifiedTime;
        GpxSelectionHelper selectedGpxHelper = ((OsmandApplication) getApplication()).getSelectedGpxHelper();
        displayGroups = selectedGpxHelper.collectDisplayGroups(gpxFile);
        originalGroups.clear();
        for (GpxDisplayGroup g : displayGroups) {
            originalGroups.add(g.cloneInstance());
        }
        if (file != null) {
            SelectedGpxFile sf = selectedGpxHelper.getSelectedFileByPath(gpxFile.path);
            if (sf != null && file != null && sf.getDisplayGroups() != null) {
                displayGroups = sf.getDisplayGroups();
            }
        }
    }
    if (useDisplayGroups) {
        return displayGroups;
    } else {
        return originalGroups;
    }
}
Also used : GpxDisplayGroup(net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup) OsmandApplication(net.osmand.plus.OsmandApplication) SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) ArrayList(java.util.ArrayList) GpxSelectionHelper(net.osmand.plus.GpxSelectionHelper)

Example 2 with GpxSelectionHelper

use of net.osmand.plus.GpxSelectionHelper in project Osmand by osmandapp.

the class WptPtMenuController method getTypeStr.

@Override
public String getTypeStr() {
    GpxSelectionHelper helper = getMapActivity().getMyApplication().getSelectedGpxHelper();
    SelectedGpxFile selectedGpxFile = helper.getSelectedGPXFile(wpt);
    StringBuilder sb = new StringBuilder();
    sb.append(getMapActivity().getString(R.string.gpx_wpt));
    sb.append(", ");
    if (selectedGpxFile != null) {
        File file = new File(selectedGpxFile.getGpxFile().path);
        String gpxName = file.getName().replace(".gpx", "").replace("/", " ").replace("_", " ");
        sb.append(gpxName);
    }
    return sb.toString();
}
Also used : SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) GpxSelectionHelper(net.osmand.plus.GpxSelectionHelper) SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) File(java.io.File)

Example 3 with GpxSelectionHelper

use of net.osmand.plus.GpxSelectionHelper in project Osmand by osmandapp.

the class MapMarkersGroupsAdapter method switchGpxVisibility.

private void switchGpxVisibility(@NonNull GPXFile gpxFile, boolean visible) {
    GpxSelectionHelper gpxHelper = app.getSelectedGpxHelper();
    gpxHelper.selectGpxFile(gpxFile, visible, false, false);
}
Also used : GpxSelectionHelper(net.osmand.plus.GpxSelectionHelper)

Example 4 with GpxSelectionHelper

use of net.osmand.plus.GpxSelectionHelper in project Osmand by osmandapp.

the class OsmandAidlApi method finishGpxImport.

private void finishGpxImport(boolean destinationExists, File destination, String color, boolean show) {
    int col = ConfigureMapMenu.GpxAppearanceAdapter.parseTrackColor(app.getRendererRegistry().getCurrentSelectedRenderer(), color);
    if (!destinationExists) {
        GpxDataItem gpxDataItem = new GpxDataItem(destination, col);
        gpxDataItem.setApiImported(true);
        app.getGpxDatabase().add(gpxDataItem);
    } else {
        GpxDataItem item = app.getGpxDatabase().getItem(destination);
        if (item != null) {
            app.getGpxDatabase().updateColor(item, col);
        }
    }
    final GpxSelectionHelper helper = app.getSelectedGpxHelper();
    final SelectedGpxFile selectedGpx = helper.getSelectedFileByName(destination.getName());
    if (selectedGpx != null) {
        if (show) {
            new AsyncTask<File, Void, GPXFile>() {

                @Override
                protected GPXFile doInBackground(File... files) {
                    return GPXUtilities.loadGPXFile(app, files[0]);
                }

                @Override
                protected void onPostExecute(GPXFile gpx) {
                    if (gpx.warning == null) {
                        selectedGpx.setGpxFile(gpx);
                        refreshMap();
                    }
                }
            }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, destination);
        } else {
            helper.selectGpxFile(selectedGpx.getGpxFile(), false, false);
            refreshMap();
        }
    } else if (show) {
        new AsyncTask<File, Void, GPXFile>() {

            @Override
            protected GPXFile doInBackground(File... files) {
                return GPXUtilities.loadGPXFile(app, files[0]);
            }

            @Override
            protected void onPostExecute(GPXFile gpx) {
                if (gpx.warning == null) {
                    helper.selectGpxFile(gpx, true, false);
                    refreshMap();
                }
            }
        }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, destination);
    }
}
Also used : SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) ASelectedGpxFile(net.osmand.aidl.gpx.ASelectedGpxFile) GpxDataItem(net.osmand.plus.GPXDatabase.GpxDataItem) AsyncTask(android.os.AsyncTask) GpxSelectionHelper(net.osmand.plus.GpxSelectionHelper) GPXFile(net.osmand.plus.GPXUtilities.GPXFile) SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) ASelectedGpxFile(net.osmand.aidl.gpx.ASelectedGpxFile) GPXFile(net.osmand.plus.GPXUtilities.GPXFile) File(java.io.File) FavouritePoint(net.osmand.data.FavouritePoint) AMapPoint(net.osmand.aidl.maplayer.point.AMapPoint)

Example 5 with GpxSelectionHelper

use of net.osmand.plus.GpxSelectionHelper in project Osmand by osmandapp.

the class DashTrackFragment method updateShowOnMap.

private void updateShowOnMap(final OsmandApplication app, final File f, final View pView, final ImageButton showOnMap) {
    final GpxSelectionHelper selectedGpxHelper = app.getSelectedGpxHelper();
    final SelectedGpxFile selected = selectedGpxHelper.getSelectedFileByPath(f.getAbsolutePath());
    if (selected != null) {
        showOnMap.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_show_on_map, R.color.color_distance));
        showOnMap.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                selectedGpxHelper.selectGpxFile(selected.getGpxFile(), false, false);
                AvailableGPXFragment.GpxInfo info = new AvailableGPXFragment.GpxInfo();
                info.subfolder = "";
                info.file = f;
                AvailableGPXFragment.updateGpxInfoView(pView, info, app, true);
                updateShowOnMap(app, f, v, showOnMap);
            }
        });
    } else {
        showOnMap.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_show_on_map));
        showOnMap.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Runnable run = new Runnable() {

                    @Override
                    public void run() {
                        showOnMap(GPXUtilities.loadGPXFile(app, f));
                    }
                };
                run.run();
            }
        });
    }
}
Also used : SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) GpxSelectionHelper(net.osmand.plus.GpxSelectionHelper) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) AvailableGPXFragment(net.osmand.plus.myplaces.AvailableGPXFragment)

Aggregations

GpxSelectionHelper (net.osmand.plus.GpxSelectionHelper)8 SelectedGpxFile (net.osmand.plus.GpxSelectionHelper.SelectedGpxFile)7 File (java.io.File)5 GPXFile (net.osmand.plus.GPXUtilities.GPXFile)3 OsmandApplication (net.osmand.plus.OsmandApplication)2 AsyncTask (android.os.AsyncTask)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 ArrayList (java.util.ArrayList)1 ASelectedGpxFile (net.osmand.aidl.gpx.ASelectedGpxFile)1 AMapPoint (net.osmand.aidl.maplayer.point.AMapPoint)1 FavouritePoint (net.osmand.data.FavouritePoint)1 GpxDataItem (net.osmand.plus.GPXDatabase.GpxDataItem)1 GPXUtilities (net.osmand.plus.GPXUtilities)1 WptPt (net.osmand.plus.GPXUtilities.WptPt)1 GpxDisplayGroup (net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup)1 MapMarkersHelper (net.osmand.plus.MapMarkersHelper)1 MapMarkersGroup (net.osmand.plus.MapMarkersHelper.MapMarkersGroup)1 AvailableGPXFragment (net.osmand.plus.myplaces.AvailableGPXFragment)1