Use generic bg executor for LT and DeepL

pull/214/head
M66B 1 year ago
parent 80d5102364
commit 66d718ffa2

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

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

Loading…
Cancel
Save