From 50029c7f7372f14149b686feebc3df05cee92736 Mon Sep 17 00:00:00 2001 From: sk Date: Mon, 6 Feb 2023 13:16:17 +0100 Subject: [PATCH] avoid null pointer when switching tabs closes sk22#412 --- .../org/joinmastodon/android/fragments/HomeTabFragment.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTabFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTabFragment.java index ebabad810..37ce0e002 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTabFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTabFragment.java @@ -662,7 +662,8 @@ public class HomeTabFragment extends MastodonToolbarFragment implements Scrollab @Override public SimpleViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { FrameLayout tabView = tabViews[viewType % getItemCount()]; - ((ViewGroup)tabView.getParent()).removeView(tabView); + ViewGroup tabParent = (ViewGroup) tabView.getParent(); + if (tabParent != null) tabParent.removeView(tabView); tabView.setVisibility(View.VISIBLE); return new SimpleViewHolder(tabView); }