fix null-pointer when switching themes

This commit is contained in:
sk 2023-01-17 00:44:55 +01:00 committed by LucasGGamerM
parent 885b5d781a
commit 4fa641b482
1 changed files with 4 additions and 2 deletions

View File

@ -253,9 +253,11 @@ public class HomeTabFragment extends MastodonToolbarFragment implements Scrollab
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
int toolbarWidth = getToolbar().getWidth();
Toolbar t = getToolbar();
if (t == null) return;
int toolbarWidth = t.getWidth();
if (toolbarWidth == 0) return;
toolbar.getViewTreeObserver().removeOnGlobalLayoutListener(this);
t.getViewTreeObserver().removeOnGlobalLayoutListener(this);
int toolbarFrameWidth = toolbarFrame.getWidth();
int padding = toolbarWidth - toolbarFrameWidth;