/*
 * Copyright (C) 2015 Mateusz Widuch. All rights reserved.
 */

package eu.redray.trevie;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.List;

/**
 * Represents movie item.
 */
public class Movie implements Parcelable {

    public static final String EXTRA_DETAILS = "movie_details";
    public static final Creator<Movie> CREATOR = new Creator<Movie>() {
        @Override
        public Movie createFromParcel(Parcel in) {
            return new Movie(in);
        }

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

    private String mId;
    private String mTitle;
    private String mReleaseDate;
    private String mRating;
    private String mSynopsis;
    private String mPosterPath;
    private String mRuntime;
    private List<String> mGenres;
    private List<String> mCountries;

    public Movie(String id, String title, String releaseDate, String avgRating, String overview, String posterPath,
                 String runtime, List<String> genres, List<String> countries) {
        mId = id;
        mTitle = title;
        mReleaseDate = releaseDate;
        mRating = avgRating;
        mSynopsis = overview;
        mPosterPath = posterPath;
        mRuntime = runtime;
        mGenres = genres;
        mCountries = countries;
    }

    protected Movie(Parcel in) {
        mId = in.readString();
        mTitle = in.readString();
        mReleaseDate = in.readString();
        mRating = in.readString();
        mSynopsis = in.readString();
        mPosterPath = in.readString();
        mRuntime = in.readString();
        mGenres = in.readArrayList(String.class.getClassLoader());
        mCountries = in.readArrayList(String.class.getClassLoader());
    }

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

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(mId);
        dest.writeString(mTitle);
        dest.writeString(mReleaseDate);
        dest.writeString(mRating);
        dest.writeString(mSynopsis);
        dest.writeString(mPosterPath);
        dest.writeString(mRuntime);
        dest.writeList(mGenres);
        dest.writeList(mCountries);
    }

    public String getPosterPath() {
        return mPosterPath;
    }

    public String getTitle() {
        return mTitle;
    }

    public String getReleaseDate() {
        return mReleaseDate;
    }

    public String getRating() {
        return mRating;
    }

    public String getSynopsis() {
        return mSynopsis;
    }

    public String getReleaseYear() {
        return mReleaseDate.substring(0, 4);
    }

    public String getRuntime() {
        return mRuntime;
    }

    public List<String> getGenres() {
        return mGenres;
    }

    public List<String> getCountries() {
        return mCountries;
    }
}

@@ -148,32 +148,8 @@
 e;%0A%0A
-import java.util.List;%0A%0A
 /**%0A
@@ -803,28 +803,22 @@
 private 
-List%3C
 String
-%3E
  mGenres
@@ -831,28 +831,22 @@
 private 
-List%3C
 String
-%3E
  mCountr
@@ -1000,28 +1000,22 @@
 untime, 
-List%3C
 String
-%3E
  genres,
@@ -1015,28 +1015,22 @@
 genres, 
-List%3C
 String
-%3E
  countri
@@ -1613,117 +1613,53 @@
 read
-ArrayList(String.class.getClassLoader());%0A        mCountries = in.readArrayList(String.class.getClassLoader()
+String();%0A        mCountries = in.readString(
 );%0A 
@@ -2079,20 +2079,22 @@
 st.write
-List
+String
 (mGenres
@@ -2114,20 +2114,22 @@
 st.write
-List
+String
 (mCountr
@@ -2133,32 +2133,87 @@
 ntries);%0A    %7D%0A%0A
+    public String getId() %7B%0A        return mId;%0A    %7D%0A%0A
     public Strin
@@ -2692,36 +2692,30 @@
 %0A    public 
-List%3C
 String
-%3E
  getGenres()
@@ -2763,20 +2763,14 @@
 lic 
-List%3C
 String
-%3E
  get

Modify Movie fields to more suitable data types