Check internet connection on translate

pull/207/head
M66B 4 years ago
parent 401ded742f
commit c6319a0974

@ -197,6 +197,9 @@ public class DeepL {
} }
public static Translation translate(String text, String target, boolean formality, Context context) throws IOException, JSONException { public static Translation translate(String text, String target, boolean formality, Context context) throws IOException, JSONException {
if (!ConnectionHelper.getNetworkState(context).isConnected())
throw new IllegalArgumentException(context.getString(R.string.title_no_internet));
// https://www.deepl.com/docs-api/translating-text/request/ // https://www.deepl.com/docs-api/translating-text/request/
String request = String request =
"text=" + URLEncoder.encode(text, StandardCharsets.UTF_8.name()) + "text=" + URLEncoder.encode(text, StandardCharsets.UTF_8.name()) +

Loading…
Cancel
Save