Search in sources :

Example 11 with OsmNotesPoint

use of net.osmand.plus.plugins.osmedit.data.OsmNotesPoint in project Osmand by osmandapp.

the class OsmEditsFragment method fetchData.

private void fetchData() {
    boolean portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
    osmEdits = new ArrayList<>();
    List<OpenstreetmapPoint> l1 = plugin.getDBPOI().getOpenstreetmapPoints();
    List<OsmNotesPoint> l2 = plugin.getDBBug().getOsmbugsPoints();
    osmEdits.addAll(l1);
    osmEdits.addAll(l2);
    ListView listView = getListView();
    listView.setDivider(null);
    listView.setEmptyView(emptyView);
    if (osmEdits.size() > 0 && footerView == null && portrait) {
        footerView = getActivity().getLayoutInflater().inflate(R.layout.list_shadow_footer, listView, false);
        listView.addFooterView(footerView);
    }
    List<Object> items = createItemsList();
    listAdapter = new OsmEditsAdapter(getMyApplication(), items);
    listAdapter.setSelectedOsmEdits(osmEditsSelected);
    listAdapter.setAdapterListener(new OsmEditsAdapter.OsmEditsAdapterListener() {

        @Override
        public void onHeaderCheckboxClick(boolean checked) {
            if (checked) {
                selectAll();
            } else {
                deselectAll();
            }
            updateSelectionTitle(actionMode);
        }

        @Override
        public void onItemSelect(OsmPoint point, boolean checked) {
            if (checked) {
                osmEditsSelected.add(point);
            } else {
                osmEditsSelected.remove(point);
            }
            updateSelectionMode(actionMode);
        }

        @Override
        public void onItemShowMap(OsmPoint point, int position) {
            showOnMap(point, position);
        }

        @Override
        public void onOptionsClick(OsmPoint note) {
            openPopUpMenu(note);
        }
    });
    listAdapter.setPortrait(portrait);
    listView.setAdapter(listAdapter);
}
Also used : OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) OsmEditsAdapter(net.osmand.plus.plugins.osmedit.OsmEditsAdapter) OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) ListView(android.widget.ListView)

Example 12 with OsmNotesPoint

use of net.osmand.plus.plugins.osmedit.data.OsmNotesPoint in project Osmand by osmandapp.

the class SendOsmNoteBottomSheetFragment method onRightBottomButtonClick.

@Override
protected void onRightBottomButtonClick() {
    ProgressDialogPoiUploader progressDialogPoiUploader = null;
    Activity activity = getActivity();
    if (activity instanceof MapActivity) {
        if (getParentFragment() instanceof DashOsmEditsFragment) {
            progressDialogPoiUploader = (ProgressDialogPoiUploader) getParentFragment();
        } else {
            progressDialogPoiUploader = new SimpleProgressDialogPoiUploader((MapActivity) activity);
        }
    } else if (getParentFragment() instanceof ProgressDialogPoiUploader) {
        progressDialogPoiUploader = (ProgressDialogPoiUploader) getParentFragment();
    }
    if (progressDialogPoiUploader != null) {
        ((OsmNotesPoint) poi[0]).setText(noteText.getText().toString());
        progressDialogPoiUploader.showProgressDialog(poi, false, uploadAnonymously.isChecked());
    }
    dismiss();
}
Also used : OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) FragmentActivity(androidx.fragment.app.FragmentActivity) Activity(android.app.Activity) MapActivity(net.osmand.plus.activities.MapActivity) DashOsmEditsFragment(net.osmand.plus.plugins.osmedit.fragments.DashOsmEditsFragment) MapActivity(net.osmand.plus.activities.MapActivity)

Example 13 with OsmNotesPoint

use of net.osmand.plus.plugins.osmedit.data.OsmNotesPoint in project Osmand by osmandapp.

the class UploadOpenstreetmapPointAsyncTask method doInBackground.

