From c87e6ecfc3c16df42b5481781d5acc2732398415 Mon Sep 17 00:00:00 2001 From: Florens Douwes Date: Tue, 3 Jun 2014 13:43:12 +0200 Subject: [PATCH] Always have a PinWatcher on a Pin --- .../chan/core/manager/PinnedManager.java | 4 +--- .../java/org/floens/chan/core/model/Pin.java | 24 ++++++++----------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/Clover/app/src/main/java/org/floens/chan/core/manager/PinnedManager.java b/Clover/app/src/main/java/org/floens/chan/core/manager/PinnedManager.java index e5a5f7ef..a87a1b74 100644 --- a/Clover/app/src/main/java/org/floens/chan/core/manager/PinnedManager.java +++ b/Clover/app/src/main/java/org/floens/chan/core/manager/PinnedManager.java @@ -136,9 +136,7 @@ public class PinnedManager { } public void onPinViewed(Pin pin) { - if (pin.getPinWatcher() != null) { - pin.getPinWatcher().onViewed(); - } + pin.getPinWatcher().onViewed(); onPinsChanged(); } diff --git a/Clover/app/src/main/java/org/floens/chan/core/model/Pin.java b/Clover/app/src/main/java/org/floens/chan/core/model/Pin.java index 039a4dec..0927a9a6 100644 --- a/Clover/app/src/main/java/org/floens/chan/core/model/Pin.java +++ b/Clover/app/src/main/java/org/floens/chan/core/model/Pin.java @@ -62,10 +62,6 @@ public class Pin { public boolean isError = false; - public PinWatcher getPinWatcher() { - return pinWatcher; - } - public int getNewPostsCount() { if (watchLastCount < 0 || watchNewCount < 0) { return 0; @@ -79,19 +75,11 @@ public class Pin { } public Post getLastSeenPost() { - if (pinWatcher == null) { - return null; - } else { - return pinWatcher.getLastSeenPost(); - } + return getPinWatcher().getLastSeenPost(); } public void updateWatch() { - if (pinWatcher == null) { - pinWatcher = new PinWatcher(this); - } - - pinWatcher.update(); + getPinWatcher().update(); } public void destroyWatcher() { @@ -108,4 +96,12 @@ public class Pin { updateWatch(); } } + + public PinWatcher getPinWatcher() { + if (pinWatcher == null) { + pinWatcher = new PinWatcher(this); + } + + return pinWatcher; + } }