rework list serialization

This commit is contained in:
Andrew Dolgov 2013-10-24 15:31:47 +04:00
parent 3fa0b2591a
commit e65c943dd8
3 changed files with 8 additions and 33 deletions

View File

@ -5,6 +5,7 @@ import java.util.ArrayList;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;
@SuppressWarnings("serial")
public class ArticleList extends ArrayList<Article> implements Parcelable {
@ -15,10 +16,7 @@ public class ArticleList extends ArrayList<Article> implements Parcelable {
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeInt(this.size());
for (Article article : this) {
out.writeParcelable(article, flags);
}
out.writeList(this);
}
public Article findById(int id) {
@ -30,12 +28,7 @@ public class ArticleList extends ArrayList<Article> implements Parcelable {
}
public void readFromParcel(Parcel in) {
int length = in.readInt();
for (int i = 0; i < length; i++) {
Article article = in.readParcelable(Article.class.getClassLoader());
this.add(article);
}
in.readList(this, getClass().getClassLoader());
}
public ArticleList() { }

View File

@ -18,20 +18,11 @@ public class FeedCategoryList extends ArrayList<FeedCategory> implements Parcela
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeInt(this.size());
for (FeedCategory feed : this) {
out.writeParcelable(feed, flags);
}
out.writeList(this);
}
public void readFromParcel(Parcel in) {
int length = in.readInt();
for (int i = 0; i < length; i++) {
FeedCategory feed = in.readParcelable(FeedCategory.class.getClassLoader());
this.add(feed);
}
in.readList(this, getClass().getClassLoader());
}
public FeedCategoryList(Parcel in) {

View File

@ -18,20 +18,11 @@ public class FeedList extends ArrayList<Feed> implements Parcelable {
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeInt(this.size());
for (Feed feed : this) {
out.writeParcelable(feed, flags);
}
out.writeList(this);
}
public void readFromParcel(Parcel in) {
int length = in.readInt();
for (int i = 0; i < length; i++) {
Feed feed = in.readParcelable(Feed.class.getClassLoader());
this.add(feed);
}
in.readList(this, getClass().getClassLoader());
}
public FeedList(Parcel in) {