parent
2cabe94ba0
commit
62411a563f
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue