src/main/java/de/blau/android/easyedit/turnrestriction/FromElementActionModeCallback.java
/**
     * In the simplest case this selects the next step in creating the restriction, in the worst it splits both the via
     * and from way and restarts the process.
     */
In the simplest case this selects the next step in creating the restriction, in the worst it splits both the via
and from way and restarts the process.
In the simplest case this selects the next step in creating the restriction in the worst it splits both the via and from way and restarts the process .
@Override
    public boolean handleElementClick(OsmElement element) { 
        super.handleElementClick(element);
        Node viaNode = null;
        Way viaWay = null;
        if (Node.NAME.equals(element.getName())) {
            viaNode = (Node) element;
        } else if (Way.NAME.equals(element.getName())) {
            viaWay = (Way) element;
            viaNode = fromWay.getCommonNode(viaWay);
        } else {
            Log.e(DEBUG_TAG, element.getName() + " clicked");
            return true;
        }
        if (viaWay != null && viaWay.equals(fromWay)) {
            main.startSupportActionMode(
                    new RestrictionWaySplittingActionModeCallback(manager, R.string.actionmode_restriction_split_from, fromWay, null, savedResults));
            return true;
        }
        final boolean fromNeedsSplit = !fromWay.isEndNode(viaNode);
        final boolean viaNeedsSplit = viaWay != null && !viaWay.isEndNode(viaNode);
        if (fromNeedsSplit || viaNeedsSplit) {
            List<Way> toSplit = new ArrayList<>();
            if (fromNeedsSplit) {
                toSplit.add(fromWay);
            }
            if (viaNeedsSplit) {
                toSplit.add(viaWay);
            }
            final Node splitNode = viaNode;
            final Way splitViaWay = viaWay;
            splitSafe(toSplit, () -> {
                try {
                    Way newFromWay = null;
                    if (fromNeedsSplit) {
                        List<Result> result = logic.performSplit(main, fromWay, splitNode);
                        newFromWay = newWayFromSplitResult(result);
                        saveSplitResult(fromWay, result);
                    }
                    Way newViaWay = null;
                    if (viaNeedsSplit) {
                        List<Result> result = logic.performSplit(main, splitViaWay, splitNode);
                        newViaWay = newWayFromSplitResult(result);
                        saveSplitResult(splitViaWay, result);
                    }
                    nextStep(element, newFromWay, newViaWay);
                } catch (OsmIllegalOperationException | StorageException ex) {
                    manager.finish();
                }
            });
        } else {
            nextStep(element, null, null);
        }
        return true;
    }
@ Override public boolean handleElementClick ( OsmElement element ) { super . handleElementClick ( element ) ; Node viaNode = null ; Way viaWay = null ; if ( Node . NAME . equals ( element . getName ( ) ) ) { viaNode = ( Node ) element ; } else if ( Way . NAME . equals ( element . getName ( ) ) ) { viaWay = ( Way ) element ; viaNode = fromWay . getCommonNode ( viaWay ) ; } else { Log . e ( DEBUG_TAG , element . getName ( ) + " clicked" ) ; return true ; } if ( viaWay != null && viaWay . equals ( fromWay ) ) { main . startSupportActionMode ( new RestrictionWaySplittingActionModeCallback ( manager , R . string . actionmode_restriction_split_from , fromWay , null , savedResults ) ) ; return true ; } final boolean fromNeedsSplit = ! fromWay . isEndNode ( viaNode ) ; final boolean viaNeedsSplit = viaWay != null && ! viaWay . isEndNode ( viaNode ) ; if ( fromNeedsSplit || viaNeedsSplit ) { List < Way > toSplit = new ArrayList < > ( ) ; if ( fromNeedsSplit ) { toSplit . add ( fromWay ) ; } if ( viaNeedsSplit ) { toSplit . add ( viaWay ) ; } final Node splitNode = viaNode ; final Way splitViaWay = viaWay ; splitSafe ( toSplit , ( ) -> { try { Way newFromWay = null ; if ( fromNeedsSplit ) { List < Result > result = logic . performSplit ( main , fromWay , splitNode ) ; newFromWay = newWayFromSplitResult ( result ) ; saveSplitResult ( fromWay , result ) ; } Way newViaWay = null ; if ( viaNeedsSplit ) { List < Result > result = logic . performSplit ( main , splitViaWay , splitNode ) ; newViaWay = newWayFromSplitResult ( result ) ; saveSplitResult ( splitViaWay , result ) ; } nextStep ( element , newFromWay , newViaWay ) ; } catch ( OsmIllegalOperationException | StorageException ex ) { manager . finish ( ) ; } } ) ; } else { nextStep ( element , null , null ) ; } return true ; }
In the simplest case this selects the next step in creating the restriction, in the worst it splits both the via
 and from way and restarts the process.
In the simplest case this selects the next step in creating the restriction in the worst it splits both the via and from way and restarts the process .
// NOSONAR // due to clickableElements, only valid nodes can be clicked // check if we have to split from or via // FIXME show a warning // we need to split fromWay first // split from at node // toast has already been displayed