fedilab-Android-App/app/src/main/java/app/fedilab/android/client/Entities/Poll.java

178 lines
4.7 KiB
Java
Raw Normal View History

2019-03-23 17:23:02 +01:00
/* Copyright 2019 Thomas Schneider
*
2019-05-18 11:10:30 +02:00
* This file is a part of Fedilab
2019-03-23 17:23:02 +01:00
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
2019-05-18 11:10:30 +02:00
* Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
2019-03-23 17:23:02 +01:00
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
2019-05-18 11:10:30 +02:00
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
2019-03-23 17:23:02 +01:00
* see <http://www.gnu.org/licenses>. */
2019-05-18 11:10:30 +02:00
package app.fedilab.android.client.Entities;
2019-03-23 17:23:02 +01:00
2019-03-24 16:38:12 +01:00
2019-03-23 17:23:02 +01:00
import android.os.Parcel;
import android.os.Parcelable;
2020-04-09 14:09:43 +02:00
import java.util.ArrayList;
2019-03-23 17:23:02 +01:00
import java.util.Date;
import java.util.List;
2020-05-07 16:16:54 +02:00
@SuppressWarnings("unused")
2019-03-23 17:23:02 +01:00
public class Poll implements Parcelable {
2020-04-09 18:57:12 +02:00
public static final Creator<Poll> CREATOR = new Creator<Poll>() {
@Override
public Poll createFromParcel(Parcel source) {
return new Poll(source);
}
@Override
public Poll[] newArray(int size) {
return new Poll[size];
}
};
2019-03-23 17:23:02 +01:00
private String id;
private Date expires_at;
2019-03-24 16:38:12 +01:00
private int expires_in;
2019-03-23 17:23:02 +01:00
private boolean expired;
private boolean multiple;
private int votes_count;
2019-11-19 18:11:49 +01:00
private int voters_count;
2019-03-23 17:23:02 +01:00
private boolean voted;
private List<PollOptions> optionsList;
2020-04-08 17:42:28 +02:00
private List<Emojis> emojis;
2020-04-09 14:09:43 +02:00
private List<Integer> own_votes;
2019-03-23 17:23:02 +01:00
2019-03-24 16:38:12 +01:00
public Poll() {
}
2020-04-09 18:57:12 +02:00
protected Poll(Parcel in) {
this.id = in.readString();
long tmpExpires_at = in.readLong();
this.expires_at = tmpExpires_at == -1 ? null : new Date(tmpExpires_at);
this.expires_in = in.readInt();
this.expired = in.readByte() != 0;
this.multiple = in.readByte() != 0;
this.votes_count = in.readInt();
this.voters_count = in.readInt();
this.voted = in.readByte() != 0;
this.optionsList = in.createTypedArrayList(PollOptions.CREATOR);
this.emojis = in.createTypedArrayList(Emojis.CREATOR);
this.own_votes = new ArrayList<>();
in.readList(this.own_votes, Integer.class.getClassLoader());
}
2019-03-24 16:38:12 +01:00
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
2019-03-23 17:23:02 +01:00
public Date getExpires_at() {
return expires_at;
}
public void setExpires_at(Date expires_at) {
this.expires_at = expires_at;
}
public boolean isExpired() {
return expired;
}
public void setExpired(boolean expired) {
this.expired = expired;
}
public boolean isMultiple() {
return multiple;
}
public void setMultiple(boolean multiple) {
this.multiple = multiple;
}
public int getVotes_count() {
return votes_count;
}
public void setVotes_count(int votes_count) {
this.votes_count = votes_count;
}
public boolean isVoted() {
return voted;
}
public void setVoted(boolean voted) {
this.voted = voted;
}
public List<PollOptions> getOptionsList() {
return optionsList;
}
public void setOptionsList(List<PollOptions> optionsList) {
this.optionsList = optionsList;
}
2019-03-24 16:38:12 +01:00
public int getExpires_in() {
return expires_in;
}
2019-03-23 17:23:02 +01:00
2019-03-24 16:38:12 +01:00
public void setExpires_in(int expires_in) {
this.expires_in = expires_in;
2019-03-23 17:23:02 +01:00
}
2020-04-09 14:09:43 +02:00
public int getVoters_count() {
return voters_count;
}
public void setVoters_count(int voters_count) {
this.voters_count = voters_count;
}
public List<Emojis> getEmojis() {
return emojis;
}
public void setEmojis(List<Emojis> emojis) {
this.emojis = emojis;
}
public List<Integer> getOwn_votes() {
return own_votes;
}
public void setOwn_votes(List<Integer> own_votes) {
this.own_votes = own_votes;
}
2019-03-23 17:23:02 +01:00
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.id);
dest.writeLong(this.expires_at != null ? this.expires_at.getTime() : -1);
2019-03-24 16:38:12 +01:00
dest.writeInt(this.expires_in);
2019-03-23 17:23:02 +01:00
dest.writeByte(this.expired ? (byte) 1 : (byte) 0);
dest.writeByte(this.multiple ? (byte) 1 : (byte) 0);
dest.writeInt(this.votes_count);
2019-11-21 19:07:58 +01:00
dest.writeInt(this.voters_count);
2019-03-23 17:23:02 +01:00
dest.writeByte(this.voted ? (byte) 1 : (byte) 0);
2019-03-24 16:38:12 +01:00
dest.writeTypedList(this.optionsList);
2020-04-08 17:42:28 +02:00
dest.writeTypedList(this.emojis);
2020-04-09 14:09:43 +02:00
dest.writeList(this.own_votes);
2019-03-23 17:23:02 +01:00
}
}