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);
}
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();
}
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;
}
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;
}
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;
}
Aggregations