Fix OkHttp deprecations (#6979)

This commit is contained in:
Taco 2024-03-10 01:55:35 -05:00 committed by GitHub
parent 48e8197e3f
commit f1fe1b573f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 10 additions and 12 deletions

View File

@ -28,9 +28,6 @@
public *;
}
# for okhttp
-dontwarn okhttp3.**
# android-iconify
-keep class com.joanzapata.** { *; }

View File

@ -53,6 +53,7 @@ import de.danoeh.antennapod.model.playback.Playable;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import okhttp3.Call;
import java.io.File;
import java.util.ArrayList;
@ -232,7 +233,7 @@ public class ExoPlayerWrapper {
throws IllegalArgumentException, IllegalStateException {
Log.d(TAG, "setDataSource: " + s);
final OkHttpDataSource.Factory httpDataSourceFactory =
new OkHttpDataSource.Factory((okhttp3.Call.Factory) AntennapodHttpClient.getHttpClient())
new OkHttpDataSource.Factory((Call.Factory) AntennapodHttpClient.getHttpClient())
.setUserAgent(ClientConfig.USER_AGENT);
if (!TextUtils.isEmpty(user) && !TextUtils.isEmpty(password)) {

View File

@ -157,7 +157,7 @@ public class GpodnetService implements ISyncService {
} else {
content = "";
}
RequestBody body = RequestBody.create(JSON, content);
RequestBody body = RequestBody.create(content, JSON);
Request.Builder request = new Request.Builder().post(body).url(url);
executeRequest(request);
} catch (JSONException | MalformedURLException | URISyntaxException e) {
@ -190,7 +190,7 @@ public class GpodnetService implements ISyncService {
requestObject.put("add", new JSONArray(added));
requestObject.put("remove", new JSONArray(removed));
RequestBody body = RequestBody.create(JSON, requestObject.toString());
RequestBody body = RequestBody.create(requestObject.toString(), JSON);
Request.Builder request = new Request.Builder().post(body).url(url);
final String response = executeRequest(request);
@ -272,7 +272,7 @@ public class GpodnetService implements ISyncService {
}
}
RequestBody body = RequestBody.create(JSON, list.toString());
RequestBody body = RequestBody.create(list.toString(), JSON);
Request.Builder request = new Request.Builder().post(body).url(url);
final String response = executeRequest(request);
@ -330,7 +330,7 @@ public class GpodnetService implements ISyncService {
e.printStackTrace();
throw new GpodnetServiceException(e);
}
RequestBody requestBody = RequestBody.create(TEXT, "");
RequestBody requestBody = RequestBody.create("", TEXT);
Request request = new Request.Builder().url(url).post(requestBody).build();
try {
String credential = Credentials.basic(username, password, Charset.forName("UTF-8"));

View File

@ -117,7 +117,7 @@ public class NextcloudLoginFlow {
private JSONObject doRequest(URL url, String bodyContent) throws IOException, JSONException {
RequestBody requestBody = RequestBody.create(
MediaType.get("application/x-www-form-urlencoded"), bodyContent);
bodyContent, MediaType.get("application/x-www-form-urlencoded"));
Request request = new Request.Builder().url(url).method("POST", requestBody).build();
Response response = httpClient.newCall(request).execute();
if (response.code() != 200) {

View File

@ -71,7 +71,7 @@ public class NextcloudSyncService implements ISyncService {
requestObject.put("add", new JSONArray(addedFeeds));
requestObject.put("remove", new JSONArray(removedFeeds));
RequestBody requestBody = RequestBody.create(
MediaType.get("application/json"), requestObject.toString());
requestObject.toString(), MediaType.get("application/json"));
performRequest(url, "POST", requestBody);
} catch (Exception e) {
e.printStackTrace();
@ -121,7 +121,7 @@ public class NextcloudSyncService implements ISyncService {
}
HttpUrl.Builder url = makeUrl("/index.php/apps/gpoddersync/episode_action/create");
RequestBody requestBody = RequestBody.create(
MediaType.get("application/json"), list.toString());
list.toString(), MediaType.get("application/json"));
performRequest(url, "POST", requestBody);
} catch (Exception e) {
e.printStackTrace();

View File

@ -104,7 +104,7 @@ class ApOkHttpUrlLoader implements ModelLoader<String, InputStream> {
.protocol(Protocol.HTTP_2)
.code(420)
.message("Policy Not Fulfilled")
.body(ResponseBody.create(null, new byte[0]))
.body(ResponseBody.create(new byte[0], null))
.request(chain.request())
.build();
}