use of net.osmand.plus.views.controls.DynamicListView.DragIcon in project Osmand by osmandapp.
the class WaypointDialogHelper method updateWaypointItemView.
public static View updateWaypointItemView(final boolean edit, final List<LocationPointWrapper> deletedPoints, final OsmandApplication app, final Activity ctx, final WaypointDialogHelper helper, View v, final LocationPointWrapper point, final ArrayAdapter adapter, final boolean nightMode, final boolean flat) {
if (v == null || v.findViewById(R.id.info_close) == null) {
v = ctx.getLayoutInflater().inflate(R.layout.waypoint_reached, null);
}
updatePointInfoView(app, ctx, v, point, true, nightMode, edit, false);
v.findViewById(R.id.all_points).setVisibility(View.GONE);
final ImageView move = (ImageView) v.findViewById(R.id.info_move);
final ImageButton remove = (ImageButton) v.findViewById(R.id.info_close);
if (!edit) {
remove.setVisibility(View.GONE);
move.setVisibility(View.GONE);
} else {
boolean targets = point.type == WaypointHelper.TARGETS;
boolean notFlatTargets = targets && !flat;
boolean startPoint = notFlatTargets && ((TargetPoint) point.point).start;
final TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper();
boolean canRemove = !targets || !targetPointsHelper.getIntermediatePoints().isEmpty();
int iconResId = nightMode ? R.color.marker_circle_button_color_dark : R.color.ctx_menu_title_color_dark;
remove.setVisibility(View.VISIBLE);
remove.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_remove_dark, iconResId));
remove.setEnabled(canRemove);
remove.setAlpha(canRemove ? 1 : .5f);
if (canRemove) {
if (notFlatTargets && startPoint) {
remove.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (targetPointsHelper.getPointToStart() == null) {
if (!targetPointsHelper.getIntermediatePoints().isEmpty()) {
replaceStartWithFirstIntermediate(targetPointsHelper, ctx, helper);
}
} else {
targetPointsHelper.setStartPoint(null, true, null);
updateControls(ctx, helper);
}
}
});
} else {
remove.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
deletePoint(app, ctx, adapter, helper, point, deletedPoints, true);
}
});
}
}
move.setVisibility(notFlatTargets ? View.VISIBLE : View.GONE);
if (notFlatTargets) {
move.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_reorder, iconResId));
move.setTag(new DragIcon() {
@Override
public void onClick() {
// do nothing
}
});
}
}
return v;
}
Aggregations