Use generic bg executor for LT and DeepL

This commit is contained in:
M66B 2023-09-11 16:20:02 +02:00
parent 80d5102364
commit 66d718ffa2
2 changed files with 7 additions and 3 deletions

View File

@ -2756,6 +2756,8 @@ public class FragmentCompose extends FragmentBase {
@Override
protected void onExecuted(Bundle args, DeepL.Translation translation) {
if (etSubject == null)
return;
etSubject.setText(translation.translated_text);
}
@ -2763,7 +2765,7 @@ public class FragmentCompose extends FragmentBase {
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(getParentFragmentManager(), ex, !(ex instanceof IOException));
}
}.serial().execute(FragmentCompose.this, args, "compose:translate");
}.execute(FragmentCompose.this, args, "compose:translate");
} else {
final Pair<Integer, Integer> paragraph = StyleHelper.getParagraph(etBody);
if (paragraph == null)
@ -2890,7 +2892,7 @@ public class FragmentCompose extends FragmentBase {
etBody.setSelection(paragraph.second);
Log.unexpectedError(getParentFragmentManager(), ex, !(ex instanceof IOException));
}
}.serial().execute(FragmentCompose.this, args, "compose:translate");
}.execute(FragmentCompose.this, args, "compose:translate");
}
}
});
@ -2970,7 +2972,7 @@ public class FragmentCompose extends FragmentBase {
Log.unexpectedError(getParentFragmentManager(), exex, false);
}
}
}.serial().execute(this, args, "compose:lt");
}.execute(this, args, "compose:lt");
}
private void onActionRecordAudio() {

View File

@ -409,6 +409,8 @@ public class LanguageTool {
}
static void applySuggestions(EditText etBody, int start, int end, List<Suggestion> suggestions) {
if (etBody == null)
return;
Editable edit = etBody.getText();
if (edit == null)
return;