rework list serialization
This commit is contained in:
parent
3fa0b2591a
commit
e65c943dd8
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class ArticleList extends ArrayList<Article> implements Parcelable {
|
public class ArticleList extends ArrayList<Article> implements Parcelable {
|
||||||
@ -15,10 +16,7 @@ public class ArticleList extends ArrayList<Article> implements Parcelable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel out, int flags) {
|
public void writeToParcel(Parcel out, int flags) {
|
||||||
out.writeInt(this.size());
|
out.writeList(this);
|
||||||
for (Article article : this) {
|
|
||||||
out.writeParcelable(article, flags);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Article findById(int id) {
|
public Article findById(int id) {
|
||||||
@ -30,12 +28,7 @@ public class ArticleList extends ArrayList<Article> implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void readFromParcel(Parcel in) {
|
public void readFromParcel(Parcel in) {
|
||||||
int length = in.readInt();
|
in.readList(this, getClass().getClassLoader());
|
||||||
|
|
||||||
for (int i = 0; i < length; i++) {
|
|
||||||
Article article = in.readParcelable(Article.class.getClassLoader());
|
|
||||||
this.add(article);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArticleList() { }
|
public ArticleList() { }
|
||||||
|
@ -18,20 +18,11 @@ public class FeedCategoryList extends ArrayList<FeedCategory> implements Parcela
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel out, int flags) {
|
public void writeToParcel(Parcel out, int flags) {
|
||||||
out.writeInt(this.size());
|
out.writeList(this);
|
||||||
for (FeedCategory feed : this) {
|
|
||||||
out.writeParcelable(feed, flags);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readFromParcel(Parcel in) {
|
public void readFromParcel(Parcel in) {
|
||||||
int length = in.readInt();
|
in.readList(this, getClass().getClassLoader());
|
||||||
|
|
||||||
for (int i = 0; i < length; i++) {
|
|
||||||
FeedCategory feed = in.readParcelable(FeedCategory.class.getClassLoader());
|
|
||||||
this.add(feed);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public FeedCategoryList(Parcel in) {
|
public FeedCategoryList(Parcel in) {
|
||||||
|
@ -18,20 +18,11 @@ public class FeedList extends ArrayList<Feed> implements Parcelable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel out, int flags) {
|
public void writeToParcel(Parcel out, int flags) {
|
||||||
out.writeInt(this.size());
|
out.writeList(this);
|
||||||
for (Feed feed : this) {
|
|
||||||
out.writeParcelable(feed, flags);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readFromParcel(Parcel in) {
|
public void readFromParcel(Parcel in) {
|
||||||
int length = in.readInt();
|
in.readList(this, getClass().getClassLoader());
|
||||||
|
|
||||||
for (int i = 0; i < length; i++) {
|
|
||||||
Feed feed = in.readParcelable(Feed.class.getClassLoader());
|
|
||||||
this.add(feed);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public FeedList(Parcel in) {
|
public FeedList(Parcel in) {
|
||||||
|
Loading…
Reference in New Issue
Block a user