Search in sources :

Example 1 with OsmBugsDbHelper

use of net.osmand.plus.plugins.osmedit.helpers.OsmBugsDbHelper in project Osmand by osmandapp.

the class OsmNotesSettingsItem method apply.

@Override
public void apply() {
    List<OsmNotesPoint> newItems = getNewItems();
    if (!newItems.isEmpty() || !duplicateItems.isEmpty()) {
        appliedItems = new ArrayList<>(newItems);
        OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
        if (osmEditingPlugin != null) {
            OsmBugsDbHelper db = osmEditingPlugin.getDBBug();
            for (OsmNotesPoint duplicate : duplicateItems) {
                int ind = existingItems.indexOf(duplicate);
                if (ind != -1 && ind < existingItems.size()) {
                    OsmNotesPoint original = existingItems.get(ind);
                    if (original != null) {
                        db.deleteAllBugModifications(original);
                    }
                    db.addOsmbugs(duplicate);
                }
            }
            for (OsmNotesPoint point : appliedItems) {
                db.addOsmbugs(point);
            }
        }
    }
}
Also used : OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) OsmBugsDbHelper(net.osmand.plus.plugins.osmedit.helpers.OsmBugsDbHelper) OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) OsmEditingPlugin(net.osmand.plus.plugins.osmedit.OsmEditingPlugin)

Aggregations

OsmEditingPlugin (net.osmand.plus.plugins.osmedit.OsmEditingPlugin)1 OsmNotesPoint (net.osmand.plus.plugins.osmedit.data.OsmNotesPoint)1 OsmPoint (net.osmand.plus.plugins.osmedit.data.OsmPoint)1 OsmBugsDbHelper (net.osmand.plus.plugins.osmedit.helpers.OsmBugsDbHelper)1