From 096dc6e98cf87582ab212687be924e8988a20cd5 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 2 Feb 2024 18:28:33 +0100 Subject: [PATCH] Fix a crash with back button --- .../java/app/fedilab/android/mastodon/helper/Helper.java | 5 ++++- .../ui/fragment/timeline/FragmentMastodonTimeline.java | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java b/app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java index 25e4114d..eb80cfc3 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java +++ b/app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java @@ -909,7 +909,10 @@ public class Helper { if (args != null) fragment.setArguments(args); ft = fragmentManager.beginTransaction(); ft.add(containerViewId, fragment, tag); - if (backStackName != null) ft.addToBackStack(backStackName); + if (backStackName != null) { + ft = fragmentManager.beginTransaction(); + ft.addToBackStack(backStackName); + } if (!fragmentManager.isDestroyed()) { ft.commit(); } diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java index 13d5c881..0d201729 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/timeline/FragmentMastodonTimeline.java @@ -1259,7 +1259,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. if (show_pinned) { //Fetch pinned statuses to display them at the top accountsVM.getAccountStatuses(currentInstance, MainActivity.currentToken, accountId, null, null, null, null, null, false, true, MastodonHelper.statusesPerCall(requireActivity())) - .observe(getViewLifecycleOwner(), pinnedStatuses -> accountsVM.getAccountStatuses(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, accountTimeline.id, null, null, null, exclude_replies, exclude_reblogs, media_only, false, MastodonHelper.statusesPerCall(requireActivity())) + .observe(getViewLifecycleOwner(), pinnedStatuses -> accountsVM.getAccountStatuses(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, accountId, null, null, null, exclude_replies, exclude_reblogs, media_only, false, MastodonHelper.statusesPerCall(requireActivity())) .observe(getViewLifecycleOwner(), otherStatuses -> { if (otherStatuses != null && otherStatuses.statuses != null && pinnedStatuses != null && pinnedStatuses.statuses != null) { for (Status status : pinnedStatuses.statuses) {