summaryrefslogtreecommitdiff
path: root/org.fox.ttrss/src/main/java/org/fox/ttrss/types/Article.java
blob: a5032c6cc962cf83bf9596c244833deddb68145f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package org.fox.ttrss.types;

import android.os.Parcel;
import android.os.Parcelable;

import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

import java.util.ArrayList;
import java.util.List;

// TODO: serialize Labels
public class Article implements Parcelable {
	public int id;
	public boolean unread; 
	public boolean marked; 
	public boolean published; 
	public int score;
	public int updated; 
	public boolean is_updated; 
	public String title; 
	public String link; 
	public int feed_id; 
	public List<String> tags;
	public List<Attachment> attachments;
	public String content;
    public String excerpt;
	public List<List<String>> labels;
	public String feed_title;	
	public int comments_count;
	public String comments_link;
	public boolean always_display_attachments;
	public String author;
	public String note;
    public boolean selected;

    /* not serialized */
    public Document articleDoc;
    public Element flavorImage;
    public boolean noValidFlavorImage;

	public Article(Parcel in) {
		readFromParcel(in);
	}
	
	public Article() {
		
	}
	
	public Article(int id) {
		this.id = id;
		this.title = "";
		this.link = "";
		this.tags = new ArrayList<String>();
	}

	@Override
	public int describeContents() {
		return 0;
	}
	
	@Override
	public void writeToParcel(Parcel out, int flags) {
		out.writeInt(id);
		out.writeInt(unread ? 1 : 0);
		out.writeInt(marked ? 1 : 0);
		out.writeInt(published ? 1 : 0);
		out.writeInt(score);
		out.writeInt(updated);
		out.writeInt(is_updated ? 1 : 0);
		out.writeString(title);
		out.writeString(link);
		out.writeInt(feed_id);
		out.writeStringList(tags);
		out.writeString(content);
        out.writeString(excerpt);
		out.writeList(attachments);
		out.writeString(feed_title);
		out.writeInt(comments_count);
		out.writeString(comments_link);
		out.writeInt(always_display_attachments ? 1 : 0);
		out.writeString(author);
		out.writeString(note);
        out.writeInt(selected ? 1 : 0);
	}
	
	public void readFromParcel(Parcel in) {
		id = in.readInt();
		unread = in.readInt() == 1;
		marked = in.readInt() == 1;
		published = in.readInt() == 1;
		score = in.readInt();
		updated = in.readInt();
		is_updated = in.readInt() == 1;
		title = in.readString();
		link = in.readString();
		feed_id = in.readInt();
		
		if (tags == null) tags = new ArrayList<String>();
		in.readStringList(tags);
		
		content = in.readString();
        excerpt = in.readString();
		
		attachments = new ArrayList<Attachment>();
		in.readList(attachments, Attachment.class.getClassLoader());
		
		feed_title = in.readString();
		
		comments_count = in.readInt();
		comments_link = in.readString();
		always_display_attachments = in.readInt() == 1;
		author = in.readString();
		note = in.readString();
        selected = in.readInt() == 1;
	}
	
	@SuppressWarnings("rawtypes")
	public static final Parcelable.Creator CREATOR =
    	new Parcelable.Creator() {
            public Article createFromParcel(Parcel in) {
                return new Article(in);
            }
 
            public Article[] newArray(int size) {
                return new Article[size];
            }
        };
}