From dca68de77eee63f393e35b9d42d2c0c5580f9abc Mon Sep 17 00:00:00 2001 From: FineFindus Date: Thu, 16 Nov 2023 22:23:49 +0100 Subject: [PATCH] fix: button showing wrong text when refreshing --- .../ui/displayitems/PollFooterStatusDisplayItem.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) 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 43a6306c81..8e187417d3 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 @@ -14,7 +14,7 @@ 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 Holder(Activity activity, ViewGroup parent){ 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 void onBind(PollFooterStatusDisplayItem item){ 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); }