@Override
protected Map<OsmPoint, String> doInBackground(OsmPoint... points) {
    TrafficStats.setThreadStatsTag(THREAD_ID);
    Map<OsmPoint, String> loadErrorsMap = new HashMap<>();
    boolean uploaded = false;
    for (OsmPoint point : points) {
        if (interruptUploading) {
            break;
        }
        if (point.getGroup() == OsmPoint.Group.POI) {
            OpenstreetmapPoint p = (OpenstreetmapPoint) point;
            EntityInfo entityInfo = null;
            p.trimChangedTagNamesValues();
            if (OsmPoint.Action.CREATE != p.getAction()) {
                entityInfo = remotepoi.loadEntity(p.getEntity());
            }
            Entity n = remotepoi.commitEntityImpl(p.getAction(), p.getEntity(), entityInfo, p.getComment(), false, null);
            if (n != null) {
                uploaded = true;
                plugin.getDBPOI().deletePOI(p);
                publishProgress(p);
            }
            loadErrorsMap.put(point, n != null ? null : "Unknown problem");
        } else if (point.getGroup() == OsmPoint.Group.BUG) {
            OsmNotesPoint p = (OsmNotesPoint) point;
            String errorMessage = remotebug.commit(p, p.getText(), p.getAction(), loadAnonymous).warning;
            if (errorMessage == null) {
                plugin.getDBBug().deleteAllBugModifications(p);
                publishProgress(p);
            }
            loadErrorsMap.put(point, errorMessage);
        }
    }
    if (uploaded && closeChangeSet) {
        remotepoi.closeChangeSet();
    }
    return loadErrorsMap;
}
Also used : Entity(net.osmand.osm.edit.Entity) OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) HashMap(java.util.HashMap) EntityInfo(net.osmand.osm.edit.EntityInfo) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint)

Example 14 with OsmNotesPoint

use of net.osmand.plus.plugins.osmedit.data.OsmNotesPoint in project Osmand by osmandapp.

the class OsmBugsDbHelper method getOsmbugsPoints.

public List<OsmNotesPoint> getOsmbugsPoints() {
    if (cache == null) {
        SQLiteDatabase db = getReadableDatabase();
        List<OsmNotesPoint> res = checkOsmbugsPoints(db);
        db.close();
        return res;
    }
    return cache;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint)

Example 15 with OsmNotesPoint

use of net.osmand.plus.plugins.osmedit.data.OsmNotesPoint in project Osmand by osmandapp.

the class OsmBugsDbHelper method checkOsmbugsPoints.

private List<OsmNotesPoint> checkOsmbugsPoints(SQLiteDatabase db) {
    List<OsmNotesPoint> cachedOsmbugsPoints = new ArrayList<OsmNotesPoint>();
    if (db != null) {
        Cursor query = db.rawQuery(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
        "SELECT " + OSMBUGS_COL_ID + ", " + OSMBUGS_COL_TEXT + ", " + OSMBUGS_COL_LAT + "," + OSMBUGS_COL_LON + "," + OSMBUGS_COL_ACTION + "," + OSMBUGS_COL_AUTHOR + " FROM " + OSMBUGS_TABLE_NAME, null);
        if (query.moveToFirst()) {
            do {
                boolean isValidId = Algorithms.isInt(query.getString(0));
                if (!isValidId) {
                    continue;
                }
                OsmNotesPoint p = new OsmNotesPoint();
                p.setId(query.getLong(0));
                p.setText(query.getString(1));
                p.setLatitude(query.getDouble(2));
                p.setLongitude(query.getDouble(3));
                p.setAction(query.getString(4));
                p.setAuthor(query.getString(5));
                cachedOsmbugsPoints.add(p);
            } while (query.moveToNext());
        }
        query.close();
        cache = cachedOsmbugsPoints;
    }
    return cachedOsmbugsPoints;
}
Also used : OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor)

Aggregations

OsmNotesPoint (net.osmand.plus.plugins.osmedit.data.OsmNotesPoint)29 OpenstreetmapPoint (net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint)16 OsmPoint (net.osmand.plus.plugins.osmedit.data.OsmPoint)13 ArrayList (java.util.ArrayList)7 View (android.view.View)5 File (java.io.File)5 HistoryEntry (net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry)5 MapMarkersGroup (net.osmand.plus.mapmarkers.MapMarkersGroup)5 FavoriteGroup (net.osmand.plus.myplaces.FavoriteGroup)5 ITileSource (net.osmand.map.ITileSource)4 AvoidRoadInfo (net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo)4 OnlineRoutingEngine (net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine)4 OsmEditingPlugin (net.osmand.plus.plugins.osmedit.OsmEditingPlugin)4 PoiUIFilter (net.osmand.plus.poi.PoiUIFilter)4 QuickAction (net.osmand.plus.quickaction.QuickAction)4 TextView (android.widget.TextView)3 Entity (net.osmand.osm.edit.Entity)3 LinearLayout (android.widget.LinearLayout)2 NonNull (androidx.annotation.NonNull)2 FragmentActivity (androidx.fragment.app.FragmentActivity)2