Search in sources :

Example 36 with GPXFile

use of net.osmand.plus.GPXUtilities.GPXFile in project Osmand by osmandapp.

the class MapContextMenu method addNewWptToGPXFile.

public AlertDialog addNewWptToGPXFile(final LatLon latLon, final String title, final String categoryName, final int categoryColor, final boolean skipDialog) {
    CallbackWithObject<GPXFile[]> callbackWithObject = new CallbackWithObject<GPXFile[]>() {

        @Override
        public boolean processResult(GPXFile[] result) {
            GPXFile gpxFile;
            if (result != null && result.length > 0) {
                gpxFile = result[0];
            } else {
                gpxFile = mapActivity.getMyApplication().getSavingTrackHelper().getCurrentGpx();
            }
            getWptPtPointEditor().add(gpxFile, latLon, title, categoryName, categoryColor, skipDialog);
            return true;
        }
    };
    return GpxUiHelper.selectSingleGPXFile(mapActivity, true, callbackWithObject);
}
Also used : CallbackWithObject(net.osmand.CallbackWithObject) GPXFile(net.osmand.plus.GPXUtilities.GPXFile)

Example 37 with GPXFile

use of net.osmand.plus.GPXUtilities.GPXFile in project Osmand by osmandapp.

the class MapContextMenu method addWptPt.

public void addWptPt(LatLon latLon, String title, String categoryName, int categoryColor, boolean skipDialog) {
    final List<SelectedGpxFile> list = mapActivity.getMyApplication().getSelectedGpxHelper().getSelectedGPXFiles();
    if (list.isEmpty() || (list.size() == 1 && list.get(0).getGpxFile().showCurrentTrack)) {
        GPXFile gpxFile = mapActivity.getMyApplication().getSavingTrackHelper().getCurrentGpx();
        getWptPtPointEditor().add(gpxFile, latLon, title, categoryName, categoryColor, skipDialog);
    } else {
        addNewWptToGPXFile(latLon, title, categoryName, categoryColor, skipDialog);
    }
}
Also used : SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) GPXFile(net.osmand.plus.GPXUtilities.GPXFile)

Example 38 with GPXFile

use of net.osmand.plus.GPXUtilities.GPXFile in project Osmand by osmandapp.

the class WptPtEditorFragment method syncGpx.

private void syncGpx(GPXFile gpxFile) {
    File gpx = new File(gpxFile.path);
    if (gpx.exists()) {
        MapMarkersHelper helper = getMyApplication().getMapMarkersHelper();
        helper.runSynchronization(helper.getOrCreateGroup(gpx));
    }
}
Also used : MapMarkersHelper(net.osmand.plus.MapMarkersHelper) GPXFile(net.osmand.plus.GPXUtilities.GPXFile) File(java.io.File)

Example 39 with GPXFile

use of net.osmand.plus.GPXUtilities.GPXFile in project Osmand by osmandapp.

the class WptPtEditorFragment method doAddWpt.

private void doAddWpt(String name, String category, String description) {
    wpt.name = name;
    wpt.category = category;
    wpt.desc = description;
    if (color != 0) {
        wpt.setColor(color);
    }
    GPXFile gpx = editor.getGpxFile();
    if (gpx != null) {
        if (gpx.showCurrentTrack) {
            wpt = savingTrackHelper.insertPointData(wpt.getLatitude(), wpt.getLongitude(), System.currentTimeMillis(), description, name, category, color);
            if (!editor.isGpxSelected()) {
                selectedGpxHelper.setGpxFileToDisplay(gpx);
            }
        } else {
            addWpt(gpx, description, name, category, color);
            new SaveGpxAsyncTask(getMyApplication(), gpx, editor.isGpxSelected()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        }
        syncGpx(gpx);
    }
}
Also used : GPXFile(net.osmand.plus.GPXUtilities.GPXFile)

Example 40 with GPXFile

use of net.osmand.plus.GPXUtilities.GPXFile in project Osmand by osmandapp.

the class WptPtEditorFragment method doUpdateWpt.

private void doUpdateWpt(String name, String category, String description) {
    GPXFile gpx = editor.getGpxFile();
    if (gpx != null) {
        if (gpx.showCurrentTrack) {
            savingTrackHelper.updatePointData(wpt, wpt.getLatitude(), wpt.getLongitude(), System.currentTimeMillis(), description, name, category, color);
            if (!editor.isGpxSelected()) {
                selectedGpxHelper.setGpxFileToDisplay(gpx);
            }
        } else {
            gpx.updateWptPt(wpt, wpt.getLatitude(), wpt.getLongitude(), System.currentTimeMillis(), description, name, category, color);
            new SaveGpxAsyncTask(getMyApplication(), gpx, editor.isGpxSelected()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        }
        syncGpx(gpx);
    }
}
Also used : GPXFile(net.osmand.plus.GPXUtilities.GPXFile)

Aggregations

GPXFile (net.osmand.plus.GPXUtilities.GPXFile)56 File (java.io.File)26 SelectedGpxFile (net.osmand.plus.GpxSelectionHelper.SelectedGpxFile)21 WptPt (net.osmand.plus.GPXUtilities.WptPt)16 OsmandApplication (net.osmand.plus.OsmandApplication)11 View (android.view.View)8 TextView (android.widget.TextView)8 Intent (android.content.Intent)7 ImageView (android.widget.ImageView)7 FavouritePoint (net.osmand.data.FavouritePoint)7 LatLon (net.osmand.data.LatLon)7 DialogInterface (android.content.DialogInterface)6 AlertDialog (android.support.v7.app.AlertDialog)6 ArrayList (java.util.ArrayList)6 MapMarkersHelper (net.osmand.plus.MapMarkersHelper)6 OsmandSettings (net.osmand.plus.OsmandSettings)6 GpxDataItem (net.osmand.plus.GPXDatabase.GpxDataItem)5 Track (net.osmand.plus.GPXUtilities.Track)5 TrkSegment (net.osmand.plus.GPXUtilities.TrkSegment)5 AdapterView (android.widget.AdapterView)4