Beispiel #1
0
 protected void onLoadFinished(GraphObjectPagingLoader graphobjectpagingloader, SimpleGraphObjectCursor simplegraphobjectcursor)
 {
     super.ble(graphobjectpagingloader, simplegraphobjectcursor);
     if (simplegraphobjectcursor != null && !graphobjectpagingloader.isLoading())
     {
         if (simplegraphobjectcursor.areMoreObjectsAvailable())
         {
             followNextLink();
             return;
         }
         hideActivityCircle();
         if (simplegraphobjectcursor.isFromCache() && FriendPickerFragment.access$100(FriendPickerFragment.this))
         {
             long l;
             if (simplegraphobjectcursor.getCount() == 0)
             {
                 l = 2000L;
             } else
             {
                 l = 0L;
             }
             graphobjectpagingloader.refreshOriginalRequest(l);
             return;
         }
     }
 }
  @Override
  public void deliverResult(SimpleGraphObjectCursor<T> cursor) {
    SimpleGraphObjectCursor<T> oldCursor = this.cursor;
    this.cursor = cursor;

    if (isStarted()) {
      super.deliverResult(cursor);

      if (oldCursor != null && oldCursor != cursor && !oldCursor.isClosed()) {
        oldCursor.close();
      }
    }
  }
    @Override
    protected void onLoadFinished(
        GraphObjectPagingLoader<GraphPlace> loader, SimpleGraphObjectCursor<GraphPlace> data) {
      super.onLoadFinished(loader, data);

      // We could be called in this state if we are clearing data or if we are being re-attached
      // in the middle of a query.
      if (data == null || loader.isLoading()) {
        return;
      }

      hideActivityCircle();

      if (data.isFromCache()) {
        // Only the first page can be cached, since all subsequent pages will be round-tripped.
        // Force
        // a refresh of the first page before we allow paging to begin. If the first page produced
        // no data, launch the refresh immediately, otherwise schedule it for later.
        loader.refreshOriginalRequest(
            data.areMoreObjectsAvailable() ? CACHED_RESULT_REFRESH_DELAY : 0);
      }
    }
  private void addResults(Response response) {
    SimpleGraphObjectCursor<T> cursorToModify =
        (cursor == null || !appendResults)
            ? new SimpleGraphObjectCursor<T>()
            : new SimpleGraphObjectCursor<T>(cursor);

    PagedResults result = response.getGraphObjectAs(PagedResults.class);
    boolean fromCache = response.getIsFromCache();

    GraphObjectList<T> data = result.getData().castToListOf(graphObjectClass);
    boolean haveData = data.size() > 0;

    if (haveData) {
      nextRequest = response.getRequestForPagedResults(Response.PagingDirection.NEXT);

      cursorToModify.addGraphObjects(data, fromCache);
      if (nextRequest != null) {
        cursorToModify.setMoreObjectsAvailable(true);
      } else {
        cursorToModify.setMoreObjectsAvailable(false);
      }
    }

    if (!haveData) {
      cursorToModify.setMoreObjectsAvailable(false);
      cursorToModify.setFromCache(fromCache);

      nextRequest = null;
    }

    // Once we get any set of results NOT from the cache, stop trying to get any future ones
    // from it.
    if (!fromCache) {
      skipRoundtripIfCached = false;
    }

    deliverResult(cursorToModify);
  }