From: Tomas Wenström Date: Wed, 29 Mar 2017 18:56:50 +0000 (+0200) Subject: Refactored some consumers X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=d182b8ccdbbbdadc4441170f0135ec98c76f5d17;p=kaka%2Fcakelight.git Refactored some consumers --- diff --git a/src/kaka/cakelight/CakeLight.java b/src/kaka/cakelight/CakeLight.java index 33e0035..5401c0f 100644 --- a/src/kaka/cakelight/CakeLight.java +++ b/src/kaka/cakelight/CakeLight.java @@ -13,7 +13,7 @@ public class CakeLight { public void setMode(Mode mode) { cleanup(); this.mode = mode; - mode.setFrameListener(ledController); + mode.setFrameListener(ledController::onFrame); mode.enter(config); } diff --git a/src/kaka/cakelight/GuiTest.java b/src/kaka/cakelight/GuiTest.java index a3cabf4..6dbb5ff 100644 --- a/src/kaka/cakelight/GuiTest.java +++ b/src/kaka/cakelight/GuiTest.java @@ -58,7 +58,7 @@ public class GuiTest extends Application { log("Running with config:\n" + config); cakelight = new CakeLight(config, new LedController() { @Override - public void accept(LedFrame ledFrame) { + public void onFrame(LedFrame ledFrame) { if (!paused) drawLEDs(canvas.getGraphicsContext2D(), ledFrame); } }); diff --git a/src/kaka/cakelight/LedController.java b/src/kaka/cakelight/LedController.java index 9749483..201644d 100644 --- a/src/kaka/cakelight/LedController.java +++ b/src/kaka/cakelight/LedController.java @@ -1,10 +1,7 @@ package kaka.cakelight; -import java.util.function.Consumer; - -public class LedController implements Consumer { - @Override - public void accept(LedFrame ledFrame) { +public class LedController { + public void onFrame(LedFrame ledFrame) { // TODO } } diff --git a/src/kaka/cakelight/VideoMode.java b/src/kaka/cakelight/VideoMode.java index e4b9400..960f985 100644 --- a/src/kaka/cakelight/VideoMode.java +++ b/src/kaka/cakelight/VideoMode.java @@ -5,7 +5,7 @@ import java.io.IOException; import java.util.Optional; import java.util.function.Consumer; -public class VideoMode extends Mode implements Consumer> { +public class VideoMode extends Mode { private Configuration config; private Thread thread; private Consumer frameConsumer; @@ -13,7 +13,7 @@ public class VideoMode extends Mode implements Consumer> { public VideoMode() { deviceListener = new VideoDeviceListener(); - deviceListener.onVideoDeviceChange(this); + deviceListener.onVideoDeviceChange(this::onVideoDeviceChange); } @Override @@ -58,8 +58,7 @@ public class VideoMode extends Mode implements Consumer> { frameListener.accept(frame.getLedFrame()); } - @Override - public void accept(Optional videoDevice) { + public void onVideoDeviceChange(Optional videoDevice) { // Should only happen when this mode is active! if (thread != null) { thread.interrupt();