okhttp3, retrofit2 update
This commit is contained in:
parent
644d5ab49a
commit
42401453c6
4 changed files with 18 additions and 17 deletions
|
@ -300,11 +300,11 @@ dependencies {
|
|||
|
||||
|
||||
// new for tidepool
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
|
||||
implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
|
||||
implementation "com.squareup.retrofit2:retrofit:2.4.0"
|
||||
implementation "com.squareup.retrofit2:adapter-rxjava2:2.4.0"
|
||||
implementation "com.squareup.retrofit2:converter-gson:2.4.0"
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.2.2'
|
||||
implementation 'com.squareup.okhttp3:logging-interceptor:4.2.2'
|
||||
implementation "com.squareup.retrofit2:retrofit:2.6.2"
|
||||
implementation "com.squareup.retrofit2:adapter-rxjava2:2.6.2"
|
||||
implementation "com.squareup.retrofit2:converter-gson:2.6.2"
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class InfoInterceptor(tag: String) : Interceptor {
|
|||
@Throws(IOException::class)
|
||||
override fun intercept(chain: Interceptor.Chain): Response {
|
||||
val request = chain.request()
|
||||
request?.body()?.let {
|
||||
request.body?.let {
|
||||
if (L.isEnabled(L.TIDEPOOL)) {
|
||||
log.debug("Interceptor Body size: " + it.contentLength())
|
||||
val requestBuffer = Buffer()
|
||||
|
|
|
@ -14,9 +14,9 @@ import info.nightscout.androidaps.utils.DateUtil
|
|||
import info.nightscout.androidaps.utils.OKDialog
|
||||
import info.nightscout.androidaps.utils.SP
|
||||
import info.nightscout.androidaps.utils.T
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import okhttp3.logging.HttpLoggingInterceptor
|
||||
import org.slf4j.LoggerFactory
|
||||
import retrofit2.Retrofit
|
||||
|
@ -43,7 +43,7 @@ object TidepoolUploader {
|
|||
|
||||
val PUMPTYPE = "Tandem"
|
||||
|
||||
var connectionStatus: ConnectionStatus = TidepoolUploader.ConnectionStatus.DISCONNECTED
|
||||
var connectionStatus: ConnectionStatus = ConnectionStatus.DISCONNECTED
|
||||
|
||||
fun getRetrofitInstance(): Retrofit? {
|
||||
if (retrofit == null) {
|
||||
|
@ -75,7 +75,7 @@ object TidepoolUploader {
|
|||
retrofit = null
|
||||
if (L.isEnabled(L.TIDEPOOL))
|
||||
log.debug("Instance reset")
|
||||
connectionStatus = TidepoolUploader.ConnectionStatus.DISCONNECTED
|
||||
connectionStatus = ConnectionStatus.DISCONNECTED
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
|
@ -197,7 +197,7 @@ object TidepoolUploader {
|
|||
}
|
||||
|
||||
else -> {
|
||||
val body = RequestBody.create(MediaType.parse("application/json"), chunk)
|
||||
val body = chunk.toRequestBody("application/json".toMediaTypeOrNull())
|
||||
|
||||
RxBus.send(EventTidepoolStatus(("Uploading")))
|
||||
if (session.service != null && session.token != null && session.datasetReply != null) {
|
||||
|
@ -231,11 +231,11 @@ object TidepoolUploader {
|
|||
extendWakeLock(60000)
|
||||
val call = session!!.service?.deleteDataSet(session!!.token!!, session!!.datasetReply!!.id!!)
|
||||
call?.enqueue(TidepoolCallback(session!!, "Delete Dataset", {
|
||||
connectionStatus = TidepoolUploader.ConnectionStatus.DISCONNECTED
|
||||
connectionStatus = ConnectionStatus.DISCONNECTED
|
||||
RxBus.send(EventTidepoolStatus(("Dataset removed OK")))
|
||||
releaseWakeLock()
|
||||
}, {
|
||||
connectionStatus = TidepoolUploader.ConnectionStatus.DISCONNECTED
|
||||
connectionStatus = ConnectionStatus.DISCONNECTED
|
||||
RxBus.send(EventTidepoolStatus(("Dataset remove FAILED")))
|
||||
releaseWakeLock()
|
||||
}))
|
||||
|
@ -255,11 +255,11 @@ object TidepoolUploader {
|
|||
extendWakeLock(60000)
|
||||
val call = session.service?.deleteAllData(token, userid)
|
||||
call?.enqueue(TidepoolCallback(session, "Delete all data", {
|
||||
connectionStatus = TidepoolUploader.ConnectionStatus.DISCONNECTED
|
||||
connectionStatus = ConnectionStatus.DISCONNECTED
|
||||
RxBus.send(EventTidepoolStatus(("All data removed OK")))
|
||||
releaseWakeLock()
|
||||
}, {
|
||||
connectionStatus = TidepoolUploader.ConnectionStatus.DISCONNECTED
|
||||
connectionStatus = ConnectionStatus.DISCONNECTED
|
||||
RxBus.send(EventTidepoolStatus(("All data remove FAILED")))
|
||||
releaseWakeLock()
|
||||
}))
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package info.nightscout.androidaps.plugins.general.tidepool.messages
|
||||
|
||||
import info.nightscout.androidaps.plugins.general.tidepool.utils.GsonInstance
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
|
||||
open class BaseMessage {
|
||||
private fun toS(): String {
|
||||
|
@ -10,7 +11,7 @@ open class BaseMessage {
|
|||
}
|
||||
|
||||
fun getBody(): RequestBody {
|
||||
return RequestBody.create(MediaType.parse("application/json"), this.toS())
|
||||
return this.toS().toRequestBody("application/json".toMediaTypeOrNull())
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue