Android Story

[ Android ] Intent를 이용한 Custom Object를 넘기는 방법.

WhiteDuck 2016. 2. 2. 09:20

[ Android ] Intent를 이용한 Custom Object를 넘기는 방법.

http://thorwel.tistory.com/80


public AAclass extends Parcelable {

 // intent를 통하여 객체를 넘기기 위해서  Parcelable 구현
public static final Creator<Item> CREATOR = new Creator<Item>() {
@Override
public Item createFromParcel(Parcel in) {
return new Item(in);
}

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

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

public Item(Parcel in) {
this.setActor(Arrays.<Content>asList((Content[]) in.readArray(Item.class.getClassLoader())));
this.setDirector(Arrays.<Content>asList((Content[]) in.readArray(Item.class.getClassLoader())));
this.setExpect_grades(Arrays.<Content>asList((Content[]) in.readArray(Item.class.getClassLoader())));
this.setGenre(Arrays.<Content>asList((Content[]) in.readArray(Item.class.getClassLoader())));
this.setGrade1(Arrays.<Content>asList((Content[]) in.readArray(Item.class.getClassLoader())));
this.setGrade2(Arrays.<Content>asList((Content[]) in.readArray(Item.class.getClassLoader())));
this.setGrade3(Arrays.<Content>asList((Content[]) in.readArray(Item.class.getClassLoader())));
this.setNation(Arrays.<Content>asList((Content[]) in.readArray(Item.class.getClassLoader())));
this.setOpen_info(Arrays.<Content>asList((Content[]) in.readArray(Item.class.getClassLoader())));
this.setRes(Arrays.<Content>asList((Content[]) in.readArray(Item.class.getClassLoader())));
this.setStory(Arrays.<Content>asList((Content[]) in.readArray(Item.class.getClassLoader())));
this.setThumbnail(Arrays.<Content>asList((Content[]) in.readArray(Item.class.getClassLoader())));
this.setTitle(Arrays.<Content>asList((Content[]) in.readArray(Item.class.getClassLoader())));
this.setTrailer(Arrays.<Content>asList((Content[]) in.readArray(Item.class.getClassLoader())));
this.setVedio_info(Arrays.<Content>asList((Content[]) in.readArray(Item.class.getClassLoader())));
this.setYear(Arrays.<Content>asList((Content[]) in.readArray(Item.class.getClassLoader())));
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeArray(this.getActor().toArray());
dest.writeArray(this.getDirector().toArray());
dest.writeArray(this.getExpect_grades().toArray());
dest.writeArray(this.getGenre().toArray());
dest.writeArray(this.getGrade1().toArray());
dest.writeArray(this.getGrade2().toArray());
dest.writeArray(this.getGrade3().toArray());
dest.writeArray(this.getNation().toArray());
dest.writeArray(this.getOpen_info().toArray());
dest.writeArray(this.getRes().toArray());
dest.writeArray(this.getStory().toArray());
dest.writeArray(this.getThumbnail().toArray());
dest.writeArray(this.getTitle().toArray());
dest.writeArray(this.getTrailer().toArray());
dest.writeArray(this.getVedio_info().toArray());
dest.writeArray(this.getYear().toArray());
}

}

반응형