Skip to content

Commit 02ba1c3

Browse files
committed
stop storing Article as parcelable (store id instead), remove Parcelable implementation from Article class
1 parent bab4c9e commit 02ba1c3

File tree

3 files changed

+12
-85
lines changed

3 files changed

+12
-85
lines changed

org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleFragment.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ public void onCreate(Bundle savedInstanceState) {
8383
super.onCreate(savedInstanceState);
8484

8585
if (savedInstanceState != null) {
86-
m_article = savedInstanceState.getParcelable("m_article");
86+
int articleId = savedInstanceState.getInt("m_articleId");
87+
88+
m_article = Application.getArticlesModel().getById(articleId);
8789
}
8890
}
8991

@@ -389,6 +391,6 @@ public void onAttach(Activity activity) {
389391
public void onSaveInstanceState(Bundle out) {
390392
super.onSaveInstanceState(out);
391393

392-
out.putParcelable("m_article", m_article);
394+
out.putInt("m_articleId", m_article.id);
393395
}
394396
}

org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleModel.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,4 +431,11 @@ public List<Article> getSelected() {
431431
}).collect(Collectors.toList());
432432
}
433433

434+
// returns null if not found
435+
public Article getById(final int id) {
436+
return m_articles.getValue().stream().filter(a -> a.id == id)
437+
.findFirst()
438+
.orElse(null);
439+
}
440+
434441
}

org.fox.ttrss/src/main/java/org/fox/ttrss/types/Article.java

Lines changed: 1 addition & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package org.fox.ttrss.types;
22

3-
import android.os.Parcel;
4-
import android.os.Parcelable;
5-
63
import org.jsoup.Jsoup;
74
import org.jsoup.nodes.Document;
85
import org.jsoup.nodes.Element;
@@ -16,7 +13,7 @@
1613
import java.util.regex.Pattern;
1714

1815
// TODO: serialize Labels
19-
public class Article implements Parcelable {
16+
public class Article {
2017
public static final int TYPE_AMR_FOOTER = -2;
2118

2219
public static final int FLAVOR_KIND_ALBUM = 1;
@@ -73,10 +70,6 @@ public class Article implements Parcelable {
7370
transient public String youtubeVid;
7471
transient public List<Element> mediaList = new ArrayList<>();
7572

76-
public Article(Parcel in) {
77-
readFromParcel(in);
78-
}
79-
8073
public Article() {
8174

8275
}
@@ -237,81 +230,6 @@ public Article(Article clone) {
237230
mediaList = new ArrayList<>(clone.mediaList);
238231
}
239232

240-
@Override
241-
public int describeContents() {
242-
return 0;
243-
}
244-
245-
@Override
246-
public void writeToParcel(Parcel out, int flags) {
247-
out.writeInt(id);
248-
out.writeInt(unread ? 1 : 0);
249-
out.writeInt(marked ? 1 : 0);
250-
out.writeInt(published ? 1 : 0);
251-
out.writeInt(score);
252-
out.writeInt(updated);
253-
out.writeInt(is_updated ? 1 : 0);
254-
out.writeString(title);
255-
out.writeString(link);
256-
out.writeInt(feed_id);
257-
out.writeStringList(tags);
258-
out.writeString(content);
259-
out.writeString(excerpt);
260-
out.writeList(attachments);
261-
out.writeString(feed_title);
262-
out.writeInt(comments_count);
263-
out.writeString(comments_link);
264-
out.writeInt(always_display_attachments ? 1 : 0);
265-
out.writeString(author);
266-
out.writeString(note);
267-
out.writeInt(selected ? 1 : 0);
268-
out.writeString(site_url);
269-
}
270-
271-
public void readFromParcel(Parcel in) {
272-
id = in.readInt();
273-
unread = in.readInt() == 1;
274-
marked = in.readInt() == 1;
275-
published = in.readInt() == 1;
276-
score = in.readInt();
277-
updated = in.readInt();
278-
is_updated = in.readInt() == 1;
279-
title = in.readString();
280-
link = in.readString();
281-
feed_id = in.readInt();
282-
283-
if (tags == null) tags = new ArrayList<>();
284-
in.readStringList(tags);
285-
286-
content = in.readString();
287-
excerpt = in.readString();
288-
289-
attachments = new ArrayList<>();
290-
in.readList(attachments, Attachment.class.getClassLoader());
291-
292-
feed_title = in.readString();
293-
294-
comments_count = in.readInt();
295-
comments_link = in.readString();
296-
always_display_attachments = in.readInt() == 1;
297-
author = in.readString();
298-
note = in.readString();
299-
selected = in.readInt() == 1;
300-
site_url = in.readString();
301-
}
302-
303-
@SuppressWarnings("rawtypes")
304-
public static final Parcelable.Creator CREATOR =
305-
new Parcelable.Creator() {
306-
public Article createFromParcel(Parcel in) {
307-
return new Article(in);
308-
}
309-
310-
public Article[] newArray(int size) {
311-
return new Article[size];
312-
}
313-
};
314-
315233
/**
316234
* set fields which might be missing during JSON deserialization to sane values
317235
*/

0 commit comments

Comments
 (0)