use of net.osmand.plus.plugins.osmedit.data.OsmPoint in project Osmand by osmandapp.
the class DashOsmEditsFragment method getOsmPoints.
private void getOsmPoints(ArrayList<OsmPoint> dataPoints) {
List<OpenstreetmapPoint> l1 = plugin.getDBPOI().getOpenstreetmapPoints();
List<OsmNotesPoint> l2 = plugin.getDBBug().getOsmbugsPoints();
if (l1.isEmpty()) {
int i = 0;
for (OsmPoint point : l2) {
if (i > 2) {
break;
}
dataPoints.add(point);
i++;
}
} else if (l2.isEmpty()) {
int i = 0;
for (OsmPoint point : l1) {
if (i > 2) {
break;
}
dataPoints.add(point);
i++;
}
} else {
dataPoints.add(l1.get(0));
dataPoints.add(l2.get(0));
if (l1.size() > 1) {
dataPoints.add(l1.get(1));
} else if (l2.size() > 1) {
dataPoints.add(l2.get(1));
}
}
}
use of net.osmand.plus.plugins.osmedit.data.OsmPoint in project Osmand by osmandapp.
the class DashOsmEditsFragment method setupEditings.
private void setupEditings() {
View mainView = getView();
assert mainView != null;
if (plugin == null) {
mainView.setVisibility(View.GONE);
return;
}
ArrayList<OsmPoint> dataPoints = new ArrayList<>();
getOsmPoints(dataPoints);
if (dataPoints.size() == 0) {
mainView.setVisibility(View.GONE);
return;
} else {
mainView.setVisibility(View.VISIBLE);
DashboardOnMap.handleNumberOfRows(dataPoints, getMyApplication().getSettings(), ROW_NUMBER_TAG);
}
LinearLayout osmLayout = (LinearLayout) mainView.findViewById(R.id.items);
osmLayout.removeAllViews();
for (final OsmPoint point : dataPoints) {
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.note, null, false);
OsmEditsFragment.getOsmEditView(view, point, getMyApplication());
ImageButton send = (ImageButton) view.findViewById(R.id.play);
send.setImageDrawable(getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_action_export));
send.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (point.getGroup() == OsmPoint.Group.POI) {
selectedPoint = point;
if (getMyApplication().getOsmOAuthHelper().isLogged()) {
SendPoiBottomSheetFragment.showInstance(getChildFragmentManager(), new OsmPoint[] { point });
} else {
LoginBottomSheetFragment.showInstance(getActivity().getSupportFragmentManager(), DashOsmEditsFragment.this);
}
} else {
SendOsmNoteBottomSheetFragment.showInstance(getChildFragmentManager(), new OsmPoint[] { point });
}
}
});
view.findViewById(R.id.options).setVisibility(View.GONE);
view.findViewById(R.id.divider).setVisibility(View.VISIBLE);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean poi = point.getGroup() == OsmPoint.Group.POI;
String name = poi ? ((OpenstreetmapPoint) point).getName() : ((OsmNotesPoint) point).getText();
getMyApplication().getSettings().setMapLocationToShow(point.getLatitude(), point.getLongitude(), 15, new PointDescription(poi ? PointDescription.POINT_TYPE_POI : PointDescription.POINT_TYPE_OSM_BUG, name), true, // $NON-NLS-1$
point);
MapActivity.launchMapActivityMoveToTop(getActivity());
}
});
osmLayout.addView(view);
}
}
use of net.osmand.plus.plugins.osmedit.data.OsmPoint in project Osmand by osmandapp.
the class OsmEditsAdapter method getIcon.
private Drawable getIcon(OsmPoint point) {
if (point.getGroup() == OsmPoint.Group.POI) {
OpenstreetmapPoint osmPoint = (OpenstreetmapPoint) point;
int iconResId = 0;
String poiTranslation = osmPoint.getEntity().getTag(Entity.POI_TYPE_TAG);
if (poiTranslation != null) {
Map<String, PoiType> poiTypeMap = app.getPoiTypes().getAllTranslatedNames(false);
PoiType poiType = poiTypeMap.get(poiTranslation.toLowerCase());
if (poiType != null) {
String id = null;
if (RenderingIcons.containsBigIcon(poiType.getIconKeyName())) {
id = poiType.getIconKeyName();
} else if (RenderingIcons.containsBigIcon(poiType.getOsmTag() + "_" + poiType.getOsmValue())) {
id = poiType.getOsmTag() + "_" + poiType.getOsmValue();
}
if (id != null) {
iconResId = RenderingIcons.getBigIconResourceId(id);
}
}
}
if (iconResId == 0) {
iconResId = R.drawable.ic_action_info_dark;
}
int colorResId = R.color.color_distance;
if (point.getAction() == OsmPoint.Action.CREATE) {
colorResId = R.color.color_osm_edit_create;
} else if (point.getAction() == OsmPoint.Action.MODIFY) {
colorResId = R.color.color_osm_edit_modify;
} else if (point.getAction() == OsmPoint.Action.DELETE) {
colorResId = R.color.color_osm_edit_delete;
} else if (point.getAction() == OsmPoint.Action.REOPEN) {
colorResId = R.color.color_osm_edit_modify;
}
return app.getUIUtilities().getIcon(iconResId, colorResId);
} else if (point.getGroup() == OsmPoint.Group.BUG) {
return app.getUIUtilities().getIcon(R.drawable.ic_action_osm_note_add, R.color.color_distance);
}
return null;
}
use of net.osmand.plus.plugins.osmedit.data.OsmPoint in project Osmand by osmandapp.
the class OsmEditsAdapter method getView.
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
boolean nightMode = !app.getSettings().isLightContent();
Context themedCtx = UiUtilities.getThemedContext(getContext(), nightMode);
if (portrait) {
if (convertView == null) {
if (position == 0) {
convertView = LayoutInflater.from(themedCtx).inflate(R.layout.list_item_header, parent, false);
HeaderViewHolder holder = new HeaderViewHolder(convertView);
convertView.setTag(holder);
} else {
convertView = LayoutInflater.from(themedCtx).inflate(R.layout.note_list_item, parent, false);
OsmEditViewHolder holder = new OsmEditViewHolder(convertView);
convertView.setTag(holder);
}
}
if (position == 0) {
bindHeaderViewHolder((HeaderViewHolder) convertView.getTag());
} else {
final Object item = getItem(position);
if (item instanceof OsmPoint) {
final OsmEditViewHolder holder = (OsmEditViewHolder) convertView.getTag();
bindOsmEditViewHolder(holder, (OsmPoint) item, position);
}
}
return convertView;
} else {
int margin = app.getResources().getDimensionPixelSize(R.dimen.content_padding);
int sideMargin = app.getResources().getDisplayMetrics().widthPixels / 10;
FrameLayout fl = new FrameLayout(themedCtx);
LinearLayout ll = new LinearLayout(themedCtx);
ll.setOrientation(LinearLayout.VERTICAL);
ll.setBackgroundResource(app.getSettings().isLightContent() ? R.drawable.bg_card_light : R.drawable.bg_card_dark);
fl.addView(ll);
((FrameLayout.LayoutParams) ll.getLayoutParams()).setMargins(sideMargin, margin, sideMargin, margin);
HeaderViewHolder headerViewHolder = new HeaderViewHolder(LayoutInflater.from(themedCtx).inflate(R.layout.list_item_header, parent, false));
bindHeaderViewHolder(headerViewHolder);
ll.addView(headerViewHolder.mainView);
for (int i = 0; i < items.size(); i++) {
Object item = getItem(i);
if (item instanceof OsmPoint) {
OsmEditViewHolder viewHolder = new OsmEditViewHolder(LayoutInflater.from(themedCtx).inflate(R.layout.note_list_item, parent, false));
bindOsmEditViewHolder(viewHolder, (OsmPoint) item, i);
ll.addView(viewHolder.mainView);
}
}
return fl;
}
}
use of net.osmand.plus.plugins.osmedit.data.OsmPoint in project Osmand by osmandapp.
the class OsmEditsLayer method getOsmEditsFromPoint.
public void getOsmEditsFromPoint(PointF point, RotatedTileBox tileBox, List<? super OsmPoint> am) {
int ex = (int) point.x;
int ey = (int) point.y;
int compare = getScaledTouchRadius(app, getRadiusPoi(tileBox));
int radius = compare * 3 / 2;
compare = getFromPoint(tileBox, am, ex, ey, compare, radius, plugin.getDBBug().getOsmbugsPoints());
getFromPoint(tileBox, am, ex, ey, compare, radius, plugin.getDBPOI().getOpenstreetmapPoints());
}
Aggregations