From 3b9bf6457854024ba4cf4b8ba9600af6ac163750 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 13 Apr 2019 08:46:30 +0200 Subject: [PATCH] Prevent crash --- app/src/main/java/eu/faircode/email/ActivityBase.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivityBase.java b/app/src/main/java/eu/faircode/email/ActivityBase.java index 638a94efa1..ab58484b80 100644 --- a/app/src/main/java/eu/faircode/email/ActivityBase.java +++ b/app/src/main/java/eu/faircode/email/ActivityBase.java @@ -26,6 +26,7 @@ import android.content.SharedPreferences; import android.content.res.Configuration; import android.os.Bundle; import android.view.View; +import android.widget.ScrollView; import java.util.ArrayList; import java.util.Arrays; @@ -137,8 +138,10 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc protected View getVisibleView() { for (Fragment fragment : getSupportFragmentManager().getFragments()) if (fragment.getUserVisibleHint()) { - Log.i("Visible fragment=" + fragment.getClass().getName()); - return fragment.getView(); + View view = fragment.getView(); + Log.i("Visible fragment=" + fragment.getClass().getName() + " view=" + view); + if (view != null && !(view instanceof ScrollView)) // Snackbar cannot be attached to ScrollView + return view; } Log.i("Visible activity=" + this.getClass().getName());