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 0ac580020..26e1c5900 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/model/Poll.java +++ b/mastodon/src/main/java/org/joinmastodon/android/model/Poll.java @@ -13,7 +13,7 @@ public class Poll extends BaseModel{ @RequiredField public String id; public Instant expiresAt; - public boolean expired; + private boolean expired; public boolean multiple; public int votersCount; public boolean voted; @@ -48,6 +48,10 @@ public class Poll extends BaseModel{ '}'; } + public boolean isExpired(){ + return expired || expiresAt.isBefore(Instant.now()); + } + @Parcel public static class Option{ public String title; diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/PollFooterStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/PollFooterStatusDisplayItem.java index 0f493fb93..deffc9b45 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/PollFooterStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/PollFooterStatusDisplayItem.java @@ -38,13 +38,13 @@ public class PollFooterStatusDisplayItem extends StatusDisplayItem{ @Override public void onBind(PollFooterStatusDisplayItem item){ String text=item.parentFragment.getResources().getQuantityString(R.plurals.x_voters, item.poll.votersCount, item.poll.votersCount); - if(item.poll.expiresAt!=null && !item.poll.expired){ + if(item.poll.expiresAt!=null && !item.poll.isExpired()){ text+=" · "+UiUtils.formatTimeLeft(itemView.getContext(), item.poll.expiresAt); - }else if(item.poll.expired){ + }else if(item.poll.isExpired()){ text+=" · "+item.parentFragment.getString(R.string.poll_closed); } this.text.setText(text); - button.setVisibility(item.poll.expired || item.poll.voted || !item.poll.multiple ? View.GONE : View.VISIBLE); + button.setVisibility(item.poll.isExpired() || item.poll.voted || !item.poll.multiple ? View.GONE : View.VISIBLE); button.setEnabled(item.poll.selectedOptions!=null && !item.poll.selectedOptions.isEmpty()); } } 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 af9f6c90c..3c50869c6 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 @@ -33,7 +33,7 @@ public class PollOptionStatusDisplayItem extends StatusDisplayItem{ this.poll=poll; text=HtmlParser.parseCustomEmoji(option.title, poll.emojis); emojiHelper.setText(text); - showResults=poll.expired || poll.voted; + showResults=poll.isExpired() || poll.voted; if(showResults && option.votesCount!=null && poll.votersCount>0){ votesFraction=(float)option.votesCount/(float)poll.votersCount; int mostVotedCount=0;