package com.vk.sdk.api.model;

import android.os.Parcel;

public class VKApiFeedItem extends VKApiModel {
    public static final String TYPE_POST = "post";
    public static final String TYPE_PHOTO = "photo";
    public static final String TYPE_PHOTO_TAG = "photo_tag";
    public static final String TYPE_WALL_PHOTO = "wall_photo";
    public static final String TYPE_FRIEND = "friend";
    public static final String TYPE_NOTE = "note";

    public String type;
    public int source_id;
    public long date;

    public VKApiFeedItem() {
    }

    public VKApiFeedItem(Parcel source) {
        type = source.readString();
        source_id = source.readInt();
        date = source.readLong();
    }

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

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(type);
        dest.writeInt(source_id);
        dest.writeLong(date);
    }

    public static Creator<VKApiFeedItem> CREATOR = new Creator<VKApiFeedItem>() {
        public VKApiFeedItem createFromParcel(Parcel source) {
            return new VKApiFeedItem(source);
        }

        public VKApiFeedItem[] newArray(int size) {
            return new VKApiFeedItem[size];
        }
    };
}

@@ -49,16 +49,75 @@
 .Parcel;
+%0Aimport org.json.JSONException;%0Aimport org.json.JSONObject;
 %0A%0Apublic
@@ -564,16 +564,103 @@
 ng date;
+%0A    public boolean can_edit;%0A    public boolean can_delete;%0A    public VKApiPost post;
 %0A%0A    pu
@@ -835,24 +835,1160 @@
 readLong();%0A
+        can_edit = source.readByte() != 0;%0A        can_delete = source.readByte() != 0;%0A        post = source.readParcelable(getClass().getClassLoader());%0A    %7D%0A%0A    public VKApiFeedItem(JSONObject from) throws JSONException %7B%0A        parse(from);%0A    %7D%0A%0A    public VKApiFeedItem parse(JSONObject source) throws JSONException %7B%0A        type = source.optString(%22type%22);%0A        source_id = source.optInt(%22source_id%22);%0A        date = source.optLong(%22date%22);%0A        can_edit = ParseUtils.parseBoolean(source, %22can_edit%22);%0A        can_delete = ParseUtils.parseBoolean(source, %22can_delete%22);%0A        post = null;%0A%0A        if (type.equals(TYPE_POST)) %7B%0A            source.put(%22id%22, source.opt(%22post_id%22));%0A            source.put(%22to_id%22, source_id);%0A            source.put(%22from_id%22, source_id);%0A            source.put(%22reply_owner_id%22, source.opt(%22copy_owner_id%22));%0A            source.put(%22reply_post_id%22, source.opt(%22copy_post_id%22));%0A            // TODO: handle final_post%0A            // TODO: handle copy_post_date%0A            post = new VKApiPost(source);%0A        %7D%0A        // TODO: handle remaining feed item types%0A        return this;%0A
     %7D%0A%0A    @
@@ -2185,32 +2185,32 @@
 Int(source_id);%0A
-
         dest.wri
@@ -2219,24 +2219,177 @@
 Long(date);%0A
+        dest.writeByte(can_edit ? (byte)1 : (byte)0);%0A        dest.writeByte(can_delete ? (byte)1 : (byte)0);%0A        dest.writeParcelable(post, flags);%0A
     %7D%0A%0A    p

implement JSON parsing