diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/classes/Poll.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/classes/Poll.kt index 9791a8879..d5ce5ef1b 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/classes/Poll.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/classes/Poll.kt @@ -47,6 +47,13 @@ class Poll { @Expose var isVisible : Boolean = false + override fun equals(other: Any?): Boolean { + return other is Poll && this.id == other.id && this.totalVotes == other.totalVotes + && this.question == other.question && this.options.size == other.options.size + && this.options.containsAll(other.options) && other.options.containsAll(this.options) + } + + //@Expose //var homeAdapter : HomeAdapter? = null @@ -72,6 +79,21 @@ class Poll { //gui?.notifyDataSetChanged() } + override fun hashCode(): Int { + var result = id ?: 0 + result = 31 * result + (clubCode?.hashCode() ?: 0) + result = 31 * result + (question?.hashCode() ?: 0) + result = 31 * result + (createdDate?.hashCode() ?: 0) + result = 31 * result + (startDate?.hashCode() ?: 0) + result = 31 * result + (expireDate?.hashCode() ?: 0) + result = 31 * result + multiselect.hashCode() + result = 31 * result + (clubComment?.hashCode() ?: 0) + result = 31 * result + options.hashCode() + result = 31 * result + totalVotes + result = 31 * result + isVisible.hashCode() + return result + } + // Device id + poll id -> hash -> id } \ No newline at end of file diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/classes/PollOption.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/classes/PollOption.kt index 58c229447..0602055a2 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/classes/PollOption.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/classes/PollOption.kt @@ -24,4 +24,20 @@ class PollOption { var selected : Boolean = false var isVisible : Boolean = false + override fun equals(other: Any?): Boolean { + return other is PollOption && this.choice == other.choice && this.id == other.id + && this.voteCount == other.voteCount + } + + override fun hashCode(): Int { + var result = id ?: 0 + result = 31 * result + (poll ?: 0) + result = 31 * result + (choice?.hashCode() ?: 0) + result = 31 * result + voteCount + result = 31 * result + selected.hashCode() + result = 31 * result + isVisible.hashCode() + return result + } + + } \ No newline at end of file