From 21b07368420a4ad2769a6608e995e20a5010b77e Mon Sep 17 00:00:00 2001 From: sk Date: Fri, 17 Mar 2023 01:28:38 +0100 Subject: [PATCH] fix null pointer exception closes sk22#442 --- .../joinmastodon/android/fragments/NotificationsFragment.java | 2 +- .../org/joinmastodon/android/fragments/ProfileFragment.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsFragment.java index 38b4d9ae6..4500fac60 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsFragment.java @@ -232,7 +232,7 @@ public class NotificationsFragment extends MastodonToolbarFragment implements Sc @Override public SimpleViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType){ FrameLayout view=tabViews[viewType]; - ((ViewGroup)view.getParent()).removeView(view); + if (view.getParent() != null) ((ViewGroup)view.getParent()).removeView(view); view.setVisibility(View.VISIBLE); view.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); return new SimpleViewHolder(view); diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java index e4d087476..648c017c0 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java @@ -1133,7 +1133,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList @Override public SimpleViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType){ FrameLayout view=tabViews[viewType]; - ((ViewGroup)view.getParent()).removeView(view); + if (view.getParent() != null) ((ViewGroup)view.getParent()).removeView(view); view.setVisibility(View.VISIBLE); view.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); return new SimpleViewHolder(view);