import net.pterodactylus.sone.core.Options.Option;
import net.pterodactylus.sone.core.Options.OptionWatcher;
import net.pterodactylus.sone.core.event.ImageInsertAbortedEvent;
+import net.pterodactylus.sone.core.event.ImageInsertFinishedEvent;
import net.pterodactylus.sone.core.event.ImageInsertStartedEvent;
import net.pterodactylus.sone.core.event.MarkPostKnownEvent;
import net.pterodactylus.sone.core.event.MarkPostReplyKnownEvent;
image.setKey(key.toString());
deleteTemporaryImage(image.getId());
touchConfiguration();
- coreListenerManager.fireImageInsertFinished(image);
+ eventBus.post(new ImageInsertFinishedEvent(image));
}
/**
public interface CoreListener extends EventListener {
/**
- * Notifies a listener that an image was successfully inserted.
- *
- * @param image
- * The image that was inserted
- */
- public void imageInsertFinished(Image image);
-
- /**
* Notifies a listener that an image failed to be inserted.
*
* @param image
//
/**
- * Notifies all listeners that an image was successfully inserted.
- *
- * @see CoreListener#imageInsertFinished(Image)
- * @param image
- * The image that was inserted
- */
- void fireImageInsertFinished(Image image) {
- for (CoreListener coreListener : getListeners()) {
- coreListener.imageInsertFinished(image);
- }
- }
-
- /**
* Notifies all listeners that an image failed to be inserted.
*
* @see CoreListener#imageInsertFailed(Image, Throwable)
--- /dev/null
+/*
+ * Sone - ImageInsertFinishedEvent.java - Copyright © 2013 David Roden
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.sone.core.event;
+
+import net.pterodactylus.sone.data.Image;
+
+/**
+ * Event that signals that an {@link Image} insert is finished.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class ImageInsertFinishedEvent extends ImageEvent {
+
+ /**
+ * Creates a new “image insert finished” event.
+ *
+ * @param image
+ * The image whose insert finished
+ */
+ public ImageInsertFinishedEvent(Image image) {
+ super(image);
+ }
+
+}
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.core.CoreListener;
import net.pterodactylus.sone.core.event.ImageInsertAbortedEvent;
+import net.pterodactylus.sone.core.event.ImageInsertFinishedEvent;
import net.pterodactylus.sone.core.event.ImageInsertStartedEvent;
import net.pterodactylus.sone.core.event.MarkPostKnownEvent;
import net.pterodactylus.sone.core.event.MarkPostReplyKnownEvent;
insertingImagesNotification.remove(imageInsertAbortedEvent.image());
}
- //
- // CORELISTENER METHODS
- //
-
/**
- * {@inheritDoc}
+ * Notifies the web interface that an {@link Image} insert is finished.
+ *
+ * @param imageInsertFinishedEvent
+ * The event
*/
- @Override
- public void imageInsertFinished(Image image) {
- insertingImagesNotification.remove(image);
- insertedImagesNotification.add(image);
+ @Subscribe
+ public void imageInsertFinished(ImageInsertFinishedEvent imageInsertFinishedEvent) {
+ insertingImagesNotification.remove(imageInsertFinishedEvent.image());
+ insertedImagesNotification.add(imageInsertFinishedEvent.image());
notificationManager.addNotification(insertedImagesNotification);
}
+ //
+ // CORELISTENER METHODS
+ //
+
/**
* {@inheritDoc}
*/