Android Open Source - tpblogr Parcelable Flickr Photo






From Project

Back to project page tpblogr.

License

The source code is released under:

MIT License

If you think the Android project tpblogr listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package blogr.vpm.fr.blogr.apis.flickr;
/*from w w w.j  a v  a 2s.c om*/
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;

import com.googlecode.flickrjandroid.FlickrException;
import com.googlecode.flickrjandroid.photos.Photo;

import blogr.vpm.fr.blogr.picture.PictureLoadedListener;

/**
 * Created by vince on 22/10/14.
 * <p/>
 * The bean to store a picture from Flickr.
 */
public class ParcelableFlickrPhoto implements Parcelable, PictureLoadedListener {

  private static final String PAR_ID = "parceled_id";
  private static final String PAR_URL = "parceled_url";
  private static final String PAR_TITLE = "parceled_title";
  private static final String PAR_DESC = "parceled_desc";
  private static final String PAR_URL_T = "parceled_url_thumbnail";
  private static final String PAR_URL_S = "parceled_url_small";
  private static final String PAR_URL_M = "parceled_url_medium";
  private static final String PAR_URL_L = "parceled_url_large";
  private static final String PAR_URL_O = "parceled_url_original";
  private static final String PAR_URL_SQ = "parceled_url_square";
  private static final String PAR_URL_LSQ = "parceled_url_largesquare";

  private final String id;

  private final String picUrl;

  private final String title;

  private final String description;

  private final String thumbnailSizeUrl;

  private final String smallSizeUrl;

  private final String mediumSizeUrl;

  private final String largeSizeUrl;

  private String originalSizeUrl;

  private final String largeSquareSizeUrl;

  private final String squareSizeUrl;

  private Bitmap smallBitmap;

  public ParcelableFlickrPhoto(Photo photo) {
    this.id = photo.getId();
    this.picUrl = photo.getUrl();
    this.title = photo.getTitle();
    this.description = photo.getDescription();
    this.thumbnailSizeUrl = photo.getThumbnailUrl();
    this.smallSizeUrl = photo.getSmallUrl();
    this.mediumSizeUrl = photo.getMediumUrl();
    this.largeSizeUrl = photo.getLargeUrl();
    try {
      this.originalSizeUrl = photo.getOriginalUrl();
    } catch (FlickrException e) {
      this.originalSizeUrl = "";
      Log.e("flickr", "could not retrieve original sized picture.");
    }
    this.squareSizeUrl = photo.getSmallSquareUrl();
    this.largeSquareSizeUrl = photo.getLargeSquareUrl();
  }

  private ParcelableFlickrPhoto(Parcel p) {
    this.id = p.readBundle().getString(PAR_ID);
    this.picUrl = p.readBundle().getString(PAR_URL);
    this.title = p.readBundle().getString(PAR_TITLE);
    this.description = p.readBundle().getString(PAR_DESC);
    this.thumbnailSizeUrl = p.readBundle().getString(PAR_URL_T);
    this.smallSizeUrl = p.readBundle().getString(PAR_URL_S);
    this.mediumSizeUrl = p.readBundle().getString(PAR_URL_M);
    this.largeSizeUrl = p.readBundle().getString(PAR_URL_L);
    this.originalSizeUrl = p.readBundle().getString(PAR_URL_O);
    this.squareSizeUrl = p.readBundle().getString(PAR_URL_SQ);
    this.largeSquareSizeUrl = p.readBundle().getString(PAR_URL_LSQ);
  }

  public String getId() {
    return id;
  }

  public String getPicUrl() {
    return picUrl;
  }

  public String getTitle() {
    return title;
  }

  public String getDescription() {
    return description;
  }

  public String getThumbnailSizeUrl() {
    return thumbnailSizeUrl;
  }

  public String getSmallSizeUrl() {
    return smallSizeUrl;
  }

  public String getMediumSizeUrl() {
    return mediumSizeUrl;
  }

  public String getLargeSizeUrl() {
    return largeSizeUrl;
  }

  public String getOriginalSizeUrl() {
    return originalSizeUrl;
  }

  public String getLargeSquareSizeUrl() {
    return largeSquareSizeUrl;
  }

  public String getSquareSizeUrl() {
    return squareSizeUrl;
  }

  public Bitmap getSmallBitmap() {
    return smallBitmap;
  }

  @Override
  public String toString() {
    return getTitle();
  }

  @Override
  public int describeContents() {
    return 0;
  }

  @Override
  public void writeToParcel(Parcel parcel, int i) {
    Bundle b = new Bundle();
    b.putString(PAR_ID, id);
    b.putString(PAR_URL, picUrl);
    b.putString(PAR_TITLE, title);
    b.putString(PAR_DESC, description);
    b.putString(PAR_URL_T, thumbnailSizeUrl);
    b.putString(PAR_URL_S, smallSizeUrl);
    b.putString(PAR_URL_M, mediumSizeUrl);
    b.putString(PAR_URL_L, largeSizeUrl);
    b.putString(PAR_URL_O, originalSizeUrl);
    b.putString(PAR_URL_SQ, squareSizeUrl);
    b.putString(PAR_URL_LSQ, largeSquareSizeUrl);
    parcel.writeBundle(b);
  }

