From 0c8381e50d4cd4ee756353a3a79c8899f7887e1a Mon Sep 17 00:00:00 2001 From: Vavassor Date: Thu, 20 Jul 2017 21:17:36 -0400 Subject: [PATCH] Fixes a crash when a timeline or thread is backgrounded and brought back with an uninitialized notification or status list. --- .../tusky/adapter/StatusViewHolder.java | 3 +-- .../tusky/fragment/NotificationsFragment.java | 2 +- .../tusky/fragment/TimelineFragment.java | 1 + .../tusky/fragment/ViewThreadFragment.java | 1 + .../keylesspalace/tusky/viewdata/StatusViewData.java | 12 ++++++------ 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/StatusViewHolder.java b/app/src/main/java/com/keylesspalace/tusky/adapter/StatusViewHolder.java index f1de206e..250d133c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/StatusViewHolder.java +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/StatusViewHolder.java @@ -313,9 +313,8 @@ public class StatusViewHolder extends RecyclerView.ViewHolder { } } - private static @DrawableRes - int getLabelIcon(Status.MediaAttachment.Type type) { + private static int getLabelIcon(Status.MediaAttachment.Type type) { switch (type) { default: case IMAGE: diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java index b5fa5401..91f20654 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java @@ -71,7 +71,6 @@ public class NotificationsFragment extends SFragment implements } private SwipeRefreshLayout swipeRefreshLayout; - private LinearLayoutManager layoutManager; private RecyclerView recyclerView; private EndlessOnScrollListener scrollListener; @@ -134,6 +133,7 @@ public class NotificationsFragment extends SFragment implements LocalBroadcastManager.getInstance(context.getApplicationContext()) .registerReceiver(timelineReceiver, TimelineReceiver.getFilter(null)); + notifications.clear(); topLoading = false; topFetches = 0; bottomLoading = false; diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java index 548851bd..0141dd37 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java @@ -159,6 +159,7 @@ public class TimelineFragment extends SFragment implements LocalBroadcastManager.getInstance(context.getApplicationContext()) .registerReceiver(timelineReceiver, TimelineReceiver.getFilter(kind)); + statuses.clear(); topLoading = false; topFetches = 0; bottomLoading = false; diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewThreadFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewThreadFragment.java index 8bc482ef..f41df0a7 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/ViewThreadFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/ViewThreadFragment.java @@ -106,6 +106,7 @@ public class ViewThreadFragment extends SFragment implements adapter.setMediaPreviewEnabled(mediaPreviewEnabled); recyclerView.setAdapter(adapter); + statuses.clear(); thisThreadsStatusId = null; timelineReceiver = new TimelineReceiver(this, this); diff --git a/app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.java b/app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.java index 288769e6..87ff129c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.java +++ b/app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.java @@ -37,7 +37,7 @@ public final class StatusViewData { private final String senderId; private final boolean rebloggingEnabled; - public StatusViewData(String id, Spanned contnet, boolean reblogged, boolean favourited, + public StatusViewData(String id, Spanned content, boolean reblogged, boolean favourited, String spoilerText, Status.Visibility visibility, Status.MediaAttachment[] attachments, String rebloggedByUsername, String rebloggedAvatar, boolean sensitive, boolean isExpanded, @@ -45,7 +45,7 @@ public final class StatusViewData { String avatar, Date createdAt, Status.Mention[] mentions, String senderId, boolean rebloggingEnabled) { this.id = id; - this.content = contnet; + this.content = content; this.reblogged = reblogged; this.favourited = favourited; this.spoilerText = spoilerText; @@ -147,7 +147,7 @@ public final class StatusViewData { public static class Builder { private String id; - private Spanned contnet; + private Spanned content; private boolean reblogged; private boolean favourited; private String spoilerText; @@ -171,7 +171,7 @@ public final class StatusViewData { public Builder(final StatusViewData viewData) { id = viewData.id; - contnet = viewData.content; + content = viewData.content; reblogged = viewData.reblogged; favourited = viewData.favourited; spoilerText = viewData.spoilerText; @@ -197,7 +197,7 @@ public final class StatusViewData { } public Builder setContent(Spanned content) { - this.contnet = content; + this.content = content; return this; } @@ -287,7 +287,7 @@ public final class StatusViewData { } public StatusViewData createStatusViewData() { - return new StatusViewData(id, contnet, reblogged, favourited, spoilerText, visibility, + return new StatusViewData(id, content, reblogged, favourited, spoilerText, visibility, attachments, rebloggedByUsername, rebloggedAvatar, isSensitive, isExpanded, isShowingSensitiveContent, userFullName, nickname, avatar, createdAt, mentions, senderId, rebloggingEnabled);