@Override protected Bitmap doInBackground(String... params) { // Authenticate via OAuth JumblrClient client = new JumblrClient( "LfbunCVV9nOklMzFaoSGgmYG7jU4Jzt1kMjchWDXxXjEabhNtT", "Aeftb6z3MpR9Nxj9wUFXMYyrcKTIMeCaJnFJ1gdvNH8oczDfMF"); client.setToken( "LsvYhkMInXLtIvU5JffQSMesYzEvbyxwl0nksaGdi9TZmRgLUy", "UILbtYeCzHyXQ6ATHh3vG4wcqV8p1hncGoLImSvX8jy8EpGDNf"); // First query (gets 20 photos with tag cockerspaniel) Map<String, Long> options = new HashMap<>(); options.put("limit", 20l); Long timeStamp = 0l; PhotoPost photoPost; for (Post post : client.tagged("cockerspaniel", options)) { if (post instanceof PhotoPost) { photoPost = (PhotoPost) post; for (Photo photo : photoPost.getPhotos()) { if (!(photo.getSizes().get(0).getUrl()).contains(".gif") && urls.size() < 20) { timeStamp = post.getTimestamp(); urls.add(photo.getSizes().get(0).getUrl()); // Adding the photos and their notecounts in hashmap note_counts.put(photo.getSizes().get(0).getUrl(), post.getNoteCount()); // Adding the photo's URLS and their timestamps in a hashmap timestamps.put(photo.getSizes().get(0).getUrl(), post.getTimestamp()); } else { break; } } } } // Second query (gets 20 photos with tag cockerspaniel) Map<String, Long> options2 = new HashMap<>(); options2.put("limit", 20l); options2.put("before", timeStamp); for (Post post : client.tagged("cockerspaniel", options2)) { if (post instanceof PhotoPost) { photoPost = (PhotoPost) post; for (Photo photo : photoPost.getPhotos()) { if (!(photo.getSizes().get(0).getUrl()).contains(".gif") && urls.size() < 40) { timeStamp = post.getTimestamp(); urls.add(photo.getSizes().get(0).getUrl()); // Adding the photos and their notecounts in hashmap note_counts.put(photo.getSizes().get(0).getUrl(), post.getNoteCount()); // Adding the photo's URLS and their timestamps in a hashmap timestamps.put(photo.getSizes().get(0).getUrl(), post.getTimestamp()); } else { break; } } } } // Third query (gets 10 photos with tag cockerspaniel) Map<String, Long> options3 = new HashMap<>(); options3.put("limit", 20l); options3.put("before", timeStamp); for (Post post : client.tagged("cockerspaniel", options3)) { if (post instanceof PhotoPost) { photoPost = (PhotoPost) post; for (Photo photo : photoPost.getPhotos()) { if (!(photo.getSizes().get(0).getUrl()).contains(".gif") && urls.size() < 50) { urls.add(photo.getSizes().get(0).getUrl()); // Adding the photos and their notecounts in hashmap note_counts.put(photo.getSizes().get(0).getUrl(), post.getNoteCount()); // Adding the photo's URLS and their timestamps in a hashmap timestamps.put(photo.getSizes().get(0).getUrl(), post.getTimestamp()); } else { break; } } } } // Map for sorting by Most Popular TreeMap<String, Long> desc = new TreeMap<>(note_counts.descendingMap()); mostPopular.addAll(desc.keySet()); // Map for sorting by Most Recent Map<String, Long> asc = sortByComparator(timestamps); mostRecent.addAll(asc.keySet()); return null; }