From bb4a52f03a2121142a117982975c48be3f4425f1 Mon Sep 17 00:00:00 2001 From: sk Date: Thu, 15 Jun 2023 22:44:46 +0200 Subject: [PATCH] fix threads opened from notification --- .../main/java/org/joinmastodon/android/MainActivity.java | 4 +++- .../org/joinmastodon/android/fragments/ThreadFragment.java | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/MainActivity.java b/mastodon/src/main/java/org/joinmastodon/android/MainActivity.java index 67b29e14f..7af4b8fdb 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/MainActivity.java +++ b/mastodon/src/main/java/org/joinmastodon/android/MainActivity.java @@ -123,7 +123,9 @@ public class MainActivity extends FragmentStackActivity implements ProvidesAssis Log.w("MainActivity", x); return; } - UiUtils.showFragmentForNotification(this, notification, accountID, null); + Bundle args = new Bundle(); + args.putBoolean("noTransition", true); + UiUtils.showFragmentForNotification(this, notification, accountID, args); } private void showFragmentForExternalShare(Bundle args) { diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ThreadFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ThreadFragment.java index 063b4fb04..8f53b1c13 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ThreadFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ThreadFragment.java @@ -65,6 +65,7 @@ public class ThreadFragment extends StatusListFragment implements ProvidesAssist data.add(mainStatus); onAppendItems(Collections.singletonList(mainStatus)); setTitle(HtmlParser.parseCustomEmoji(getString(R.string.post_from_user, mainStatus.account.displayName), mainStatus.account.emojis)); + transitionFinished = getArguments().getBoolean("noTransition", false); } @Override @@ -359,7 +360,7 @@ public class ThreadFragment extends StatusListFragment implements ProvidesAssist int nextDisplayItemsIndex = -1, indexOfPreviousDisplayItem = -1; - for (int i = 0; i < displayItems.size(); i++) { + if (ancestry != null) for (int i = 0; i < displayItems.size(); i++) { StatusDisplayItem item = displayItems.get(i); if (repliedToStatus.id.equals(item.parentID)) { // saving the replied-to status' display items index to eventually reach the last one @@ -382,7 +383,7 @@ public class ThreadFragment extends StatusListFragment implements ProvidesAssist int nextDataIndex = data.indexOf(repliedToStatus) + 1; // if replied-to status already has another reply... - if (ancestry.descendantNeighbor != null) { + if (ancestry != null && ancestry.descendantNeighbor != null) { // update the reply's ancestry to remove its ancestoring neighbor (as we did above) ancestryMap.get(ancestry.descendantNeighbor.id).ancestoringNeighbor = null; // make sure the existing reply has a reply line @@ -399,7 +400,7 @@ public class ThreadFragment extends StatusListFragment implements ProvidesAssist } // update replied-to status' ancestry - ancestry.descendantNeighbor = ev.status; + if (ancestry != null) ancestry.descendantNeighbor = ev.status; // add ancestry for newly created status before building its display items ancestryMap.put(ev.status.id, new NeighborAncestryInfo(ev.status, null, repliedToStatus));