import net.pterodactylus.sone.core.event.NewPostFoundEvent;
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.SoneRemovedEvent;
import net.pterodactylus.sone.data.Album;
import net.pterodactylus.sone.data.Client;
for (Post post : storedSone.getPosts()) {
posts.remove(post.getId());
if (!sone.getPosts().contains(post)) {
- coreListenerManager.firePostRemoved(post);
+ eventBus.post(new PostRemovedEvent(post));
}
}
}
synchronized (posts) {
posts.remove(post.getId());
}
- coreListenerManager.firePostRemoved(post);
+ eventBus.post(new PostRemovedEvent(post));
markPostKnown(post);
touchConfiguration();
}
synchronized (knownPosts) {
for (Post post : sone.getPosts()) {
posts.remove(post.getId());
- coreListenerManager.firePostRemoved(post);
+ eventBus.post(new PostRemovedEvent(post));
}
}
}
import java.util.EventListener;
import net.pterodactylus.sone.data.Image;
-import net.pterodactylus.sone.data.Post;
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 post was removed.
- *
- * @param post
- * The removed post
- */
- public void postRemoved(Post post);
-
- /**
* Notifies a listener that the given reply was removed.
*
* @param reply
package net.pterodactylus.sone.core;
import net.pterodactylus.sone.data.Image;
-import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.data.PostReply;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.util.event.AbstractListenerManager;
//
/**
- * Notifies all listener that the given post was removed.
- *
- * @see CoreListener#postRemoved(Post)
- * @param post
- * The removed post
- */
- void firePostRemoved(Post post) {
- for (CoreListener coreListener : getListeners()) {
- coreListener.postRemoved(post);
- }
- }
-
- /**
* Notifies all listener that the given reply was removed.
*
* @see CoreListener#replyRemoved(PostReply)
--- /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.Post;
+
+/**
+ * Event that signals that a {@link Post} was removed.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class PostRemovedEvent extends PostEvent {
+
+ /**
+ * Creates a new “post removed” event.
+ *
+ * @param post
+ * The post that was removed
+ */
+ public PostRemovedEvent(Post post) {
+ super(post);
+ }
+
+}
import net.pterodactylus.sone.core.event.NewPostFoundEvent;
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.SoneRemovedEvent;
import net.pterodactylus.sone.data.Album;
import net.pterodactylus.sone.data.Image;
newSoneNotification.remove(soneRemovedEvent.sone());
}
- //
- // CORELISTENER METHODS
- //
-
/**
- * {@inheritDoc}
+ * Notifies the web interface that a {@link Post} was removed.
+ *
+ * @param postRemovedEvent
+ * The event
*/
- @Override
- public void postRemoved(Post post) {
- newPostNotification.remove(post);
- localPostNotification.remove(post);
- mentionNotification.remove(post);
+ @Subscribe
+ public void postRemoved(PostRemovedEvent postRemovedEvent) {
+ newPostNotification.remove(postRemovedEvent.post());
+ localPostNotification.remove(postRemovedEvent.post());
+ mentionNotification.remove(postRemovedEvent.post());
}
+ //
+ // CORELISTENER METHODS
+ //
+
/**
* {@inheritDoc}
*/