From fc67c8204012540c9f835f7e051025d5a7aaf71d Mon Sep 17 00:00:00 2001 From: Grishka Date: Mon, 13 Mar 2023 20:46:29 +0300 Subject: [PATCH] Fix #544 --- .../src/main/java/org/joinmastodon/android/model/Poll.java | 3 +++ .../android/ui/displayitems/PollOptionStatusDisplayItem.java | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/model/Poll.java b/mastodon/src/main/java/org/joinmastodon/android/model/Poll.java index 037a1115b..4430bed62 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/model/Poll.java +++ b/mastodon/src/main/java/org/joinmastodon/android/model/Poll.java @@ -16,6 +16,7 @@ public class Poll extends BaseModel{ private boolean expired; public boolean multiple; public int votersCount; + public int votesCount; public boolean voted; @RequiredField public List ownVotes; @@ -41,10 +42,12 @@ public class Poll extends BaseModel{ ", expired="+expired+ ", multiple="+multiple+ ", votersCount="+votersCount+ + ", votesCount="+votesCount+ ", voted="+voted+ ", ownVotes="+ownVotes+ ", options="+options+ ", emojis="+emojis+ + ", selectedOptions="+selectedOptions+ '}'; } diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/PollOptionStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/PollOptionStatusDisplayItem.java index 3c50869c6..6333f32fe 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/PollOptionStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/PollOptionStatusDisplayItem.java @@ -34,8 +34,9 @@ public class PollOptionStatusDisplayItem extends StatusDisplayItem{ text=HtmlParser.parseCustomEmoji(option.title, poll.emojis); emojiHelper.setText(text); showResults=poll.isExpired() || poll.voted; - if(showResults && option.votesCount!=null && poll.votersCount>0){ - votesFraction=(float)option.votesCount/(float)poll.votersCount; + int total=poll.votersCount>0 ? poll.votersCount : poll.votesCount; + if(showResults && option.votesCount!=null && total>0){ + votesFraction=(float)option.votesCount/(float)total; int mostVotedCount=0; for(Poll.Option opt:poll.options) mostVotedCount=Math.max(mostVotedCount, opt.votesCount);