  @Override
  public void onPictureLoaded(Bitmap pictureBitmap) {
    this.smallBitmap = pictureBitmap;
  }

  public static final Creator CREATOR = new Creator<ParcelableFlickrPhoto>() {

    @Override
    public ParcelableFlickrPhoto createFromParcel(Parcel parcel) {
      return new ParcelableFlickrPhoto(parcel);
    }

    @Override
    public ParcelableFlickrPhoto[] newArray(int size) {
      return new ParcelableFlickrPhoto[size];
    }
  };
}




Java Source Code List

blogr.vpm.fr.blogr.activity.AllPreferencesActivity.java
blogr.vpm.fr.blogr.activity.BlogActivity.java
blogr.vpm.fr.blogr.activity.BlogListDialogFragment.java
blogr.vpm.fr.blogr.activity.DialogDismissedListener.java
blogr.vpm.fr.blogr.activity.EmailBlogEditionFragment.java
blogr.vpm.fr.blogr.activity.FlickrDialogFragment.java
blogr.vpm.fr.blogr.activity.GithubBlogEditionFragment.java
blogr.vpm.fr.blogr.activity.InvalidatedModelListener.java
blogr.vpm.fr.blogr.activity.PostEditionActivity.java
blogr.vpm.fr.blogr.activity.PostEditionFragment.java
blogr.vpm.fr.blogr.activity.PostListActivity.java
blogr.vpm.fr.blogr.activity.PostListChoiceModeListener.java
blogr.vpm.fr.blogr.activity.PostListFragment.java
blogr.vpm.fr.blogr.activity.PostSelectionListener.java
blogr.vpm.fr.blogr.activity.PreferenceCategoryFragment.java
blogr.vpm.fr.blogr.apis.flickr.FlickrJAndroidProvider.java
blogr.vpm.fr.blogr.apis.flickr.FlickrJAsyncTaskProvider.java
blogr.vpm.fr.blogr.apis.flickr.FlickrProvider.java
blogr.vpm.fr.blogr.apis.flickr.ParcelableFlickrPhoto.java
blogr.vpm.fr.blogr.bean.Blog.java
blogr.vpm.fr.blogr.bean.EmailBlog.java
blogr.vpm.fr.blogr.bean.GithubBlog.java
blogr.vpm.fr.blogr.bean.Post.java
blogr.vpm.fr.blogr.bean.TPBlog.java
blogr.vpm.fr.blogr.format.AlignCenterTagsProvider.java
blogr.vpm.fr.blogr.format.AlignLeftTagsProvider.java
blogr.vpm.fr.blogr.format.AlignRightTagsProvider.java
blogr.vpm.fr.blogr.insertion.DefaultInserter.java
blogr.vpm.fr.blogr.insertion.Inserter.java
blogr.vpm.fr.blogr.insertion.SingleTagProvider.java
blogr.vpm.fr.blogr.insertion.SurroundingTagsProvider.java
blogr.vpm.fr.blogr.location.AndroidLocationProvider.java
blogr.vpm.fr.blogr.location.LatLongTagProvider.java
blogr.vpm.fr.blogr.location.LocationProvider.java
blogr.vpm.fr.blogr.persistence.BlogRetriever.java
blogr.vpm.fr.blogr.persistence.BlogSaver.java
blogr.vpm.fr.blogr.persistence.FileBlogManager.java
blogr.vpm.fr.blogr.persistence.FilePostRetriever.java
blogr.vpm.fr.blogr.persistence.FilePostSaver.java
blogr.vpm.fr.blogr.persistence.PostRetriever.java
blogr.vpm.fr.blogr.persistence.PostSaver.java
blogr.vpm.fr.blogr.picture.AsyncPictureLoader.java
blogr.vpm.fr.blogr.picture.ImageViewLoader.java
blogr.vpm.fr.blogr.picture.PictureLoadedListener.java
blogr.vpm.fr.blogr.picture.PictureMdTagsProvider.java
blogr.vpm.fr.blogr.picture.PicturePickedListener.java
blogr.vpm.fr.blogr.picture.PictureTagProvider.java
blogr.vpm.fr.blogr.picture.PictureTpTagsProvider.java
blogr.vpm.fr.blogr.publish.Formatter.java
blogr.vpm.fr.blogr.publish.HtmlFormatter.java
blogr.vpm.fr.blogr.publish.IdentityFormatter.java
blogr.vpm.fr.blogr.publish.PostPublisher.java
blogr.vpm.fr.blogr.publish.StdEmailPostPublisher.java
blogr.vpm.fr.blogr.publish.TPJavaMailPostPublisher.java
blogr.vpm.fr.blogr.publish.TPPostPublisher.java
blogr.vpm.fr.blogr.service.PostPublishingPreferencesProvider.java
blogr.vpm.fr.blogr.service.PostPublishingServiceProvider.java