@Override protected List<Photoset> doInBackground(Void... arg0) { OAuth oAuth = authentication.getOAuth(); if (oAuth == null) return null; FlickrHelper.setOAuth(oAuth); List<Photoset> result = new ArrayList<Photoset>(); PhotosetsInterface intf = FlickrHelper.getFlickr().getPhotosetsInterface(); try { Collection<Photoset> photosets; int page = 1; final int perPage = 10; do { try { photosets = intf.getList(oAuth.getUser().getId(), perPage, page).getPhotosets(); } catch (FlickrException e) { if (e.getErrorCode().compareTo("1") == 0) // empty page break; throw e; } for (Photoset p : photosets) result.add(p); page += 1; } while (photosets.size() >= perPage); return result; } catch (IOException e) { Log.w(TAG, e); error = e; return null; } catch (FlickrException e) { Log.w(TAG, e); error = e; return null; } catch (JSONException e) { Log.w(TAG, e); error = e; return null; } }