package com.wasu.cs.model; import android.os.Parcel; import android.os.Parcelable; import com.wasu.util.StringUtils; import org.json.JSONArray; import org.json.JSONObject; import java.io.Serializable; import java.util.ArrayList; import java.util.List; @SuppressWarnings("serial") public class SpecialColumnModel extends Model { private int eid; private int ctype; private int elementType; private String jsonUrl; private String csJsonUrl; private String csLayout; private String layout; public String getCsJsonUrl() { return csJsonUrl; } public void setCsJsonUrl(String csJsonUrl) { this.csJsonUrl = csJsonUrl; } public String getCsLayout() { return csLayout; } public void setCsLayout(String csLayout) { this.csLayout = csLayout; } public ChannelListModel getChannel() { return channel; } public void setChannel(ChannelListModel channel) { this.channel = channel; } private String position; private int selected; private int linkType; private String summary; private String summaryColor; private String name; private String nameColor; private String description; private String descColor; private String title; private String content; private String tbgColor; private String cmark; private String points; private String traceid; // 用于统计 //直播频道对象 private ChannelListModel channel; private List picUrlList = new ArrayList(); private ArrayList assetList = new ArrayList(); private ArrayList videoSourceList = new ArrayList(); @Override public boolean from(JSONObject json) { boolean result = super.from(json); if (result) { eid = json.optInt("eid", Integer.MAX_VALUE); ctype = json.optInt("ctype", Integer.MAX_VALUE); elementType = json.optInt("elementType", Integer.MAX_VALUE); jsonUrl = json.optString("jsonUrl", ""); layout = json.optString("layout", ""); position = json.optString("position", ""); selected = json.optInt("selected", Integer.MAX_VALUE); linkType = json.optInt("linkType", Integer.MAX_VALUE); summary = json.optString("summary", ""); summaryColor = json.optString("summaryColor", ""); name = json.optString("name", ""); nameColor = json.optString("nameColor", ""); description = json.optString("description", ""); descColor = json.optString("descColor", ""); title = json.optString("title", ""); content = json.optString("content", ""); tbgColor = json.optString("tbgColor", ""); cmark = json.optString("cmark", ""); points = json.optString("points", ""); csJsonUrl = json.optString("csJsonUrl",""); csLayout =json.optString("csLayout",""); JSONArray jsonArr = json.optJSONArray("picUrls"); if (jsonArr != null && jsonArr.length() > 0) { PicUrl item; for (int i = 0, len = jsonArr.length(); i < len; i++) { item = new PicUrl(); if (item.from(jsonArr.optJSONObject(i))) { picUrlList.add(item); } } } JSONArray jsonArr2 = json.optJSONArray("assets"); if (jsonArr2 != null && jsonArr2.length() > 0) { AssetModel item; for (int i = 0, len = jsonArr2.length(); i < len; i++) { item = new AssetModel(); if (item.from(jsonArr2.optJSONObject(i))) { assetList.add(item); } } } // 点播资产解析 JSONArray jsonArr3 = json.optJSONArray("tags"); if (jsonArr3 != null && jsonArr3.length() > 0) { VideoModel item; for (int i = 0, len = jsonArr3.length(); i < len; i++) { item = new VideoModel(); if (item.from(jsonArr3.optJSONObject(i))) { videoSourceList.add(item); } } } // 直播资产解析 JSONObject obj=json.optJSONObject("channel"); ChannelListModel channelListItem=new ChannelListModel(); if (channelListItem.from(obj)) { channel=channelListItem; } } return result; } public ArrayList getVideoSourceList() { return videoSourceList; } public void setVideoSourceList(ArrayList videoSourceList) { this.videoSourceList = videoSourceList; } public int getEid() { return eid; } public int getSelected() { return selected; } public String getPosition() { return position; } public int getElementType() { return elementType; } public String getContent() { return content; } public String getTitle() { return title; } public String getSummary() { return summary; } public String getDescription() { return description; } public String getTbgColor() { return tbgColor; } public int getLinkType() { return linkType; } public String getLayout() { return layout; } public String getJsonUrl() { return jsonUrl; } public String getNameColor() { return nameColor; } public String getSummaryColor() { return summaryColor; } public String getDescColor() { return descColor; } public String getName() { return name; } public int getCtype() { return ctype; } public List getPicUrlList() { return picUrlList; } public static class PicUrl extends Model { private String topPic; private String bottomPic; @Override public boolean from(JSONObject json) { boolean result = super.from(json); if (result) { topPic = json.optString("topPic", ""); bottomPic = json.optString("bottomPic", ""); } return result; } public String getTopPic() { return topPic; } public void setTopPic(String topPic) { this.topPic = topPic; } public String getBottomPic() { return bottomPic; } public void setBottomPic(String bottomPic) { this.bottomPic = bottomPic; } } public static class ChannelListModel extends Model implements Parcelable { private String name; private String type; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getType() { return type; } public void setType(String type) { this.type = type; } public List getChannelList() { return channelList; } public void setChannelList(List channelList) { this.channelList = channelList; } private List channelList = new ArrayList(); @Override public boolean from(JSONObject json) { boolean result = super.from(json); if (result) { name = json.optString("name", ""); type = json.optString("type", ""); JSONArray jsonArr = json.optJSONArray("channelList"); if (jsonArr != null && jsonArr.length() > 0) { ChannelModel item; for (int i = 0, len = jsonArr.length(); i < len; i++) { item = new ChannelModel(); if (item.from(jsonArr.optJSONObject(i))) { channelList.add(item); } } } } return result; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(name); dest.writeString(type); dest.writeTypedList(channelList); } public static final Parcelable.Creator CREATOR = new Creator() { @Override public ChannelListModel createFromParcel(Parcel source) { ChannelListModel channelListModel = new ChannelListModel(); channelListModel.name = source.readString(); channelListModel.type = source.readString(); source.readTypedList(channelListModel.channelList, ChannelModel.CREATOR); return channelListModel; } @Override public ChannelListModel[] newArray(int size) { return new ChannelListModel[size]; } }; } public static class LivePlayUrlModel extends Model implements Parcelable { private String httpUrl; private String p2pid; private String p2pserver; @Override public boolean from(JSONObject json) { boolean result = super.from(json); if (result) { httpUrl = json.optString("httpUrl", ""); p2pid = json.optString("p2pid", ""); p2pserver = json.optString("p2pserver", ""); } return result; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(httpUrl); dest.writeString(p2pid); dest.writeString(p2pserver); } public static final Parcelable.Creator CREATOR = new Creator() { @Override public LivePlayUrlModel createFromParcel(Parcel source) { LivePlayUrlModel livePlayModel = new LivePlayUrlModel(); livePlayModel.httpUrl = source.readString(); livePlayModel.p2pid = source.readString(); livePlayModel.p2pserver = source.readString(); return livePlayModel; } @Override public LivePlayUrlModel[] newArray(int size) { return new LivePlayUrlModel[size]; } }; } public static class ChannelModel extends Model implements Parcelable { public int getChannelId() { return channelId; } public void setChannelId(int channelId) { this.channelId = channelId; } public String getChannelKey() { return channelKey; } public void setChannelKey(String channelKey) { this.channelKey = channelKey; } public String getChannelName() { return channelName; } public void setChannelName(String channelName) { this.channelName = channelName; } public String getPicUrl() { return picUrl; } public void setPicUrl(String picUrl) { this.picUrl = picUrl; } public String getPlayBackBill() { return playBackBill; } public void setPlayBackBill(String playBackBill) { this.playBackBill = playBackBill; } public String getPlayBackUrl() { return playBackUrl; } public void setPlayBackUrl(String playBackUrl) { this.playBackUrl = playBackUrl; } public String getPlayType() { return playType; } public void setPlayType(String playType) { this.playType = playType; } public List getLivePlayUrlList() { return livePlayUrlList; } public void setLivePlayUrlList(List livePlayUrlList) { this.livePlayUrlList = livePlayUrlList; } private int channelId; private String channelKey; private String channelName; private String picUrl; private String playBackBill; private String playBackUrl; private String playType; private List livePlayUrlList = new ArrayList(); @Override public boolean from(JSONObject json) { boolean result = super.from(json); if (result) { channelId = json.optInt("channelId", 0); channelKey = json.optString("channelKey", ""); channelName = json.optString("channelName", ""); picUrl = json.optString("picUrl", ""); playBackBill = json.optString("playBackBill", ""); playBackUrl = json.optString("playBackUrl", ""); playType = json.optString("playType", ""); JSONArray jsonArr = json.optJSONArray("playUrl"); if (jsonArr != null && jsonArr.length() > 0) { LivePlayUrlModel item; for (int i = 0, len = jsonArr.length(); i < len; i++) { item = new LivePlayUrlModel(); if (item.from(jsonArr.optJSONObject(i))) { livePlayUrlList.add(item); } } } } return result; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(channelId); dest.writeString(channelKey); dest.writeString(channelName); dest.writeString(picUrl); dest.writeString(playBackBill); dest.writeString(playBackUrl); dest.writeString(playType); dest.writeTypedList(livePlayUrlList); } public static final Parcelable.Creator CREATOR = new Creator() { @Override public ChannelModel createFromParcel(Parcel source) { ChannelModel channelModel = new ChannelModel(); channelModel.channelId = source.readInt(); channelModel.channelKey = source.readString(); channelModel.channelName = source.readString(); channelModel.picUrl = source.readString(); channelModel.playBackBill = source.readString(); channelModel.playBackUrl = source.readString(); channelModel.playType = source.readString(); source.readTypedList(channelModel.livePlayUrlList, LivePlayUrlModel.CREATOR); return channelModel; } @Override public ChannelModel[] newArray(int size) { return new ChannelModel[size]; } }; } public static class AssetModel extends Model implements Parcelable ,Serializable{ private int id; private String summary; private String title; private static final long serialVersionUID = 2L; private List tagList = new ArrayList(); private double mCurrentPosition = 0; @Override public boolean from(JSONObject json) { boolean result = super.from(json); if (result) { id = json.optInt("id", 0); summary = json.optString("summary", ""); title = json.optString("title", ""); JSONArray jsonArr = json.optJSONArray("tags"); if (jsonArr != null && jsonArr.length() > 0) { TagModel item; for (int i = 0, len = jsonArr.length(); i < len; i++) { item = new TagModel(); if (item.from(jsonArr.optJSONObject(i))) { tagList.add(item); } } } } return result; } public int getId() { return id; } public String getSummary() { return summary; } public String getTitle() { return title; } public List getTagList() { return tagList; } public double getCurrentPosition() { return mCurrentPosition; } public void setCurrentPosition(double position) { mCurrentPosition = position; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(id); dest.writeString(summary); dest.writeString(title); dest.writeTypedList(tagList); dest.writeDouble(mCurrentPosition); } public static final Parcelable.Creator CREATOR = new Creator() { @Override public AssetModel createFromParcel(Parcel source) { AssetModel assetModel = new AssetModel(); assetModel.id = source.readInt(); assetModel.summary = source.readString(); assetModel.title = source.readString(); source.readTypedList(assetModel.tagList, TagModel.CREATOR); assetModel.mCurrentPosition = source.readDouble(); return assetModel; } @Override public AssetModel[] newArray(int size) { return new AssetModel[size]; } }; } public static class TagModel extends Model implements Parcelable { private int rate; private String tag; private List videoList = new ArrayList(); @Override public boolean from(JSONObject json) { boolean result = super.from(json); if (result) { rate = json.optInt("rate", 0); tag = json.optString("tag", ""); JSONArray jsonArr = json.optJSONArray("items"); if (jsonArr != null && jsonArr.length() > 0) { VideoModel item; for (int i = 0, len = jsonArr.length(); i < len; i++) { item = new VideoModel(); if (item.from(jsonArr.optJSONObject(i))) { videoList.add(item); } } } } return result; } public int getRate() { return rate; } public String getTag() { return tag; } public List getVideoList() { return videoList; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(rate); dest.writeString(tag); dest.writeTypedList(videoList); } public static final Parcelable.Creator CREATOR = new Creator() { @Override public TagModel createFromParcel(Parcel source) { TagModel tagModel = new TagModel(); tagModel.rate = source.readInt(); tagModel.tag = source.readString(); source.readTypedList(tagModel.videoList, VideoModel.CREATOR); return tagModel; } @Override public TagModel[] newArray(int size) { return new TagModel[size]; } }; } public static class VideoModel extends Model implements Parcelable { private int rate; private String tag; private String datetime; private int episode; private int itemId; private String title; private List playUrls = new ArrayList(); @Override public boolean from(JSONObject json) { boolean result = super.from(json); if (result) { datetime = json.optString("datetime", ""); episode = json.optInt("episode", 0); itemId = json.optInt("itemId", 0); title = json.optString("title", ""); tag = json.optString("tag", ""); rate = json.optInt("rate", 0); JSONArray jsonArr = json.optJSONArray("playUrls"); if (jsonArr != null && jsonArr.length() > 0) { String playUrl; for (int i = 0, len = jsonArr.length(); i < len; i++) { playUrl = jsonArr.optString(i); if (!StringUtils.isBlank(playUrl)) { playUrls.add(playUrl); } } } } return result; } public String getDatetime() { return datetime; } public int getEpisode() { return episode; } public int getItemId() { return itemId; } public String getTitle() { return title; } public String getTag() { return tag; } public int getRate() { return rate; } public List getPlayUrls() { return playUrls; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(datetime); dest.writeInt(episode); dest.writeInt(itemId); dest.writeString(title); dest.writeString(tag); dest.writeInt(rate); dest.writeStringList(playUrls); } public static final Parcelable.Creator CREATOR = new Creator() { @Override public VideoModel createFromParcel(Parcel source) { VideoModel videoModel = new VideoModel(); videoModel.datetime = source.readString(); videoModel.episode = source.readInt(); videoModel.itemId = source.readInt(); videoModel.title = source.readString(); videoModel.tag = source.readString(); videoModel.rate = source.readInt(); source.readStringList(videoModel.playUrls); return videoModel; } @Override public VideoModel[] newArray(int size) { return new VideoModel[size]; } }; } public String getCmark() { return cmark; } public String getPoints() { return points; } public ArrayList getAssetList() { return assetList; } public String getTraceid() { return traceid; } }