package com.jonalmeida.john.item;

import java.io.Serializable;

/// Json data structure view:
// {
//         "by" : "dhouston",
//         "descendants" : 71,
//         "id" : 8863,
//         "kids" : [ 8952, 9224, 8917, 8884, 8887, 8943, 8869, 8958, 9005],
//         "score" : 111,
//         "time" : 1175714200,
//         "title" : "My YC app: Dropbox - Throw away your USB drive",
//         "type" : "story",
//         "url" : "http://www.getdropbox.com/u/2/screencast.html"
// }

public class StoryItem extends Item implements Serializable {
    protected String by;
    protected int descendants;
    protected int[] kids;
    protected int score;
    protected String text;
    protected int time;
    protected String title;
    protected String type;
    protected String url;

    public StoryItem() {
        super();
        this.score = -1;
        this.descendants = -1;
    }

    public StoryItem(int id) {
        super(id);
        this.score = -1;
        this.descendants = -1;
    }

    public StoryItem(String id) {
        super(id);
    }

    public StoryItem(String title, String url, int score, String by, int descendants) {
        this.title = title;
        this.url = url;
        this.score = score;
        this.by = by;
        this.descendants = descendants;
    }

    @Override
    public void updateThis(Item i) {
        StoryItem item = (StoryItem) i;
        this.id = item.id;
        this.by = item.by;
        this.descendants = item.descendants;
        this.kids = item.kids;
        this.score = item.score;
        this.text = item.text;
        this.time = item.time;
        this.title = item.title;
        this.type = item.type;
        this.url = item.url;
    }

    public String getBy() {
        return by;
    }

    public String getTitle() {
        return title;
    }

    public String getUrl() {
        return url;
    }

    public int getScore() {
        return score;
    }

    public int getDescendants() {
        return descendants;
    }

    public int getId() {
        return super.id;
    }

    public int[] getKids() {
        return kids;
    }

    public String getType() {
        return type;
    }

    public String getText() {
        return text;
    }

    public int getTime() {
        return time;
    }

    public String toString() {
        return " title: " + title +
                " url: " + url +
                " score: " + score +
                " by: "  + by +
                " descendants: " + descendants +
                super.toString();
    }

}

@@ -39,24 +39,51 @@
 ort 
-java.io.Serializ
+android.os.Parcel;%0Aimport android.os.Parcel
 able
@@ -564,16 +564,14 @@
 nts 
-Serializ
+Parcel
 able
@@ -1324,24 +1324,422 @@
 nts;%0A    %7D%0A%0A
+    private StoryItem(Parcel in) %7B%0A        this.by = in.readString();%0A        this.descendants = in.readInt();%0A        this.id = in.readInt();%0A        in.readIntArray(kids);%0A        this.score = in.readInt();%0A        this.text = in.readString();%0A        this.time = in.readInt();%0A        this.title = in.readString();%0A        this.type = in.readString();%0A        this.url = in.readString();%0A    %7D%0A%0A
     @Overrid
@@ -1821,35 +1821,8 @@
  i;%0A
-        this.id = item.id;%0A
     
@@ -1885,24 +1885,51 @@
 escendants;%0A
+        this.id = item.id;%0A
         this
@@ -2131,31 +2131,904 @@
 = item.url;%0A
-
     %7D%0A%0A
+    @Override%0A    public int describeContents() %7B%0A        return 0;%0A    %7D%0A%0A    @Override%0A    public void writeToParcel(Parcel parcel, int i) %7B%0A        parcel.writeString(this.by);%0A        parcel.writeInt(this.descendants);%0A        parcel.writeInt(this.id);%0A        parcel.writeIntArray(this.kids);%0A        parcel.writeInt(this.score);%0A        parcel.writeString(this.text);%0A        parcel.writeInt(this.time);%0A        parcel.writeString(this.title);%0A        parcel.writeString(this.type);%0A        parcel.writeString(this.url);%0A    %7D%0A%0A    public static final Parcelable.Creator%3CStoryItem%3E CREATOR = new Creator%3CStoryItem%3E() %7B%0A        @Override%0A        public StoryItem createFromParcel(Parcel parcel) %7B%0A            return new StoryItem(parcel);%0A        %7D%0A%0A        @Override%0A        public StoryItem%5B%5D newArray(int i) %7B%0A            return new StoryItem%5B0%5D;%0A        %7D%0A    %7D;%0A%0A
     public S

Implement Parcelable for StoryItem