示例#1
0
 @Override
 public synchronized void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
   if (cursor != null) {
     cursorSeenYet = true;
     if (cursor.getCount() < 1) {
       triggerRefresh(1, 0);
     } else {
       if (!firstStorySeenYet) {
         // once we have at least a single story, we can instruct the sync service as to how to
         // safely
         // activate new stories we recieve
         firstStorySeenYet = true;
         cursor.moveToFirst();
         long cutoff = cursor.getLong(cursor.getColumnIndex(DatabaseConstants.STORY_TIMESTAMP));
         cursor.moveToPosition(-1);
         if (activity.getStoryOrder() == StoryOrder.NEWEST) {
           NBSyncService.setActivationMode(NBSyncService.ActivationMode.OLDER, cutoff);
         } else {
           NBSyncService.setActivationMode(NBSyncService.ActivationMode.NEWER, cutoff);
         }
       }
     }
     adapter.swapCursor(cursor);
   }
   updateLoadingMessage();
 }