Added fail safe

This commit is contained in:
M66B 2021-05-20 07:43:43 +02:00
parent 7394c80e4d
commit 3e9ed34c68
1 changed files with 6 additions and 1 deletions

View File

@ -109,6 +109,7 @@ import androidx.cursoradapter.widget.SimpleCursorAdapter;
import androidx.documentfile.provider.DocumentFile;
import androidx.exifinterface.media.ExifInterface;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.Lifecycle;
@ -2054,6 +2055,10 @@ public class FragmentCompose extends FragmentBase {
if (paragraph.second > edit.length())
return;
FragmentActivity activity = getActivity();
if (activity == null)
return;
// Insert translated text
StringBuilder sb = new StringBuilder("\n");
if (paragraph.second == edit.length() ||
@ -2068,7 +2073,7 @@ public class FragmentCompose extends FragmentBase {
int count = prefs.getInt(key, 0);
prefs.edit().putInt(key, count + 1).apply();
getActivity().invalidateOptionsMenu();
activity.invalidateOptionsMenu();
}
@Override