Search in sources :

Example 1 with DragIcon

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;
}
Also used : ImageButton(android.widget.ImageButton) DragIcon(net.osmand.plus.views.controls.DynamicListView.DragIcon) ImageView(android.widget.ImageView) TargetPointsHelper(net.osmand.plus.TargetPointsHelper) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) LocationPoint(net.osmand.data.LocationPoint) SuppressLint(android.annotation.SuppressLint) FavouritePoint(net.osmand.data.FavouritePoint)

Aggregations

SuppressLint (android.annotation.SuppressLint)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ImageButton (android.widget.ImageButton)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 FavouritePoint (net.osmand.data.FavouritePoint)1 LocationPoint (net.osmand.data.LocationPoint)1 TargetPointsHelper (net.osmand.plus.TargetPointsHelper)1 TargetPoint (net.osmand.plus.TargetPointsHelper.TargetPoint)1 DragIcon (net.osmand.plus.views.controls.DynamicListView.DragIcon)1