Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 package org.xbmc.android.jsonrpc.api.model;
00022
00023 import android.os.Parcel;
00024 import android.os.Parcelable;
00025 import java.util.ArrayList;
00026 import java.util.List;
00027 import org.codehaus.jackson.JsonNode;
00028 import org.codehaus.jackson.node.ArrayNode;
00029 import org.codehaus.jackson.node.ObjectNode;
00030 import org.xbmc.android.jsonrpc.api.AbstractModel;
00031
00032 public final class MediaModel {
00033
00040 public static class Artwork extends AbstractModel {
00041 public final static String API_TYPE = "Media.Artwork";
00042
00043
00044 public static final String BANNER = "banner";
00045 public static final String FANART = "fanart";
00046 public static final String POSTER = "poster";
00047 public static final String THUMB = "thumb";
00048
00049
00050 public final String banner;
00051 public final String fanart;
00052 public final String poster;
00053 public final String thumb;
00054
00061 public Artwork(String banner, String fanart, String poster, String thumb) {
00062 this.banner = banner;
00063 this.fanart = fanart;
00064 this.poster = poster;
00065 this.thumb = thumb;
00066 }
00067
00072 public Artwork(JsonNode node) {
00073 banner = parseString(node, BANNER);
00074 fanart = parseString(node, FANART);
00075 poster = parseString(node, POSTER);
00076 thumb = parseString(node, THUMB);
00077 }
00078
00079 @Override
00080 public JsonNode toJsonNode() {
00081 final ObjectNode node = OM.createObjectNode();
00082 node.put(BANNER, banner);
00083 node.put(FANART, fanart);
00084 node.put(POSTER, poster);
00085 node.put(THUMB, thumb);
00086 return node;
00087 }
00088
00094 static List<Artwork> getMediaModelArtworkList(JsonNode node, String key) {
00095 if (node.has(key)) {
00096 final ArrayNode a = (ArrayNode)node.get(key);
00097 final List<Artwork> l = new ArrayList<Artwork>(a.size());
00098 for (int i = 0; i < a.size(); i++) {
00099 l.add(new Artwork((JsonNode)a.get(i)));
00100 }
00101 return l;
00102 }
00103 return new ArrayList<Artwork>(0);
00104 }
00105
00111 @Override
00112 public void writeToParcel(Parcel parcel, int flags) {
00113 parcel.writeValue(banner);
00114 parcel.writeValue(fanart);
00115 parcel.writeValue(poster);
00116 parcel.writeValue(thumb);
00117 }
00118
00122 protected Artwork(Parcel parcel) {
00123 banner = parcel.readString();
00124 fanart = parcel.readString();
00125 poster = parcel.readString();
00126 thumb = parcel.readString();
00127 }
00128
00132 public static final Parcelable.Creator<Artwork> CREATOR = new Parcelable.Creator<Artwork>() {
00133 @Override
00134 public Artwork createFromParcel(Parcel parcel) {
00135 return new Artwork(parcel);
00136 }
00137 @Override
00138 public Artwork[] newArray(int n) {
00139 return new Artwork[n];
00140 }
00141 };
00142
00143 @Override
00144 public int describeContents() {
00145 return 0;
00146 }
00147 }
00148
00155 public static class BaseDetail extends ItemModel.BaseDetail {
00156 public final static String API_TYPE = "Media.Details.Base";
00157
00158
00159 public static final String FANART = "fanart";
00160 public static final String THUMBNAIL = "thumbnail";
00161
00162
00163 public final String fanart;
00164 public final String thumbnail;
00165
00170 public BaseDetail(JsonNode node) {
00171 super(node);
00172 fanart = parseString(node, FANART);
00173 thumbnail = parseString(node, THUMBNAIL);
00174 }
00175
00176 @Override
00177 public JsonNode toJsonNode() {
00178 final ObjectNode node = (ObjectNode)super.toJsonNode();
00179 node.put(FANART, fanart);
00180 node.put(THUMBNAIL, thumbnail);
00181 return node;
00182 }
00183
00189 static List<BaseDetail> getMediaModelBaseDetailList(JsonNode node, String key) {
00190 if (node.has(key)) {
00191 final ArrayNode a = (ArrayNode)node.get(key);
00192 final List<BaseDetail> l = new ArrayList<BaseDetail>(a.size());
00193 for (int i = 0; i < a.size(); i++) {
00194 l.add(new BaseDetail((JsonNode)a.get(i)));
00195 }
00196 return l;
00197 }
00198 return new ArrayList<BaseDetail>(0);
00199 }
00200
00206 @Override
00207 public void writeToParcel(Parcel parcel, int flags) {
00208 super.writeToParcel(parcel, flags);
00209 parcel.writeValue(fanart);
00210 parcel.writeValue(thumbnail);
00211 }
00212
00216 protected BaseDetail(Parcel parcel) {
00217 super(parcel);
00218 fanart = parcel.readString();
00219 thumbnail = parcel.readString();
00220 }
00221
00225 public static final Parcelable.Creator<BaseDetail> CREATOR = new Parcelable.Creator<BaseDetail>() {
00226 @Override
00227 public BaseDetail createFromParcel(Parcel parcel) {
00228 return new BaseDetail(parcel);
00229 }
00230 @Override
00231 public BaseDetail[] newArray(int n) {
00232 return new BaseDetail[n];
00233 }
00234 };
00235
00236 @Override
00237 public int describeContents() {
00238 return 0;
00239 }
00240 }
00241 }