New post/quote count visible even when it's not being watched

captchafix
Florens Douwes 11 years ago
parent 07c1dae22f
commit d856721b8d
  1. 16
      Chan/src/org/floens/chan/core/model/Pin.java
  2. 20
      Chan/src/org/floens/chan/core/watch/PinWatcher.java
  3. 8
      Chan/src/org/floens/chan/core/watch/WatchNotifier.java
  4. 2
      Chan/src/org/floens/chan/ui/adapter/PinnedAdapter.java

@ -42,6 +42,22 @@ public class Pin {
return pinWatcher; return pinWatcher;
} }
public int getNewPostsCount() {
if (watchLastCount <= 0) {
return 0;
} else {
return Math.max(0, watchNewCount - watchLastCount);
}
}
public int getNewQuoteCount() {
if (quoteLastCount <= 0) {
return 0;
} else {
return Math.max(0, quoteNewCount - quoteLastCount);
}
}
public void updateWatch() { public void updateWatch() {
if (pinWatcher == null) { if (pinWatcher == null) {
pinWatcher = new PinWatcher(this); pinWatcher = new PinWatcher(this);

@ -50,15 +50,7 @@ public class PinWatcher implements Loader.LoaderListener {
if (posts.size() == 0) { if (posts.size() == 0) {
return posts; return posts;
} else { } else {
return posts.subList(Math.max(0, posts.size() - getNewPostsCount()), posts.size()); return posts.subList(Math.max(0, posts.size() - pin.getNewPostsCount()), posts.size());
}
}
public int getNewPostsCount() {
if (pin.watchLastCount <= 0) {
return 0;
} else {
return Math.max(0, pin.watchNewCount - pin.watchLastCount);
} }
} }
@ -66,15 +58,7 @@ public class PinWatcher implements Loader.LoaderListener {
if (posts.size() == 0) { if (posts.size() == 0) {
return posts; return posts;
} else { } else {
return posts.subList(Math.max(0, posts.size() - getNewQuoteCount()), posts.size()); return posts.subList(Math.max(0, posts.size() - pin.getNewQuoteCount()), posts.size());
}
}
public int getNewQuoteCount() {
if (pin.quoteLastCount <= 0) {
return 0;
} else {
return Math.max(0, pin.quoteNewCount - pin.quoteLastCount);
} }
} }

@ -80,8 +80,8 @@ public class WatchNotifier {
boolean add = false; boolean add = false;
if (watcher.getNewPostsCount() > 0) { if (pin.getNewPostsCount() > 0) {
newPostsCount += watcher.getNewPostsCount(); newPostsCount += pin.getNewPostsCount();
for (Post p : watcher.getNewPosts()) { for (Post p : watcher.getNewPosts()) {
p.title = pin.loadable.title; p.title = pin.loadable.title;
posts.add(p); posts.add(p);
@ -91,8 +91,8 @@ public class WatchNotifier {
add = true; add = true;
} }
if (watcher.getNewQuoteCount() > 0) { if (pin.getNewQuoteCount() > 0) {
newQuotesCount += watcher.getNewQuoteCount(); newQuotesCount += pin.getNewQuoteCount();
show = true; show = true;
add = true; add = true;
} }

@ -53,7 +53,7 @@ public class PinnedAdapter extends ArrayAdapter<Pin> {
if (item.isError()) { if (item.isError()) {
itemCount.setText("Err"); itemCount.setText("Err");
} else { } else {
int count = item.getPinWatcher() == null ? 0 : item.getPinWatcher().getNewPostsCount(); int count = item.getPinWatcher() == null ? 0 : item.getNewPostsCount();
String total = Integer.toString(count); String total = Integer.toString(count);
if (count > 999) { if (count > 999) {
total = "1k+"; total = "1k+";

Loading…
Cancel
Save