Fix new quotes not always making the new quotes count increase.

captchafix
Florens Douwes 11 years ago
parent 242c160c90
commit fa0855a7cc
  1. 10
      Clover/app/src/main/java/org/floens/chan/core/model/Pin.java
  2. 10
      Clover/app/src/main/java/org/floens/chan/core/net/ChanReaderRequest.java
  3. 27
      Clover/app/src/main/java/org/floens/chan/core/watch/PinWatcher.java
  4. 5
      Clover/app/src/main/java/org/floens/chan/service/WatchService.java

@ -54,7 +54,7 @@ public class Pin {
public int watchLastCount = -1;
@DatabaseField
public int watchNewCount = -1;
public int watchNewCount = 0;
@DatabaseField
public int quoteLastCount = 0;
@ -69,7 +69,7 @@ public class Pin {
}
public int getNewPostsCount() {
if (watchLastCount <= 0) {
if (watchLastCount < 0) {
return 0;
} else {
return Math.max(0, watchNewCount - watchLastCount);
@ -77,11 +77,7 @@ public class Pin {
}
public int getNewQuoteCount() {
if (quoteLastCount <= 0) {
return 0;
} else {
return Math.max(0, quoteNewCount - quoteLastCount);
}
return Math.max(0, quoteNewCount - quoteLastCount);
}
public Post getLastSeenPost() {

@ -40,16 +40,6 @@ public class ChanReaderRequest extends JsonReaderRequest<List<Post>> {
super(url, listener, errorListener);
}
/**
* Creates a ChanReaderRequest with supplied params
*
* @param mode ThreadManager mode
* @param board board key
* @param no page for board, no for threads
* @param listener
* @param errorListener
* @return New instance of ChanReaderRequest
*/
public static ChanReaderRequest newInstance(Loadable loadable, List<Post> cached, Listener<List<Post>> listener,
ErrorListener errorListener) {
String url;

@ -17,6 +17,8 @@
*/
package org.floens.chan.core.watch;
import android.util.Log;
import com.android.volley.VolleyError;
import org.floens.chan.core.loader.Loader;
@ -114,36 +116,29 @@ public class PinWatcher implements Loader.LoaderListener {
posts.addAll(result);
if (pin.watchLastCount < 0)
pin.watchLastCount = pin.watchNewCount;
pin.watchLastCount = result.size();
pin.watchNewCount = result.size();
// If there are more replies than last time, let the notification make a sound
int lastCounterForSoundNotification = pin.quoteNewCount;
// Get list of saved posts
List<Post> savedPosts = new ArrayList<Post>();
int total = 0;
for (Post saved : result) {
if (saved.isSavedReply) {
savedPosts.add(saved);
total += saved.repliesFrom.size();
}
}
// If there are more replies than last time, let the notification make a sound
int lastCounterForSoundNotification = pin.quoteNewCount;
// Find posts quoting these saved posts
pin.quoteNewCount = 0;
for (Post resultPost : result) {
// This post replies to me
for (Post savedPost : savedPosts) {
if (resultPost.repliesTo.contains(savedPost.no)) {
pin.quoteNewCount++;
}
}
}
pin.quoteNewCount = total;
if (pin.quoteNewCount > lastCounterForSoundNotification) {
wereNewQuotes = true;
}
Log.d(TAG, "QuoteLastCount: " + pin.quoteLastCount + ", quoteNewCount: " + pin.quoteNewCount + ", wereNewQuotes: " + wereNewQuotes);
WatchService.onPinWatcherResult();
}
}

@ -20,15 +20,14 @@ package org.floens.chan.service;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import org.floens.chan.ChanApplication;
import org.floens.chan.core.ChanPreferences;
import org.floens.chan.core.model.Pin;
import org.floens.chan.core.watch.WatchNotifier;
import org.floens.chan.utils.Logger;
import org.floens.chan.utils.Utils;
import java.util.List;
@ -104,7 +103,7 @@ public class WatchService extends Service {
}
public static void onPinWatcherResult() {
new Handler(Looper.getMainLooper()).post(new Runnable() {
Utils.runOnUiThread(new Runnable() {
@Override
public void run() {
ChanApplication.getPinnedManager().onPinsChanged();

Loading…
Cancel
Save