com.googlecode.flickrjandroid.photos.SearchParameters Java Examples
The following examples show how to use
com.googlecode.flickrjandroid.photos.SearchParameters.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FlickrApi.java From GestureViews with Apache License 2.0 | 5 votes |
@Background(singleThread = true) @Subscribe(LOAD_IMAGES_EVENT) private static synchronized EventResult loadImages(int count) throws Exception { SearchParameters params = new SearchParameters(); params.setText(SEARCH_QUERY); params.setSafeSearch(Flickr.SAFETYLEVEL_SAFE); params.setSort(SearchParameters.RELEVANCE); params.setLicense(LICENCE_ID); params.setExtras(photoParams); boolean hasNext = hasNext(); final PhotosInterface flickrPhotos = new Flickr(API_KEY).getPhotosInterface(); while (photos.size() < count && hasNext) { final PhotoList loaded = flickrPhotos.search(params, PER_PAGE, pages.size() + 1); pages.add(loaded); photos.addAll(loaded); hasNext = hasNext(); } int resultSize; if (photos.size() >= count) { resultSize = count; } else { resultSize = photos.size(); } List<Photo> result = new ArrayList<>(photos.subList(0, resultSize)); if (!hasNext) { hasNext = photos.size() > count; } return EventResult.create().result(result, hasNext).build(); }
Example #2
Source File: PhotoFragment.java From android-opensource-library-56 with Apache License 2.0 | 5 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mTask = new AsyncTask<Void, Void, PhotoList>() { protected PhotoList doInBackground(Void... params) { Log.d(TAG, "doInBackground"); final Flickr f = new Flickr(API_KEY, API_SECRET); SearchParameters param = new SearchParameters(); param.setText("coffee"); try { return f.getPhotosInterface().search(param, 20, 1); } catch (Exception e) { e.printStackTrace(); } return null; }; protected void onPostExecute(PhotoList photolist) { if (photolist == null) { setEmptyText("load failed."); } else { ImageAdapter adapter = new ImageAdapter(getActivity(), photolist); setListAdapter(adapter); } }; }.execute(); }
Example #3
Source File: FlickrApi.java From flickr-uploader with GNU General Public License v2.0 | 5 votes |
public static boolean isStillOnFlickr(Media media) { if (isAuthentified()) { String md5tag = media.getMd5Tag(); SearchParameters params = new SearchParameters(); params.setUserId(Utils.getStringProperty(STR.userId)); params.setMachineTags(new String[] { md5tag }); PhotoList photoList = null; int retry = 0; while (photoList == null && retry < 3) { try { photoList = FlickrApi.get().getPhotosInterface().search(params, 1, 1); if (photoList != null && !photoList.isEmpty()) { Photo photo = photoList.get(0); LOG.warn(media + " is uploaded : " + photo.getId() + " = " + md5tag); return true; } } catch (Throwable e) { LOG.error(ToolString.stack2string(e)); try { Thread.sleep((long) (Math.pow(4, retry) * 1000L)); } catch (InterruptedException e1) { } } finally { retry++; } } } return false; }