Skip to content

Commit

Permalink
Use DownloaderImpl in CheckForNewAppVersionTask
Browse files Browse the repository at this point in the history
  • Loading branch information
wb9688 committed Apr 2, 2020
1 parent fed9197 commit 41061d0
Showing 1 changed file with 3 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.json.JSONException;
import org.json.JSONObject;
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException;
import org.schabi.newpipe.report.ErrorActivity;
import org.schabi.newpipe.report.UserAction;

Expand All @@ -31,11 +32,8 @@
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

/**
* AsyncTask to check if there is a newer version of the NewPipe github apk available or not.
Expand Down Expand Up @@ -150,19 +148,9 @@ protected String doInBackground(final Void... voids) {
}

// Make a network request to get latest NewPipe data.
// FIXME: Use DownloaderImp
if (client == null) {

client = new OkHttpClient.Builder()
.readTimeout(TIMEOUT_PERIOD, TimeUnit.SECONDS).build();
}

Request request = new Request.Builder().url(NEWPIPE_API_URL).build();

try {
Response response = client.newCall(request).execute();
return response.body().string();
} catch (IOException ex) {
return DownloaderImpl.getInstance().get(NEWPIPE_API_URL).responseBody();
} catch (IOException | ReCaptchaException ex) {
// connectivity problems, do not alarm user and fail silently
if (DEBUG) {
Log.w(TAG, Log.getStackTraceString(ex));
Expand Down

0 comments on commit 41061d0

Please sign in to comment.