From e65c943dd89f30583e31591af2ad24f46ea55e8c Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 24 Oct 2013 15:31:47 +0400 Subject: [PATCH] rework list serialization --- src/org/fox/ttrss/types/ArticleList.java | 15 ++++----------- src/org/fox/ttrss/types/FeedCategoryList.java | 13 ++----------- src/org/fox/ttrss/types/FeedList.java | 13 ++----------- 3 files changed, 8 insertions(+), 33 deletions(-) diff --git a/src/org/fox/ttrss/types/ArticleList.java b/src/org/fox/ttrss/types/ArticleList.java index fe70a15c..c9b491ee 100644 --- a/src/org/fox/ttrss/types/ArticleList.java +++ b/src/org/fox/ttrss/types/ArticleList.java @@ -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
implements Parcelable { @@ -15,10 +16,7 @@ public class ArticleList extends ArrayList
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,17 +28,12 @@ public class ArticleList extends ArrayList
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() { } - public ArticleList(Parcel in) { + public ArticleList(Parcel in) { readFromParcel(in); } diff --git a/src/org/fox/ttrss/types/FeedCategoryList.java b/src/org/fox/ttrss/types/FeedCategoryList.java index 0b85ce3b..eb5331bc 100644 --- a/src/org/fox/ttrss/types/FeedCategoryList.java +++ b/src/org/fox/ttrss/types/FeedCategoryList.java @@ -18,20 +18,11 @@ public class FeedCategoryList extends ArrayList 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) { diff --git a/src/org/fox/ttrss/types/FeedList.java b/src/org/fox/ttrss/types/FeedList.java index 2d972919..350f45ad 100644 --- a/src/org/fox/ttrss/types/FeedList.java +++ b/src/org/fox/ttrss/types/FeedList.java @@ -18,20 +18,11 @@ public class FeedList extends ArrayList 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) {