com.googlecode.flickrjandroid.photos.Photo Java Examples
The following examples show how to use
com.googlecode.flickrjandroid.photos.Photo.
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: PhotoViewerFragment.java From glimmr with Apache License 2.0 | 6 votes |
public static PhotoViewerFragment newInstance(Photo photo, boolean fetchExtraInfo, int num) { if (BuildConfig.DEBUG) Log.d(TAG, "newInstance"); PhotoViewerFragment photoFragment = new PhotoViewerFragment(); photoFragment.mBasePhoto = photo; if (!fetchExtraInfo) { photoFragment.mPhotoExtendedInfo = photo; } Bundle args = new Bundle(); args.putInt("num", num); photoFragment.setArguments(args); return photoFragment; }
Example #2
Source File: MainActivity.java From glimmr with Apache License 2.0 | 6 votes |
private void startViewerForActivityItem(int itemPos) { setProgressBarIndeterminateVisibility(Boolean.TRUE); List<Item> items = ActivityNotificationHandler .loadItemList(MainActivity.this); Item item = items.get(itemPos); new LoadPhotoInfoTask(new IPhotoInfoReadyListener() { @Override public void onPhotoInfoReady(final Photo photo, Exception e) { setProgressBarIndeterminateVisibility(Boolean.FALSE); if (FlickrHelper.getInstance().handleFlickrUnavailable(MainActivity.this, e)) { return; } if (photo == null) { Log.e(TAG, "onPhotoInfoReady: photo is null, " + "can't start viewer"); return; } List<Photo> photos = new ArrayList<Photo>(); photos.add(photo); setProgressBarIndeterminateVisibility(Boolean.FALSE); PhotoViewerActivity.startPhotoViewer( MainActivity.this, photos, 0); } }, item.getId(), item.getSecret()).execute(mOAuth); }
Example #3
Source File: PhotoViewerActivity.java From glimmr with Apache License 2.0 | 6 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { Photo currentlyShowing = mPhotos.get(mCurrentAdapterIndex); switch (item.getItemId()) { case R.id.menu_view_comments: onCommentsButtonClick(currentlyShowing); return true; case R.id.menu_view_info: onPhotoInfoButtonClick(currentlyShowing); return true; case R.id.menu_slideshow: startSlideshow(); return true; default: return super.onOptionsItemSelected(item); } }
Example #4
Source File: LoadContactsPhotosTask.java From glimmr with Apache License 2.0 | 6 votes |
@Override protected List<Photo> doInBackground(OAuth... params) { OAuth oauth = params[0]; if (oauth != null) { OAuthToken token = oauth.getToken(); Flickr f = FlickrHelper.getInstance().getFlickrAuthed( token.getOauthToken(), token.getOauthTokenSecret()); try { return f.getPhotosInterface().getContactsPhotos( Constants.FETCH_PER_PAGE, Constants.EXTRAS, false, false, false, mPage, Constants.FETCH_PER_PAGE); } catch (Exception e) { e.printStackTrace(); mException = e; } } else { Log.e(TAG, "LoadContactsPhotosTask requires authentication"); } return null; }
Example #5
Source File: PhotosetGridFragment.java From glimmr with Apache License 2.0 | 6 votes |
@Override public void onPhotosReady(List<Photo> photos, Exception e) { super.onPhotosReady(photos, e); mActivity.setProgressBarIndeterminateVisibility(Boolean.FALSE); if (mPhotoset != null) { User owner = mPhotoset.getOwner(); if (owner != null) { for (Photo p : photos) { p.setOwner(owner); p.setUrl(String.format("%s%s%s%s", "http://flickr.com/photos/", owner.getId(), "/", p.getId())); } } if (photos != null && photos.isEmpty()) { mMorePages = false; } } }
Example #6
Source File: FlickrApi.java From flickr-uploader with GNU General Public License v2.0 | 6 votes |
public static void syncMedia(final String flickrPhotoId) { executorService.execute(new Runnable() { @Override public void run() { try { List<Media> medias = Utils.loadMedia(false); for (Media media : medias) { if (flickrPhotoId.equals(media.getFlickrId())) { Photo photo = FlickrApi.get().getPhotosInterface().getPhoto(flickrPhotoId); PRIVACY privacy = getPrivacy(photo); media.setPrivacy(privacy); media.save(); LOG.debug("updated : " + media + ", privacy = " + privacy); FlickrUploaderActivity.updateStatic(media); break; } } } catch (Throwable e) { LOG.error(ToolString.stack2string(e)); } } }); }
Example #7
Source File: PhotoGridFragment.java From glimmr with Apache License 2.0 | 6 votes |
@Override public void onPhotosReady(List<Photo> photos, Exception e) { mActivity.setProgressBarIndeterminateVisibility(Boolean.FALSE); mSwipeLayout.setRefreshing(false); if (FlickrHelper.getInstance().handleFlickrUnavailable(mActivity, e)) { return; } if (photos == null) { mNoConnectionLayout.setVisibility(View.VISIBLE); mGridView.setVisibility(View.GONE); return; } if (photos.isEmpty()) { mMorePages = false; } mNoConnectionLayout.setVisibility(View.GONE); mGridView.setVisibility(View.VISIBLE); checkForNewPhotos(photos); mPhotos.addAll(photos); mAdapter.onDataReady(); }
Example #8
Source File: ContactsPhotosNotificationHandler.java From glimmr with Apache License 2.0 | 6 votes |
/** * Once photos are ready check for new ones and notify the user. * * There are two conditions that must be satisfied for a notification to be * shown: * 1) The id must be newer than ones previously shown in the main app. * 2) The id must not equal the one previously notified about, to avoid * duplicate notifications. */ @Override public void onPhotosReady(List<Photo> photos, Exception e) { if (BuildConfig.DEBUG) Log.d(TAG, "onPhotosReady"); if (photos != null) { List<Photo> newPhotos = checkForNewPhotos(photos); if (newPhotos != null && !newPhotos.isEmpty()) { String latestIdNotifiedAbout = getLatestIdNotifiedAbout(); Photo latestPhoto = newPhotos.get(0); if (!latestIdNotifiedAbout.equals(latestPhoto.getId())) { showNewPhotosNotification(newPhotos); storeLatestIdNotifiedAbout(latestPhoto); } } } else { Log.e(TAG, "onPhotosReady: null photolist received"); } }
Example #9
Source File: PhotoPagerAdapter.java From GestureViews with Apache License 2.0 | 6 votes |
@Override public void onBindViewHolder(@NonNull final ViewHolder holder, int position) { settingsController.apply(holder.image); holder.progress.animate().setStartDelay(PROGRESS_DELAY).alpha(1f); Photo photo = photos.get(position); // Loading image DemoGlideHelper.loadFlickrFull(photo, holder.image, new DemoGlideHelper.LoadingListener() { @Override public void onSuccess() { holder.progress.animate().cancel(); holder.progress.animate().alpha(0f); } @Override public void onError() { holder.progress.animate().alpha(0f); } }); }
Example #10
Source File: ContactsPhotosNotificationHandler.java From glimmr with Apache License 2.0 | 6 votes |
/** Notify that user's contacts have uploaded new photos */ public void showNewPhotosNotification(List<Photo> newPhotos) { final NotificationManager mgr = (NotificationManager) mContext.getSystemService( WakefulIntentService.NOTIFICATION_SERVICE); String tickerText = mContext.getString(R.string.notification_contacts_ticker); String titleText = String.format("%d %s", newPhotos.size(), mContext.getString(R.string.notification_contacts_title)); String contentText = mContext.getString(R.string.notification_contacts_content); Notification newContactsPhotos = getNotification(tickerText, titleText, contentText, newPhotos.size()); mgr.notify(Constants.NOTIFICATION_NEW_CONTACTS_PHOTOS, newContactsPhotos); }
Example #11
Source File: ContactsPhotosNotificationHandler.java From glimmr with Apache License 2.0 | 6 votes |
/** * Check if the most recent photo id we have stored is present in the * list of photos passed in. If so, new photos are the sublist from 0 * to the found id. */ private List<Photo> checkForNewPhotos(List<Photo> photos) { if (photos == null || photos.isEmpty()) { if (BuildConfig.DEBUG) { Log.d(TAG, "checkForNewPhotos: photos null or empty"); } return Collections.EMPTY_LIST; } List<Photo> newPhotos = new ArrayList<Photo>(); String newestId = getLatestViewedId(); for (int i=0; i < photos.size(); i++) { Photo p = photos.get(i); if (p.getId().equals(newestId)) { newPhotos = photos.subList(0, i); break; } } if (BuildConfig.DEBUG) { Log.d(TAG, String.format("Found %d new photos", newPhotos.size())); } return newPhotos; }
Example #12
Source File: ImageAdapter.java From android-opensource-library-56 with Apache License 2.0 | 6 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = mInflater.inflate(R.layout.image_item, null); } Photo photo = getItem(position); ImageView imageView = (ImageView) convertView.findViewById(R.id.image); imageView.setTag(photo.getMediumUrl()); imageView.setImageBitmap(null); ImageLoader.getInstance().cancelDisplayTask(imageView); ImageLoader.getInstance().displayImage(photo.getMediumUrl(), imageView, new SimpleImageLoadingListener() { @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { if (view.getTag().equals(imageUri)) { ((ImageView) view).setImageBitmap(loadedImage); } } }); return convertView; }
Example #13
Source File: DemoGlideHelper.java From GestureViews with Apache License 2.0 | 6 votes |
public static void loadFlickrFull(Photo photo, ImageView image, LoadingListener listener) { final String photoUrl = photo.getLargeSize() == null ? photo.getMediumUrl() : photo.getLargeUrl(); final RequestOptions options = new RequestOptions() .diskCacheStrategy(DiskCacheStrategy.DATA) .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) .dontTransform(); final RequestBuilder<Drawable> thumbRequest = Glide.with(image) .load(photo.getMediumUrl()) .apply(options); Glide.with(image) .load(photoUrl) .apply(new RequestOptions().apply(options).placeholder(image.getDrawable())) .thumbnail(thumbRequest) .listener(new RequestListenerWrapper<>(listener)) .into(image); }
Example #14
Source File: DemoGlideHelper.java From GestureViews with Apache License 2.0 | 6 votes |
public static void loadFlickrThumb(Photo photo, ImageView image) { final RequestOptions options = new RequestOptions() .diskCacheStrategy(DiskCacheStrategy.DATA) .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) .dontTransform(); final RequestBuilder<Drawable> thumbRequest = Glide.with(image) .load(photo.getThumbnailUrl()) .apply(options) .transition(DrawableTransitionOptions.with(TRANSITION_FACTORY)); Glide.with(image).load(photo.getMediumUrl()) .apply(options) .thumbnail(thumbRequest) .into(image); }
Example #15
Source File: LoadPublicPhotosTask.java From glimmr with Apache License 2.0 | 6 votes |
@Override protected List<Photo> doInBackground(Void... arg0) { if (BuildConfig.DEBUG) Log.d(TAG, "Fetching page " + mPage); /* A specific date to return interesting photos for. */ Date day = null; try { //noinspection ConstantConditions return FlickrHelper.getInstance().getInterestingInterface() .getList(day, Constants.EXTRAS, Constants.FETCH_PER_PAGE, mPage); } catch (Exception e) { e.printStackTrace(); mException = e; } return null; }
Example #16
Source File: StackWidgetService.java From glimmr with Apache License 2.0 | 5 votes |
private List<Photo> getFavoritePhotos() throws Exception { OAuthToken token = mOAuth.getToken(); Flickr f = FlickrHelper.getInstance().getFlickrAuthed( token.getOauthToken(), token.getOauthTokenSecret()); Date minFavDate = null; Date maxFavDate = null; return f.getFavoritesInterface().getList(mUser.getId(), minFavDate, maxFavDate, Constants.FETCH_PER_PAGE, PAGE, Constants.EXTRAS); }
Example #17
Source File: LoadContactsPhotosTask.java From glimmr with Apache License 2.0 | 5 votes |
@Override protected void onPostExecute(final List<Photo> result) { if (result == null) { if (BuildConfig.DEBUG) Log.e(TAG, "Error fetching contacts photos, result is null"); } mListener.onPhotosReady(result, mException); }
Example #18
Source File: PhotoViewerActivity.java From glimmr with Apache License 2.0 | 5 votes |
@Override public void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); if (mPhotos.isEmpty()) { String json = new GsonHelper(this).loadJson(PHOTO_LIST_FILE); if (json.length() == 0) { Log.e(TAG, String.format("Error reading '%s'", PHOTO_LIST_FILE)); } else { Type collectionType = new TypeToken<Collection<Photo>>(){}.getType(); mPhotos = new Gson().fromJson(json, collectionType); } } boolean overlayOn = savedInstanceState.getBoolean(KEY_ACTIONBAR_SHOW, true); if (overlayOn) { mActionBar.show(); } else { mActionBar.hide(); } int pagerIndex = savedInstanceState.getInt(KEY_CURRENT_INDEX, 0); initViewPager(pagerIndex, false); if (savedInstanceState.getBoolean(KEY_SLIDESHOW_RUNNING, false)) { startSlideshow(); } }
Example #19
Source File: LoadPhotostreamTask.java From glimmr with Apache License 2.0 | 5 votes |
@Override protected void onPostExecute(final List<Photo> result) { if (result == null) { if (BuildConfig.DEBUG) Log.e(TAG, "Error fetching photolist, result is null"); } mListener.onPhotosReady(result, mException); }
Example #20
Source File: LoadFavoritesTask.java From glimmr with Apache License 2.0 | 5 votes |
@Override protected void onPostExecute(final List<Photo> result) { if (result == null) { if (BuildConfig.DEBUG) Log.e(TAG, "Error fetching photolist, result is null"); } mListener.onPhotosReady(result, mException); }
Example #21
Source File: SearchPhotosTask.java From glimmr with Apache License 2.0 | 5 votes |
@Override protected void onPostExecute(List<Photo> result) { if (result == null) { Log.e(TAG, "Error fetching photolist, result is null"); result = Collections.EMPTY_LIST; } mListener.onPhotosReady(result, mException); }
Example #22
Source File: LoadPhotosetPhotosTask.java From glimmr with Apache License 2.0 | 5 votes |
@Override protected void onPostExecute(List<Photo> result) { if (result == null) { if (BuildConfig.DEBUG) { Log.e(TAG, "Error fetching photolist, result is null"); } result = Collections.EMPTY_LIST; } mListener.onPhotosReady(result, mException); }
Example #23
Source File: LoadPublicPhotosTask.java From glimmr with Apache License 2.0 | 5 votes |
@Override protected void onPostExecute(final List<Photo> result) { if (result == null) { if (BuildConfig.DEBUG) { Log.e(TAG, "Error fetching photolist, result is null"); } } mListener.onPhotosReady(result, mException); }
Example #24
Source File: PhotoViewerActivity.java From glimmr with Apache License 2.0 | 5 votes |
/** * Start PhotoViewerActivity to view a list of photos, starting at a specific index. */ public static void startPhotoViewer(Context context, List<Photo> photos, int index) { if (new GsonHelper(context).marshallObject(photos, PHOTO_LIST_FILE)) { Intent photoViewer = new Intent(context, PhotoViewerActivity.class); photoViewer.setAction(ACTION_VIEW_PHOTOLIST); photoViewer.putExtra(KEY_START_INDEX, index); photoViewer.putExtra(KEY_PHOTO_LIST_FILE, PHOTO_LIST_FILE); context.startActivity(photoViewer); } else { Log.e(TAG, "Error marshalling photo list, cannot start viewer"); } }
Example #25
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; }
Example #26
Source File: CommentsFragment.java From glimmr with Apache License 2.0 | 5 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (savedInstanceState != null && mPhoto == null) { String json = savedInstanceState.getString(KEY_PHOTO); if (json != null) { mPhoto = new Gson().fromJson(json, Photo.class); } else { Log.e(TAG, "No stored photo found in savedInstanceState"); } } }
Example #27
Source File: PhotoViewerActivity.java From glimmr with Apache License 2.0 | 5 votes |
@Override public void onPhotoInfoReady(Photo photo, Exception e) { if (BuildConfig.DEBUG) Log.d(TAG, "onPhotoInfoReady"); if (FlickrHelper.getInstance().handleFlickrUnavailable(this, e)) { return; } if (photo != null) { mPhotos.add(photo); initViewPager(0, false); } else { Log.e(TAG, "null result received"); // TODO: alert user of error } }
Example #28
Source File: PhotoViewerFragment.java From glimmr with Apache License 2.0 | 5 votes |
/** * Return the largest size available for a given photo. * <p/> * All should have medium, but not all have large. */ private String getLargestUrlAvailable(Photo photo) { Size size = photo.getLargeSize(); if (size != null) { return photo.getLargeUrl(); } else { /* No large size available, fall back to medium */ return photo.getMediumUrl(); } }
Example #29
Source File: PhotosetsInterface.java From flickr-uploader with GNU General Public License v2.0 | 5 votes |
/** * Get the information for a specified photoset. * * This method does not require authentication. * * @param photosetId * The photoset ID * @return The Photoset * @throws FlickrException * @throws IOException * @throws JSONException */ public Photoset getInfo(String photosetId) throws FlickrException, IOException, JSONException { List<Parameter> parameters = new ArrayList<Parameter>(); parameters.add(new Parameter("method", METHOD_GET_INFO)); parameters.add(new Parameter("api_key", apiKey)); parameters.add(new Parameter("photoset_id", photosetId)); Response response = transportAPI.get(transportAPI.getPath(), parameters); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } JSONObject photosetElement = response.getData().getJSONObject("photoset"); Photoset photoset = new Photoset(); photoset.setId(photosetElement.getString("id")); User owner = new User(); owner.setId(photosetElement.getString("owner")); photoset.setOwner(owner); Photo primaryPhoto = new Photo(); primaryPhoto.setId(photosetElement.getString("primary")); primaryPhoto.setSecret(photosetElement.getString("secret")); // TODO verify that this is the secret for the photo primaryPhoto.setServer(photosetElement.getString("server")); // TODO verify that this is the server for the photo primaryPhoto.setFarm(photosetElement.getString("farm")); photoset.setPrimaryPhoto(primaryPhoto); // TODO remove secret/server/farm from photoset? // It's rather related to the primaryPhoto, then to the photoset itself. photoset.setSecret(photosetElement.getString("secret")); photoset.setServer(photosetElement.getString("server")); photoset.setFarm(photosetElement.getString("farm")); photoset.setPhotoCount(photosetElement.getString("photos")); photoset.setTitle(JSONUtils.getChildValue(photosetElement, "title")); photoset.setDescription(JSONUtils.getChildValue(photosetElement, "description")); photoset.setPrimaryPhoto(primaryPhoto); return photoset; }
Example #30
Source File: PhotoViewerFragment.java From glimmr with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { mNum = savedInstanceState.getInt("mNum", 0); mBasePhoto = (Photo) savedInstanceState.getSerializable(mNum + "_basePhoto"); } initUIVisibilityChangeListener(); }