From: David ‘Bombe’ Roden Date: Wed, 16 Jan 2013 18:32:48 +0000 (+0100) Subject: Convert “image is inserted” into EventBus-based event. X-Git-Tag: 0.8.5^2~3^2~98 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=f29f2dc508c4553c12f1329df213910432612b2a;p=Sone.git Convert “image is inserted” into EventBus-based event. --- 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} */