avoid null pointer when switching tabs

closes sk22#412
This commit is contained in:
sk 2023-02-06 13:16:17 +01:00
parent e2c907eb10
commit 50029c7f73

View File

@ -662,7 +662,8 @@ public class HomeTabFragment extends MastodonToolbarFragment implements Scrollab
@Override @Override
public SimpleViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { public SimpleViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
FrameLayout tabView = tabViews[viewType % getItemCount()]; 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); tabView.setVisibility(View.VISIBLE);
return new SimpleViewHolder(tabView); return new SimpleViewHolder(tabView);
} }