diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/FollowRequestsListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/FollowRequestsListFragment.java index bd9ff0a2b..8f2b35fcf 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/FollowRequestsListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/FollowRequestsListFragment.java @@ -302,7 +302,7 @@ public class FollowRequestsListFragment extends BaseRecyclerFragment adapter = getBindingAdapter(); if (!rel.requested && !rel.followedBy && adapter != null) { data.remove(item); - adapter.notifyItemRemoved(getBindingAdapterPosition()); + adapter.notifyItemRemoved(getLayoutPosition()); } else { rebind(); } diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/AccountCardStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/AccountCardStatusDisplayItem.java index f71fb8399..d51beca74 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/AccountCardStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/AccountCardStatusDisplayItem.java @@ -12,6 +12,8 @@ import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.TextView; +import androidx.recyclerview.widget.RecyclerView; + import org.joinmastodon.android.R; import org.joinmastodon.android.fragments.BaseStatusListFragment; import org.joinmastodon.android.model.Account; @@ -23,7 +25,9 @@ import org.joinmastodon.android.ui.utils.CustomEmojiHelper; import org.joinmastodon.android.ui.utils.UiUtils; import org.joinmastodon.android.ui.views.ProgressBarButton; +import java.util.ArrayList; import java.util.Collections; +import java.util.List; import me.grishka.appkit.imageloader.ImageLoaderViewHolder; import me.grishka.appkit.imageloader.requests.ImageLoaderRequest; @@ -154,10 +158,18 @@ public class AccountCardStatusDisplayItem extends StatusDisplayItem{ private void onFollowRequestButtonClick(View v) { itemView.setHasTransientState(true); - UiUtils.handleFollowRequest((Activity) v.getContext(), item.account, item.parentFragment.getAccountID(), item.notification.id , v == acceptButton, relationship, rel -> { + UiUtils.handleFollowRequest((Activity) v.getContext(), item.account, item.parentFragment.getAccountID(), null, v == acceptButton, relationship, rel -> { itemView.setHasTransientState(false); item.parentFragment.putRelationship(item.account.id, rel); - rebind(); + RecyclerView.Adapter adapter = getBindingAdapter(); + if (!rel.requested && !rel.followedBy && adapter != null) { + int index = item.parentFragment.getDisplayItems().indexOf(item); + item.parentFragment.getDisplayItems().remove(index); + item.parentFragment.getDisplayItems().remove(index - 1); + adapter.notifyItemRangeRemoved(getLayoutPosition()-1, 2); + } else { + rebind(); + } }); }