diff --git a/logiceditor/src/main/java/com/icst/logic/editor/view/LogicEditorView.java b/logiceditor/src/main/java/com/icst/logic/editor/view/LogicEditorView.java index 60c24ec7..010966f3 100644 --- a/logiceditor/src/main/java/com/icst/logic/editor/view/LogicEditorView.java +++ b/logiceditor/src/main/java/com/icst/logic/editor/view/LogicEditorView.java @@ -175,6 +175,7 @@ public void dropBlock(float x, float y) { } } else if (draggingBean instanceof ActionBlockBean block) { if (dropZone.canDrop(block, x, y)) { + hasNearbyTarget = true; } } diff --git a/logiceditor/src/main/java/com/icst/logic/lib/view/ActionBlockDropZoneView.java b/logiceditor/src/main/java/com/icst/logic/lib/view/ActionBlockDropZoneView.java index b8d21085..ce31b78f 100644 --- a/logiceditor/src/main/java/com/icst/logic/lib/view/ActionBlockDropZoneView.java +++ b/logiceditor/src/main/java/com/icst/logic/lib/view/ActionBlockDropZoneView.java @@ -145,6 +145,7 @@ private void addBlockBeans(ArrayList actionBlocks, int index) { if (actionBlockBeanView == null) continue; + actionBlockBeanView.setInsideCanva(true); super.addView(actionBlockBeanView, i + index); if (i == 0 && index == 0) diff --git a/logiceditor/src/main/java/com/icst/logic/lib/view/MainActionBlockDropZoneView.java b/logiceditor/src/main/java/com/icst/logic/lib/view/MainActionBlockDropZoneView.java index 00a7d9ff..19249317 100644 --- a/logiceditor/src/main/java/com/icst/logic/lib/view/MainActionBlockDropZoneView.java +++ b/logiceditor/src/main/java/com/icst/logic/lib/view/MainActionBlockDropZoneView.java @@ -187,8 +187,8 @@ public void dropToNearestTarget(ArrayList blocks, float x, floa LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lp.setMargins(0, BlockMarginConstants.CHAINED_ACTION_BLOCK_TOP_MARGIN, 0, 0); int index = getIndex(x, y); - if (index == 0) { - index = 1; + if (index != 0) { + index -= 1; } addBlockBeans(blocks, index); } @@ -197,8 +197,8 @@ public void dropToNearestTarget(ArrayList blocks, float x, floa public void dropToNearestTarget(ActionBlockBean block, float x, float y) { if (canDrop(block, x, y)) { int index = getIndex(x, y); - if (index == 0) { - index = 1; + if (index != 0) { + index -= 1; } ArrayList blocks = new ArrayList(); blocks.add(block); @@ -249,15 +249,19 @@ public void addActionBlocksBeans(ArrayList actionBlocks, int in else addBlockBeans(actionBlocks, index); } else { - if (actionBlocks.size() == 0) - return; - if (!(actionBlocks.get(actionBlocks.size() - 1) instanceof TerminatorBlockBean)) - addBlockBeans(actionBlocks, index); + if (isTerminated()) + throw new TerminatedDropZoneException(); else - throw new UnexpectedTerminatedException(); + addBlockBeans(actionBlocks, blockBeans.size()); } - } else - throw new IndexOutOfBoundsException(index); + } else { + if (actionBlocks.size() == 0) + return; + if (!(actionBlocks.get(actionBlocks.size() - 1) instanceof TerminatorBlockBean)) + addBlockBeans(actionBlocks, index); + else + throw new UnexpectedTerminatedException(); + } } private void addBlockBeans(ArrayList actionBlocks, int index) {