From cdcc428e863e2edffa596298713fd1b7d4ebd7b8 Mon Sep 17 00:00:00 2001 From: LucasGGamerM Date: Wed, 29 May 2024 15:24:59 -0300 Subject: [PATCH] fix(#421): make out of screen poll items update when clicking the "Show results" button --- .../fragments/BaseStatusListFragment.java | 34 ++++++++++++------- .../PollOptionStatusDisplayItem.java | 8 ++++- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java index 60f351dbb..7f4f5b378 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java @@ -28,9 +28,6 @@ import org.joinmastodon.android.api.requests.accounts.GetAccountRelationships; import org.joinmastodon.android.api.requests.polls.SubmitPollVote; import org.joinmastodon.android.api.requests.statuses.AkkomaTranslateStatus; import org.joinmastodon.android.api.requests.statuses.TranslateStatus; -import org.joinmastodon.android.api.session.AccountLocalPreferences; -import org.joinmastodon.android.api.session.AccountSessionManager; -import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.events.PollUpdatedEvent; import org.joinmastodon.android.model.Account; @@ -70,7 +67,6 @@ import org.joinmastodon.android.utils.TypedObjectPool; import java.time.Instant; import java.time.temporal.ChronoUnit; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Locale; @@ -79,14 +75,9 @@ import java.util.Set; import java.util.function.Consumer; import java.util.stream.Collectors; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.recyclerview.widget.RecyclerView; - import me.grishka.appkit.Nav; import me.grishka.appkit.api.Callback; import me.grishka.appkit.api.ErrorResponse; -import me.grishka.appkit.fragments.BaseRecyclerFragment; import me.grishka.appkit.imageloader.ImageLoaderRecyclerAdapter; import me.grishka.appkit.imageloader.ImageLoaderViewHolder; import me.grishka.appkit.imageloader.requests.ImageLoaderRequest; @@ -664,11 +655,30 @@ public abstract class BaseStatusListFragment exten } public void onPollViewResultsButtonClick(PollFooterStatusDisplayItem.Holder holder, boolean shown){ - for(int i=0;i pollItems=displayItems.subList(firstOptionIndex, footerIndex+1); + + for(StatusDisplayItem item:pollItems){ + if (item instanceof PollOptionStatusDisplayItem) { + ((PollOptionStatusDisplayItem) item).isAnimating=true; + ((PollOptionStatusDisplayItem) item).showResults=shown; + adapter.notifyItemRangeChanged(firstOptionIndex, pollItems.size()); + } + } } protected void submitPollVote(String parentID, String pollID, List choices){ 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 6b59255a3..ee06e111f 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 @@ -32,7 +32,8 @@ public class PollOptionStatusDisplayItem extends StatusDisplayItem{ private CharSequence translatedText; public final Poll.Option option; private CustomEmojiHelper emojiHelper=new CustomEmojiHelper(); - private boolean showResults; + public boolean showResults; + public boolean isAnimating; private float votesFraction; // 0..1 private boolean isMostVoted; private final int optionIndex; @@ -125,6 +126,11 @@ public class PollOptionStatusDisplayItem extends StatusDisplayItem{ } text.setTextColor(UiUtils.getThemeColor(itemView.getContext(), android.R.attr.textColorPrimary)); percent.setTextColor(UiUtils.getThemeColor(itemView.getContext(), R.attr.colorM3OnSecondaryContainer)); + + if (item.isAnimating) { + showResults(item.showResults); + item.isAnimating= false; + } } @Override