Skip to content

Commit

Permalink
fixes: some fixes in logic editor in dropping blocks functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxGalaxy committed Dec 30, 2024
1 parent e7142e7 commit 30db870
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,16 @@ public void dropBlock(float x, float y) {

ActionBlockDropZoneView newZone = new ActionBlockDropZoneView(
getContext(), new LogicEditorConfiguration(), this);

LogicEditorCanvaView.LayoutParams lp = new LogicEditorCanvaView.LayoutParams(
LogicEditorCanvaView.LayoutParams.WRAP_CONTENT,
LogicEditorCanvaView.LayoutParams.WRAP_CONTENT);

newZone.addActionBlocksBeans(blocks, 0);
newZone.setX(x);
newZone.setY(y);
getLogicEditorCanva().addView(newZone);
newZone.setLayoutParams(lp);
blockDropZones.add(newZone);

} else if (draggingBean instanceof ActionBlockBean block) {
Expand All @@ -249,10 +255,16 @@ public void dropBlock(float x, float y) {

ActionBlockDropZoneView newZone = new ActionBlockDropZoneView(
getContext(), new LogicEditorConfiguration(), this);

LogicEditorCanvaView.LayoutParams lp = new LogicEditorCanvaView.LayoutParams(
LogicEditorCanvaView.LayoutParams.WRAP_CONTENT,
LogicEditorCanvaView.LayoutParams.WRAP_CONTENT);

newZone.addActionBlocksBeans(blocks, 0);
newZone.setX(x);
newZone.setY(y);
getLogicEditorCanva().addView(newZone);
newZone.setLayoutParams(lp);
blockDropZones.add(newZone);
}
}
Expand Down Expand Up @@ -280,7 +292,7 @@ public void removeOldReferences() {
} else if (parent instanceof ActionBlockDropZoneView regularChain) {
int index = regularChain.indexOfChild(actionBlockBeanView);
regularChain.getChildAt(index).setOnTouchListener(null);
regularChain.removeViews(index, regularChain.getBlocksSize() - index);
regularChain.removeViews(index, regularChain.getChildCount() - index);
regularChain.dereferenceActionBlocks(index);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ public boolean isTerminated() {
}

public void dereferenceActionBlocks(int index) {
for (int i = index; i <= blockBeans.size(); ++i) {
int numberOfBlocks = blockBeans.size();
for (int i = index; i < numberOfBlocks; ++i) {
blockBeans.remove(index);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ public boolean isTerminated() {
}

public void dereferenceActionBlocks(int index) {
for (int i = index; i <= blockBeans.size(); ++i) {
int numberOfBlocks = blockBeans.size();
for (int i = index; i < numberOfBlocks; ++i) {
blockBeans.remove(index);
}
}
Expand Down

0 comments on commit 30db870

Please sign in to comment.