Prevent crash

This commit is contained in:
M66B 2018-12-29 08:20:09 +00:00
parent 9221de9f28
commit 21242a4e1a
2 changed files with 20 additions and 14 deletions

View File

@ -20,6 +20,7 @@ package eu.faircode.email;
*/
import android.Manifest;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.ClipboardManager;
import android.content.Context;
@ -524,13 +525,15 @@ public class FragmentCompose extends FragmentEx {
}
private void check() {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
checkInternet();
}
});
Activity activity = getActivity();
if (activity != null)
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
checkInternet();
}
});
}
};

View File

@ -19,6 +19,7 @@ package eu.faircode.email;
Copyright 2018 by Marcel Bokhorst (M66B)
*/
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@ -1396,13 +1397,15 @@ public class FragmentMessages extends FragmentEx {
}
private void check() {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
adapter.checkInternet();
}
});
Activity activity = getActivity();
if (activity != null)
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
adapter.checkInternet();
}
});
}
};