package kr.co.hanwha.hifive.data.model;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import kr.co.hanwha.hifive.adapter.model.OkrListViewHolderData;

/**
 * 캠페인 정보
 * Created by sanghoonkwon on 2018. 2. 21..
 */

public class CampaignData implements Parcelable {
    /**
     * Campaign id
     */
    int campaign_id;
    /**
     * Campaign description
     */
    String campaign_desc;
    /**
     * "2018-02-14 00:00:00.0"
     */
    String campaign_due_to;
    /**
     * 40
     */
    int project_id;
    /**
     * "우주최강개발"
     */
    String project_name;

    public CampaignData() {

    }

    public CampaignData(int campaignId, String campaignDesc, int projectId, String projectName) {
        this(campaignId, campaignDesc, null, projectId, projectName, false);
    }

    public CampaignData(int campaign_id, String campaign_desc, String campaign_due_to, int project_id, String project_name, boolean isFirstItem) {
        this.campaign_id = campaign_id;
        this.campaign_desc = campaign_desc;
        this.campaign_due_to = campaign_due_to;
        this.project_id = project_id;
        this.project_name = project_name;
        this.isFirstItem = isFirstItem;
    }

    public CampaignData(OkrListViewHolderData data) {
        this.campaign_id = data.getId();
        this.campaign_desc = data.getDesc();
        this.project_id = data.getProjectId();
        this.project_name = data.getProjectName();
    }

    public CampaignData(Parcel in) {
        this.campaign_id = in.readInt();
        this.campaign_desc = in.readString();
        this.campaign_due_to = in.readString();
        this.project_id = in.readInt();
        this.project_name = in.readString();
        this.isFirstItem = in.readByte() != 0;
    }

    public static final Creator<CampaignData> CREATOR = new Creator<CampaignData>() {
        @Override
        public CampaignData createFromParcel(Parcel in) {
            return new CampaignData(in);
        }

        @Override
        public CampaignData[] newArray(int size) {
            return new CampaignData[size];
        }
    };

    public String getKey() {
        return project_id + "_" + campaign_id;
    }

    boolean isFirstItem = false;

    public boolean isFirstItem() {
        return isFirstItem;
    }

    public void setFirstItem(boolean firstItem) {
        isFirstItem = firstItem;
    }

    public int getCampaign_id() {
        return campaign_id;
    }

    public String getCampaign_desc() {
        return campaign_desc;
    }

    public String getCampaign_due_to() {
        return campaign_due_to;
    }

    public int getProject_id() {
        return project_id;
    }

    public String getProject_name() {
        return project_name;
    }

    @Override
    public String toString() {
        return "CampaignData{" +
                "campaign_id=" + campaign_id +
                ", campaign_desc='" + campaign_desc + '\'' +
                ", campaign_due_to='" + campaign_due_to + '\'' +
                ", project_id=" + project_id +
                ", project_name='" + project_name + '\'' +
                ", isFirstItem=" + isFirstItem +
                '}';
    }

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

    @Override
    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeInt(campaign_id);
        parcel.writeString(campaign_desc);
        parcel.writeString(campaign_due_to);
        parcel.writeInt(project_id);
        parcel.writeString(project_name);
        parcel.writeByte((byte) (isFirstItem ? 1 : 0));
    }
}
/*
{
    "campaign_id": 56,
    "description": "누가 일했었는지 모르게 하라"
}
*/