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.NewPostFoundEvent;
import net.pterodactylus.sone.core.event.NewSoneFoundEvent;
import net.pterodactylus.sone.data.Album;
import net.pterodactylus.sone.data.Client;
knownPosts.add(post.getId());
post.setKnown(true);
} else if (!knownPosts.contains(post.getId())) {
- coreListenerManager.fireNewPostFound(post);
+ eventBus.post(new NewPostFoundEvent(post));
}
}
posts.put(post.getId(), post);
synchronized (posts) {
posts.put(post.getId(), post);
}
- coreListenerManager.fireNewPostFound(post);
+ eventBus.post(new NewPostFoundEvent(post));
sone.addPost(post);
touchConfiguration();
localElementTicker.registerEvent(System.currentTimeMillis() + 10 * 1000, new Runnable() {
public interface CoreListener extends EventListener {
/**
- * Notifies a listener that a new post has been found.
- *
- * @param post
- * The new post
- */
- public void newPostFound(Post post);
-
- /**
* Notifies a listener that a new reply has been found.
*
* @param reply
//
/**
- * Notifies all listeners that a new post has been found.
- *
- * @see CoreListener#newPostFound(Post)
- * @param post
- * The new post
- */
- void fireNewPostFound(Post post) {
- for (CoreListener coreListener : getListeners()) {
- coreListener.newPostFound(post);
- }
- }
-
- /**
* Notifies all listeners that a new reply has been found.
*
* @see CoreListener#newReplyFound(PostReply)
--- /dev/null
+/*
+ * Sone - NewPostFoundEvent.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 new post was found.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class NewPostFoundEvent extends PostEvent {
+
+ /**
+ * Creates a new “new post found” event.
+ *
+ * @param post
+ * The post that was found
+ */
+ public NewPostFoundEvent(Post post) {
+ super(post);
+ }
+
+}
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.core.CoreListener;
+import net.pterodactylus.sone.core.event.NewPostFoundEvent;
import net.pterodactylus.sone.core.event.NewSoneFoundEvent;
import net.pterodactylus.sone.data.Album;
import net.pterodactylus.sone.data.Image;
}
}
- //
- // CORELISTENER METHODS
- //
-
/**
* {@inheritDoc}
*/
- @Override
- public void newPostFound(Post post) {
+ @Subscribe
+ public void newPostFound(NewPostFoundEvent newPostFoundEvent) {
+ Post post = newPostFoundEvent.post();
boolean isLocal = post.getSone().isLocal();
if (isLocal) {
localPostNotification.add(post);
}
}
+ //
+ // CORELISTENER METHODS
+ //
+
/**
* {@inheritDoc}
*/