Added Android code
[wl-app.git] / Android / app / src / main / java / com / moiseum / wolnelektury / connection / models / BookModel.java
1 package com.moiseum.wolnelektury.connection.models;
2
3 import com.google.gson.annotations.SerializedName;
4 import com.moiseum.wolnelektury.storage.StringListConverter;
5
6 import org.parceler.Parcel;
7
8 import java.util.List;
9
10 import io.objectbox.annotation.Convert;
11 import io.objectbox.annotation.Entity;
12 import io.objectbox.annotation.Id;
13
14 /**
15  * Created by piotrostrowski on 16.11.2017.
16  */
17
18 @Parcel(Parcel.Serialization.BEAN)
19 @Entity
20 public class BookModel {
21
22         @Id(assignable = true)
23         private long localId;
24
25         // API provided fields
26         private String kind;
27         private String author;
28         private String url;
29         @SerializedName("has_audio")
30         private boolean hasAudio;
31         private String title;
32         private String cover;
33         private String epoch;
34         private String href;
35         private String genre;
36         private String slug;
37         @SerializedName("cover_color")
38         private String coverColor;
39         private String key;
40         @SerializedName("full_sort_key")
41         private String sortedKey;
42         @SerializedName("simple_thumb")
43         private String coverThumb;
44         private boolean liked;
45
46         // Locally stored fields
47         private String ebookName;
48         private int currentChapter;
49         private int totalChapters;
50         private String ebookFileUrl;
51         private int currentAudioChapter;
52         private int totalAudioChapters;
53         @Convert(converter = StringListConverter.class, dbType = String.class)
54         private List<String> audioFileUrls;
55
56         public BookModel() {
57         }
58
59         public long getLocalId() {
60                 return localId;
61         }
62
63         public void setLocalId(long localId) {
64                 this.localId = localId;
65         }
66
67         public String getKind() {
68                 return kind;
69         }
70
71         public void setKind(String kind) {
72                 this.kind = kind;
73         }
74
75         public String getAuthor() {
76                 return author;
77         }
78
79         public void setAuthor(String author) {
80                 this.author = author;
81         }
82
83         public String getUrl() {
84                 return url;
85         }
86
87         public void setUrl(String url) {
88                 this.url = url;
89         }
90
91         public String getTitle() {
92                 return title;
93         }
94
95         public void setTitle(String title) {
96                 this.title = title;
97         }
98
99         public boolean isHasAudio() {
100                 return hasAudio;
101         }
102
103         public void setHasAudio(boolean hasAudio) {
104                 this.hasAudio = hasAudio;
105         }
106
107         public String getCover() {
108                 return cover;
109         }
110
111         public void setCover(String cover) {
112                 this.cover = cover;
113         }
114
115         public String getEpoch() {
116                 return epoch;
117         }
118
119         public void setEpoch(String epoch) {
120                 this.epoch = epoch;
121         }
122
123         public String getHref() {
124                 return href;
125         }
126
127         public void setHref(String href) {
128                 this.href = href;
129         }
130
131         public String getGenre() {
132                 return genre;
133         }
134
135         public void setGenre(String genre) {
136                 this.genre = genre;
137         }
138
139         public String getSlug() {
140                 return slug;
141         }
142
143         public String getCoverColor(){return coverColor;}
144
145         public void setCoverColor(String coverColor){this.coverColor=coverColor;}
146
147         public void setSlug(String slug) {
148                 this.slug = slug;
149         }
150
151         public String getKey() {
152                 return key;
153         }
154
155         public void setKey(String key) {
156                 this.key = key;
157         }
158
159         public String getSortedKey() {
160                 return sortedKey;
161         }
162
163         public void setSortedKey(String sortedKey) {
164                 this.sortedKey = sortedKey;
165         }
166
167         public String getCoverThumb() {
168                 return coverThumb;
169         }
170
171         public void setCoverThumb(String coverThumb) {
172                 this.coverThumb = coverThumb;
173         }
174
175         public String getEbookName() {
176                 return ebookName;
177         }
178
179         public void setEbookName(String ebookName) {
180                 this.ebookName = ebookName;
181         }
182
183         public int getCurrentChapter() {
184                 return currentChapter;
185         }
186
187         public void setCurrentChapter(int currentChapter) {
188                 this.currentChapter = currentChapter;
189         }
190
191         public int getTotalChapters() {
192                 return totalChapters;
193         }
194
195         public void setTotalChapters(int totalChapters) {
196                 this.totalChapters = totalChapters;
197         }
198
199         public String getEbookFileUrl() {
200                 return ebookFileUrl;
201         }
202
203         public void setEbookFileUrl(String ebookFileUrl) {
204                 this.ebookFileUrl = ebookFileUrl;
205         }
206
207         public int getCurrentAudioChapter() {
208                 return currentAudioChapter;
209         }
210
211         public void setCurrentAudioChapter(int currentAudioChapter) {
212                 this.currentAudioChapter = currentAudioChapter;
213         }
214
215         public int getTotalAudioChapters() {
216                 return totalAudioChapters;
217         }
218
219         public void setTotalAudioChapters(int totalAudioChapters) {
220                 this.totalAudioChapters = totalAudioChapters;
221         }
222
223         public List<String> getAudioFileUrls() {
224                 return audioFileUrls;
225         }
226
227         public void setAudioFileUrls(List<String> audioFileUrls) {
228                 this.audioFileUrls = audioFileUrls;
229         }
230
231         public boolean isEbookDownloaded() {
232                 return ebookFileUrl != null;
233         }
234
235         public boolean isAudioDownloaded() {
236                 return audioFileUrls != null && audioFileUrls.size() > 0;
237         }
238
239         public boolean isDeletable() {
240                 return ebookFileUrl != null || (audioFileUrls != null && audioFileUrls.size() > 0);
241         }
242
243         public boolean isLiked() { return liked; }
244
245         public void setLiked(boolean liked) { this.liked = liked; }
246 }