From f29f2dc508c4553c12f1329df213910432612b2a Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 16 Jan 2013 19:32:48 +0100 Subject: [PATCH] =?utf8?q?Convert=20=E2=80=9Cimage=20is=20inserted?= =?utf8?q?=E2=80=9D=20into=20EventBus-based=20event.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../java/net/pterodactylus/sone/core/Core.java | 3 +- .../net/pterodactylus/sone/core/CoreListener.java | 8 ----- .../sone/core/CoreListenerManager.java | 13 -------- .../sone/core/event/ImageInsertStartedEvent.java | 39 ++++++++++++++++++++++ .../net/pterodactylus/sone/web/WebInterface.java | 20 ++++++----- 5 files changed, 53 insertions(+), 30 deletions(-) create mode 100644 src/main/java/net/pterodactylus/sone/core/event/ImageInsertStartedEvent.java diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 8318d03..f47b76b 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -35,6 +35,7 @@ import java.util.logging.Logger; import net.pterodactylus.sone.core.Options.DefaultOption; import net.pterodactylus.sone.core.Options.Option; import net.pterodactylus.sone.core.Options.OptionWatcher; +import net.pterodactylus.sone.core.event.ImageInsertStartedEvent; import net.pterodactylus.sone.core.event.MarkPostKnownEvent; import net.pterodactylus.sone.core.event.MarkPostReplyKnownEvent; import net.pterodactylus.sone.core.event.MarkSoneKnownEvent; @@ -2495,7 +2496,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis @Override public void imageInsertStarted(Image image) { logger.log(Level.WARNING, String.format("Image insert started for %s...", image)); - coreListenerManager.fireImageInsertStarted(image); + eventBus.post(new ImageInsertStartedEvent(image)); } /** diff --git a/src/main/java/net/pterodactylus/sone/core/CoreListener.java b/src/main/java/net/pterodactylus/sone/core/CoreListener.java index f644f50..9bc8c0c 100644 --- a/src/main/java/net/pterodactylus/sone/core/CoreListener.java +++ b/src/main/java/net/pterodactylus/sone/core/CoreListener.java @@ -30,14 +30,6 @@ import net.pterodactylus.sone.data.Image; public interface CoreListener extends EventListener { /** - * Notifies a listener that an image has started being inserted. - * - * @param image - * The image that is now inserted - */ - public void imageInsertStarted(Image image); - - /** * Notifies a listener that an image insert was aborted by the user. * * @param image diff --git a/src/main/java/net/pterodactylus/sone/core/CoreListenerManager.java b/src/main/java/net/pterodactylus/sone/core/CoreListenerManager.java index bb93fd7..55853c9 100644 --- a/src/main/java/net/pterodactylus/sone/core/CoreListenerManager.java +++ b/src/main/java/net/pterodactylus/sone/core/CoreListenerManager.java @@ -42,19 +42,6 @@ public class CoreListenerManager extends AbstractListenerManager. + */ + +package net.pterodactylus.sone.core.event; + +import net.pterodactylus.sone.data.Image; + +/** + * Event that signals that an {@link Image} is not being inserted. + * + * @author David ‘Bombe’ Roden + */ +public class ImageInsertStartedEvent extends ImageEvent { + + /** + * Creates a new “image is inserted” event. + * + * @param image + * The image that is being inserted + */ + public ImageInsertStartedEvent(Image image) { + super(image); + } + +} diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index dc4c4f0..a30508e 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -37,6 +37,7 @@ import java.util.logging.Logger; import net.pterodactylus.sone.core.Core; import net.pterodactylus.sone.core.CoreListener; +import net.pterodactylus.sone.core.event.ImageInsertStartedEvent; import net.pterodactylus.sone.core.event.MarkPostKnownEvent; import net.pterodactylus.sone.core.event.MarkPostReplyKnownEvent; import net.pterodactylus.sone.core.event.MarkSoneKnownEvent; @@ -1036,19 +1037,22 @@ public class WebInterface implements CoreListener { notificationManager.addNotification(newVersionNotification); } - // - // CORELISTENER METHODS - // - /** - * {@inheritDoc} + * Notifies the web interface that an image insert was started + * + * @param imageInsertStartedEvent + * The event */ - @Override - public void imageInsertStarted(Image image) { - insertingImagesNotification.add(image); + @Subscribe + public void imageInsertStarted(ImageInsertStartedEvent imageInsertStartedEvent) { + insertingImagesNotification.add(imageInsertStartedEvent.image()); notificationManager.addNotification(insertingImagesNotification); } + // + // CORELISTENER METHODS + // + /** * {@inheritDoc} */ -- 2.7.4