From 907472403d2b0eccf308b976ff6684e87a137ebf Mon Sep 17 00:00:00 2001 From: len Date: Thu, 1 Dec 2016 19:36:58 +0100 Subject: [PATCH] Upgrade okhttp --- app/build.gradle | 4 ++-- .../eu/kanade/tachiyomi/data/network/OkHttpExtensions.kt | 7 +------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index b79661355..5ad21b6f7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -120,7 +120,7 @@ dependencies { compile 'com.github.pwittchen:reactivenetwork:0.6.0' // Network client - compile "com.squareup.okhttp3:okhttp:3.4.2" + compile "com.squareup.okhttp3:okhttp:3.5.0" compile 'com.squareup.okio:okio:1.11.0' // REST @@ -148,7 +148,7 @@ dependencies { // Job scheduling compile 'com.evernote:android-job:1.1.3' - compile 'com.google.android.gms:play-services-gcm:10.0.0' + compile 'com.google.android.gms:play-services-gcm:10.0.1' // Changelog compile 'com.github.gabrielemariotti.changeloglib:changelog:2.1.0' diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/network/OkHttpExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/data/network/OkHttpExtensions.kt index 3e8ab812b..aa0d8d6ad 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/network/OkHttpExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/network/OkHttpExtensions.kt @@ -12,12 +12,7 @@ import java.util.concurrent.atomic.AtomicBoolean fun Call.asObservable(): Observable { return Observable.create { subscriber -> // Since Call is a one-shot type, clone it for each new subscriber. - val call = if (!isExecuted) this else { - // TODO use clone method in OkHttp 3.5 - val field = javaClass.getDeclaredField("client").apply { isAccessible = true } - val client = field.get(this) as OkHttpClient - client.newCall(request()) - } + val call = clone() // Wrap the call in a helper which handles both unsubscription and backpressure. val requestArbiter = object : AtomicBoolean(), Producer, Subscription {