fix: button showing wrong text when refreshing

This commit is contained in:
FineFindus 2023-11-16 22:23:49 +01:00
parent 0ef879ebd3
commit dca68de77e
No known key found for this signature in database
GPG Key ID: 64873EE210FF8E6B
1 changed files with 3 additions and 7 deletions

View File

@ -14,7 +14,7 @@ import org.joinmastodon.android.ui.utils.UiUtils;
public class PollFooterStatusDisplayItem extends StatusDisplayItem{
public final Poll poll;
public boolean resultsVisible = false;
public boolean resultsVisible=false;
public PollFooterStatusDisplayItem(String parentID, BaseStatusListFragment parentFragment, Poll poll){
super(parentID, parentFragment);
@ -39,8 +39,7 @@ public class PollFooterStatusDisplayItem extends StatusDisplayItem{
resultsButton.setOnClickListener(v-> {
item.resultsVisible = !item.resultsVisible;
item.parentFragment.onPollViewResultsButtonClick(this, item.resultsVisible);
resultsButton.setText(item.resultsVisible ? R.string.sk_poll_view : R.string.sk_poll_results);
setVoteButtonEnabled();
rebind();
});
}
@ -56,10 +55,7 @@ public class PollFooterStatusDisplayItem extends StatusDisplayItem{
text+=" "+sep+" "+item.parentFragment.getString(R.string.poll_closed);
}
this.text.setText(text);
setVoteButtonEnabled();
}
private void setVoteButtonEnabled() {
resultsButton.setText(item.resultsVisible ? R.string.sk_poll_view : R.string.sk_poll_results);
voteButton.setVisibility(item.poll.isExpired() || item.poll.voted || (!item.poll.multiple && !GlobalUserPreferences.voteButtonForSingleChoice) ? View.GONE : View.VISIBLE);
voteButton.setEnabled(item.poll.selectedOptions!=null && !item.poll.selectedOptions.isEmpty() && !item.resultsVisible);
}