From 7f2686166e888c547f968f11e6d9fe141e1acdcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Mart=C3=ADnez=20Portela?= Date: Tue, 26 May 2020 10:52:24 +0200 Subject: [PATCH] Implement custom block unlinking and pausing. --- .../parts/ProgramakerCustomBlockPart.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/codigoparallevar/minicards/parts/ProgramakerCustomBlockPart.java b/app/src/main/java/com/codigoparallevar/minicards/parts/ProgramakerCustomBlockPart.java index 62144c0..5810e00 100644 --- a/app/src/main/java/com/codigoparallevar/minicards/parts/ProgramakerCustomBlockPart.java +++ b/app/src/main/java/com/codigoparallevar/minicards/parts/ProgramakerCustomBlockPart.java @@ -53,6 +53,7 @@ public class ProgramakerCustomBlockPart implements Part { private int height = 100; private String token = null; private Object[] lastValues; + private boolean active = true; public ProgramakerCustomBlockPart(String id, PartGrid grid, Tuple2 center, ProgramakerCustomBlock block) { @@ -337,6 +338,11 @@ public class ProgramakerCustomBlockPart implements Part { } private void runBlockOperation() { + if (!this.active) { + Log.w(LogTag, "Trying to run inactive block function=" + this._block.getFunction_name()); + return; + } + ProgramakerApi api = this._partGrid.getApi(); List arguments = new LinkedList<>(); @@ -435,12 +441,12 @@ public class ProgramakerCustomBlockPart implements Part { @Override public void resume() { - // Intentionally left empty + this.active = true; } @Override public void pause() { - // Intentionally left empty + this.active = false; } @Override @@ -542,6 +548,9 @@ public class ProgramakerCustomBlockPart implements Part { @Override public void unlink() { - // TODO: Implement + this.active = false; + for (InputConnector input : getInputConnectors()) { + input.unlink(); + } } }