From 64e50bd8b50520ca2891babadf8cfc50dad7029d Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 2 Jan 2023 15:06:31 +0100 Subject: [PATCH] Fix crashes --- .../fedilab/android/helper/PinnedTimelineHelper.java | 6 ++++++ .../app/fedilab/android/helper/SpannableHelper.java | 3 +++ .../ui/fragment/timeline/FragmentMastodonTimeline.java | 10 ++++++---- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/helper/PinnedTimelineHelper.java b/app/src/main/java/app/fedilab/android/helper/PinnedTimelineHelper.java index 125212d38..f95e42c38 100644 --- a/app/src/main/java/app/fedilab/android/helper/PinnedTimelineHelper.java +++ b/app/src/main/java/app/fedilab/android/helper/PinnedTimelineHelper.java @@ -183,6 +183,12 @@ public class PinnedTimelineHelper { if (extraFeatures) { try { Pinned pinnedAll = new Pinned(activity).getAllPinned(currentAccount); + if (pinnedAll == null) { + pinnedAll = new Pinned(); + pinnedAll.user_id = currentUserID; + pinnedAll.instance = currentInstance; + pinnedAll.pinnedTimelines = new ArrayList<>(); + } boolean createDefaultBubbleAtTop = true; for (PinnedTimeline pinnedTimeline : pinnedAll.pinnedTimelines) { if (pinnedTimeline.type == Timeline.TimeLineEnum.BUBBLE) { diff --git a/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java b/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java index f27a35939..2ddf9a6fa 100644 --- a/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java +++ b/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java @@ -299,6 +299,9 @@ public class SpannableHelper { } int matchEnd = start + newUrl.length(); String finalUrl = url; + if (content.length() < matchEnd) { + matchEnd = content.length(); + } content.setSpan(new LongClickableSpan() { @Override public void onLongClick(View view) { diff --git a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java index fd4543cb2..318de33de 100644 --- a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java +++ b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java @@ -718,10 +718,12 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. timelineParams.remote = true; break; case BUBBLE: - timelineParams.onlyMedia = bubbleTimeline.only_media; - timelineParams.remote = bubbleTimeline.remote; - timelineParams.replyVisibility = bubbleTimeline.reply_visibility; - timelineParams.excludeVisibilities = bubbleTimeline.exclude_visibilities; + if (bubbleTimeline != null) { + timelineParams.onlyMedia = bubbleTimeline.only_media; + timelineParams.remote = bubbleTimeline.remote; + timelineParams.replyVisibility = bubbleTimeline.reply_visibility; + timelineParams.excludeVisibilities = bubbleTimeline.exclude_visibilities; + } break; case LIST: timelineParams.listId = list_id;