okhttp3, retrofit2 update

This commit is contained in:
Milos Kozak 2019-12-02 22:35:16 +01:00
parent 644d5ab49a
commit 42401453c6
4 changed files with 18 additions and 17 deletions

View file

@ -300,11 +300,11 @@ dependencies {
// new for tidepool // new for tidepool
implementation 'com.squareup.okhttp3:okhttp:3.10.0' implementation 'com.squareup.okhttp3:okhttp:4.2.2'
implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0' implementation 'com.squareup.okhttp3:logging-interceptor:4.2.2'
implementation "com.squareup.retrofit2:retrofit:2.4.0" implementation "com.squareup.retrofit2:retrofit:2.6.2"
implementation "com.squareup.retrofit2:adapter-rxjava2:2.4.0" implementation "com.squareup.retrofit2:adapter-rxjava2:2.6.2"
implementation "com.squareup.retrofit2:converter-gson:2.4.0" implementation "com.squareup.retrofit2:converter-gson:2.6.2"
} }

View file

@ -19,7 +19,7 @@ class InfoInterceptor(tag: String) : Interceptor {
@Throws(IOException::class) @Throws(IOException::class)
override fun intercept(chain: Interceptor.Chain): Response { override fun intercept(chain: Interceptor.Chain): Response {
val request = chain.request() val request = chain.request()
request?.body()?.let { request.body?.let {
if (L.isEnabled(L.TIDEPOOL)) { if (L.isEnabled(L.TIDEPOOL)) {
log.debug("Interceptor Body size: " + it.contentLength()) log.debug("Interceptor Body size: " + it.contentLength())
val requestBuffer = Buffer() val requestBuffer = Buffer()

View file

@ -14,9 +14,9 @@ import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.OKDialog import info.nightscout.androidaps.utils.OKDialog
import info.nightscout.androidaps.utils.SP import info.nightscout.androidaps.utils.SP
import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.T
import okhttp3.MediaType import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.RequestBody import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.logging.HttpLoggingInterceptor import okhttp3.logging.HttpLoggingInterceptor
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import retrofit2.Retrofit import retrofit2.Retrofit
@ -43,7 +43,7 @@ object TidepoolUploader {
val PUMPTYPE = "Tandem" val PUMPTYPE = "Tandem"
var connectionStatus: ConnectionStatus = TidepoolUploader.ConnectionStatus.DISCONNECTED var connectionStatus: ConnectionStatus = ConnectionStatus.DISCONNECTED
fun getRetrofitInstance(): Retrofit? { fun getRetrofitInstance(): Retrofit? {
if (retrofit == null) { if (retrofit == null) {
@ -75,7 +75,7 @@ object TidepoolUploader {
retrofit = null retrofit = null
if (L.isEnabled(L.TIDEPOOL)) if (L.isEnabled(L.TIDEPOOL))
log.debug("Instance reset") log.debug("Instance reset")
connectionStatus = TidepoolUploader.ConnectionStatus.DISCONNECTED connectionStatus = ConnectionStatus.DISCONNECTED
} }
@Synchronized @Synchronized
@ -197,7 +197,7 @@ object TidepoolUploader {
} }
else -> { else -> {
val body = RequestBody.create(MediaType.parse("application/json"), chunk) val body = chunk.toRequestBody("application/json".toMediaTypeOrNull())
RxBus.send(EventTidepoolStatus(("Uploading"))) RxBus.send(EventTidepoolStatus(("Uploading")))
if (session.service != null && session.token != null && session.datasetReply != null) { if (session.service != null && session.token != null && session.datasetReply != null) {
@ -231,11 +231,11 @@ object TidepoolUploader {
extendWakeLock(60000) extendWakeLock(60000)
val call = session!!.service?.deleteDataSet(session!!.token!!, session!!.datasetReply!!.id!!) val call = session!!.service?.deleteDataSet(session!!.token!!, session!!.datasetReply!!.id!!)
call?.enqueue(TidepoolCallback(session!!, "Delete Dataset", { call?.enqueue(TidepoolCallback(session!!, "Delete Dataset", {
connectionStatus = TidepoolUploader.ConnectionStatus.DISCONNECTED connectionStatus = ConnectionStatus.DISCONNECTED
RxBus.send(EventTidepoolStatus(("Dataset removed OK"))) RxBus.send(EventTidepoolStatus(("Dataset removed OK")))
releaseWakeLock() releaseWakeLock()
}, { }, {
connectionStatus = TidepoolUploader.ConnectionStatus.DISCONNECTED connectionStatus = ConnectionStatus.DISCONNECTED
RxBus.send(EventTidepoolStatus(("Dataset remove FAILED"))) RxBus.send(EventTidepoolStatus(("Dataset remove FAILED")))
releaseWakeLock() releaseWakeLock()
})) }))
@ -255,11 +255,11 @@ object TidepoolUploader {
extendWakeLock(60000) extendWakeLock(60000)
val call = session.service?.deleteAllData(token, userid) val call = session.service?.deleteAllData(token, userid)
call?.enqueue(TidepoolCallback(session, "Delete all data", { call?.enqueue(TidepoolCallback(session, "Delete all data", {
connectionStatus = TidepoolUploader.ConnectionStatus.DISCONNECTED connectionStatus = ConnectionStatus.DISCONNECTED
RxBus.send(EventTidepoolStatus(("All data removed OK"))) RxBus.send(EventTidepoolStatus(("All data removed OK")))
releaseWakeLock() releaseWakeLock()
}, { }, {
connectionStatus = TidepoolUploader.ConnectionStatus.DISCONNECTED connectionStatus = ConnectionStatus.DISCONNECTED
RxBus.send(EventTidepoolStatus(("All data remove FAILED"))) RxBus.send(EventTidepoolStatus(("All data remove FAILED")))
releaseWakeLock() releaseWakeLock()
})) }))

View file

@ -1,8 +1,9 @@
package info.nightscout.androidaps.plugins.general.tidepool.messages package info.nightscout.androidaps.plugins.general.tidepool.messages
import info.nightscout.androidaps.plugins.general.tidepool.utils.GsonInstance import info.nightscout.androidaps.plugins.general.tidepool.utils.GsonInstance
import okhttp3.MediaType import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
open class BaseMessage { open class BaseMessage {
private fun toS(): String { private fun toS(): String {
@ -10,7 +11,7 @@ open class BaseMessage {
} }
fun getBody(): RequestBody { fun getBody(): RequestBody {
return RequestBody.create(MediaType.parse("application/json"), this.toS()) return this.toS().toRequestBody("application/json".toMediaTypeOrNull())
} }
} }