From eda5bf00df085e69d2f2e8c1f9006f4ad929ea59 Mon Sep 17 00:00:00 2001 From: dosiecki Date: Tue, 23 Sep 2014 21:44:14 -0700 Subject: [PATCH] Ensure story lists that start empty load something. --- .../newsblur/fragment/ItemListFragment.java | 4 ++-- .../com/newsblur/service/NBSyncService.java | 18 ++++++++++-------- .../src/com/newsblur/util/AppConstants.java | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/clients/android/NewsBlur/src/com/newsblur/fragment/ItemListFragment.java b/clients/android/NewsBlur/src/com/newsblur/fragment/ItemListFragment.java index 117fe6847..70cee0bc6 100644 --- a/clients/android/NewsBlur/src/com/newsblur/fragment/ItemListFragment.java +++ b/clients/android/NewsBlur/src/com/newsblur/fragment/ItemListFragment.java @@ -99,8 +99,8 @@ public abstract class ItemListFragment extends NbFragment implements OnScrollLis @Override public synchronized void onScroll(AbsListView view, int firstVisible, int visibleCount, int totalCount) { // load an extra page or two worth of stories past the viewport - int desiredStoryCount = firstVisible + (visibleCount*2); - + int desiredStoryCount = firstVisible + (visibleCount*2) + 1; + // this method tends to get called repeatedly. don't request repeats if (desiredStoryCount <= lastRequestedStoryCount) { return; diff --git a/clients/android/NewsBlur/src/com/newsblur/service/NBSyncService.java b/clients/android/NewsBlur/src/com/newsblur/service/NBSyncService.java index 98d25e5b5..64265a637 100644 --- a/clients/android/NewsBlur/src/com/newsblur/service/NBSyncService.java +++ b/clients/android/NewsBlur/src/com/newsblur/service/NBSyncService.java @@ -622,16 +622,18 @@ public class NBSyncService extends Service { Log.e(NBSyncService.class.getName(), "rejecting request for feedset that is exhaused"); return false; } - Integer alreadyRequested = PendingFeeds.get(fs); - if ((alreadyRequested != null) && (desiredStoryCount <= alreadyRequested)) { - return false; - } - Integer alreadySeen = FeedStoriesSeen.get(fs); - if ((alreadySeen != null) && (desiredStoryCount <= alreadySeen)) { - return false; + + synchronized (PendingFeeds) { + Integer alreadyRequested = PendingFeeds.get(fs); + if ((alreadyRequested != null) && (desiredStoryCount <= alreadyRequested)) { + return false; + } + Integer alreadySeen = FeedStoriesSeen.get(fs); + if ((alreadySeen != null) && (desiredStoryCount <= alreadySeen)) { + return false; + } } - Log.d(NBSyncService.class.getName(), "enqueued request for minimum stories: " + desiredStoryCount); PendingFeeds.put(fs, desiredStoryCount); NbActivity.updateAllActivities(); return true; diff --git a/clients/android/NewsBlur/src/com/newsblur/util/AppConstants.java b/clients/android/NewsBlur/src/com/newsblur/util/AppConstants.java index e755a2f20..a40921913 100644 --- a/clients/android/NewsBlur/src/com/newsblur/util/AppConstants.java +++ b/clients/android/NewsBlur/src/com/newsblur/util/AppConstants.java @@ -5,7 +5,7 @@ public class AppConstants { // Enables high-volume logging that may be useful for debugging. This should // never be enabled for releases, as it not only slows down the app considerably, // it will log sensitive info such as passwords! - public static final boolean VERBOSE_LOG = true; + public static final boolean VERBOSE_LOG = false; public static final boolean VERBOSE_LOG_DB = false; public static final int STATE_ALL = 0;