From 5b6767cdd9eece7d2a08f52016b3e35340d1f22f Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 14 Nov 2010 20:48:36 +0100 Subject: [PATCH] Add events for marked known posts and replies. --- .../java/net/pterodactylus/sone/core/Core.java | 6 ++++++ .../net/pterodactylus/sone/core/CoreListener.java | 16 +++++++++++++++ .../sone/core/CoreListenerManager.java | 24 ++++++++++++++++++++++ .../net/pterodactylus/sone/web/WebInterface.java | 16 +++++++++++++++ 4 files changed, 62 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 0fbbf3c..4c08651 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -488,6 +488,9 @@ public class Core implements IdentityListener { synchronized (newPosts) { boolean isNew = !knownPosts.contains(postId) && newPosts.remove(postId); knownPosts.add(postId); + if (isNew) { + coreListenerManager.fireMarkPostKnown(getPost(postId)); + } return isNew; } } @@ -543,6 +546,9 @@ public class Core implements IdentityListener { synchronized (newReplies) { boolean isNew = !knownReplies.contains(replyId) && newReplies.remove(replyId); knownReplies.add(replyId); + if (isNew) { + coreListenerManager.fireMarkReplyKnown(getReply(replyId)); + } return isNew; } } diff --git a/src/main/java/net/pterodactylus/sone/core/CoreListener.java b/src/main/java/net/pterodactylus/sone/core/CoreListener.java index f8278ed..ca99e87 100644 --- a/src/main/java/net/pterodactylus/sone/core/CoreListener.java +++ b/src/main/java/net/pterodactylus/sone/core/CoreListener.java @@ -63,4 +63,20 @@ public interface CoreListener extends EventListener { */ public void markSoneKnown(Sone sone); + /** + * Notifies a listener that the given post is now marked as known. + * + * @param post + * The known post + */ + public void markPostKnown(Post post); + + /** + * Notifies a listener that the given reply is now marked as known. + * + * @param reply + * The known reply + */ + public void markReplyKnown(Reply reply); + } diff --git a/src/main/java/net/pterodactylus/sone/core/CoreListenerManager.java b/src/main/java/net/pterodactylus/sone/core/CoreListenerManager.java index f226723..74838a1 100644 --- a/src/main/java/net/pterodactylus/sone/core/CoreListenerManager.java +++ b/src/main/java/net/pterodactylus/sone/core/CoreListenerManager.java @@ -95,4 +95,28 @@ public class CoreListenerManager extends AbstractListenerManager