import net.pterodactylus.sone.core.event.NewPostReplyFoundEvent;
import net.pterodactylus.sone.core.event.NewSoneFoundEvent;
import net.pterodactylus.sone.core.event.PostRemovedEvent;
+import net.pterodactylus.sone.core.event.PostReplyRemovedEvent;
import net.pterodactylus.sone.core.event.SoneRemovedEvent;
import net.pterodactylus.sone.data.Album;
import net.pterodactylus.sone.data.Client;
for (PostReply reply : storedSone.getReplies()) {
replies.remove(reply.getId());
if (!sone.getReplies().contains(reply)) {
- coreListenerManager.fireReplyRemoved(reply);
+ eventBus.post(new PostReplyRemovedEvent(reply));
}
}
}
synchronized (knownReplies) {
for (PostReply reply : sone.getReplies()) {
replies.remove(reply.getId());
- coreListenerManager.fireReplyRemoved(reply);
+ eventBus.post(new PostReplyRemovedEvent(reply));
}
}
}
import java.util.EventListener;
import net.pterodactylus.sone.data.Image;
-import net.pterodactylus.sone.data.PostReply;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.util.version.Version;
public interface CoreListener extends EventListener {
/**
- * Notifies a listener that the given reply was removed.
- *
- * @param reply
- * The removed reply
- */
- public void replyRemoved(PostReply reply);
-
- /**
* Notifies a listener when a Sone was locked.
*
* @param sone
package net.pterodactylus.sone.core;
import net.pterodactylus.sone.data.Image;
-import net.pterodactylus.sone.data.PostReply;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.util.event.AbstractListenerManager;
import net.pterodactylus.util.version.Version;
//
/**
- * Notifies all listener that the given reply was removed.
- *
- * @see CoreListener#replyRemoved(PostReply)
- * @param reply
- * The removed reply
- */
- void fireReplyRemoved(PostReply reply) {
- for (CoreListener coreListener : getListeners()) {
- coreListener.replyRemoved(reply);
- }
- }
-
- /**
* Notifies all listeners that the given Sone was locked.
*
* @see CoreListener#soneLocked(Sone)
--- /dev/null
+/*
+ * Sone - PostRemovedEvent.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.PostReply;
+
+/**
+ * Event that signals that a {@link PostReply} was removed.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class PostReplyRemovedEvent extends PostReplyEvent {
+
+ /**
+ * Creates a new “post reply removed” event.
+ *
+ * @param postReply
+ * The post reply that was removed
+ */
+ public PostReplyRemovedEvent(PostReply postReply) {
+ super(postReply);
+ }
+
+}
import net.pterodactylus.sone.core.event.NewPostReplyFoundEvent;
import net.pterodactylus.sone.core.event.NewSoneFoundEvent;
import net.pterodactylus.sone.core.event.PostRemovedEvent;
+import net.pterodactylus.sone.core.event.PostReplyRemovedEvent;
import net.pterodactylus.sone.core.event.SoneRemovedEvent;
import net.pterodactylus.sone.data.Album;
import net.pterodactylus.sone.data.Image;
mentionNotification.remove(postRemovedEvent.post());
}
- //
- // CORELISTENER METHODS
- //
-
/**
- * {@inheritDoc}
+ * Notifies the web interface that a {@link PostReply} was removed.
+ *
+ * @param postReplyRemovedEvent
+ * The event
*/
- @Override
- public void replyRemoved(PostReply reply) {
+ @Subscribe
+ public void replyRemoved(PostReplyRemovedEvent postReplyRemovedEvent) {
+ PostReply reply = postReplyRemovedEvent.postReply();
newReplyNotification.remove(reply);
localReplyNotification.remove(reply);
if (!getMentionedSones(reply.getText()).isEmpty()) {
}
}
+ //
+ // CORELISTENER METHODS
+ //
+
/**
* {@inheritDoc}
*/