예제 #1
0
  public static List<PhotoItem> getAlbums(Context context) {
    String url = ApiConstants.getAlbumUrl();
    Boolean nextPage = true;
    List<PhotoItem> photoItemList = new ArrayList<>();

    while (nextPage) {
      PhotosResponse response = getAlbumByPage(context, url);
      photoItemList.addAll(response.getResult());

      url = ApiConstants.getNextPageAlbumUrl(response.getNextPagingHashCode());
      nextPage = response.getNextPaging();

      LogUtils.debugLog(LOG_TAG, "url = " + url + " nextPage = " + nextPage);
    }

    return photoItemList;
  }
예제 #2
0
  public static List<PhotoItem> getAlbumPhotos(Context context, String id) {
    String url = ApiConstants.getAlbumPhotoUrl(id);
    final ResultWrapper resultWrapper = new ResultWrapper();
    makeSyncGetJsonRequest(
        new PhotosResponse(),
        context,
        url,
        JSON_REQUEST_TIMEOUT,
        new ApiResponseListener<PhotosResponse>() {
          @Override
          public void onResponse(PhotosResponse response) {
            LogUtils.debugLog(LOG_TAG, "Results received");
            resultWrapper.setResult(response.getResult());
          }

          @Override
          public void onError(Exception exception) {
            LogUtils.errorLog(LOG_TAG, "Failed to fetch page. API returned: " + exception);
          }
        });
    return (List<PhotoItem>) resultWrapper.getResult();
  }