Back to project page iwannawatch-android.
The source code is released under:
MIT License
If you think the Android project iwannawatch-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.meoyawn.iwannawatch.models; //from w w w. j ava 2 s .com import com.fasterxml.jackson.annotation.JsonProperty; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; import java.text.SimpleDateFormat; import java.util.Date; /** * Created by adel on 3/1/14 */ public class Movie { public static final int[] POSTER_SIZES = {92, 154, 185, 342, 500}; static final @NonNls SimpleDateFormat YEAR_DATE_FORMAT = new SimpleDateFormat("yyyy"); public @JsonProperty("id") Long _id; public String title; public @Nullable String poster_path; public @Nullable Date release_date; public @Nullable Date createdAt; public boolean watched; int getPosterSize(int width) { for (int posterSize : POSTER_SIZES) { if (width <= posterSize) { return posterSize; } } return POSTER_SIZES[POSTER_SIZES.length - 1]; } public String getPosterUrl(int width) { int posterSize = getPosterSize(width); String pathPrefix = posterSize < Integer.MAX_VALUE ? "w" + posterSize : "original"; return "http://image.tmdb.org/t/p/" + pathPrefix + poster_path; } public String getReleaseYear() { return release_date != null ? YEAR_DATE_FORMAT.format(release_date) : ""; } @Override public String toString() { return title; } }