fix compatibility with old android releases
This commit is contained in:
+2
-2
@@ -489,7 +489,7 @@ class GeckoAddonsApiImpl(private val context: Context) : GeckoAddonsApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val responseBody = response.body.useStream { stream ->
|
val responseBody = response.body.useStream { stream ->
|
||||||
String(stream.readAllBytes(), Charsets.UTF_8)
|
String(stream.readBytes(), Charsets.UTF_8)
|
||||||
}
|
}
|
||||||
val json = JSONObject(responseBody)
|
val json = JSONObject(responseBody)
|
||||||
val currentVersion = json.optJSONObject("current_version") ?: return null
|
val currentVersion = json.optJSONObject("current_version") ?: return null
|
||||||
@@ -564,7 +564,7 @@ class GeckoAddonsApiImpl(private val context: Context) : GeckoAddonsApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val body = response.body.useStream { stream ->
|
val body = response.body.useStream { stream ->
|
||||||
String(stream.readAllBytes(), Charsets.UTF_8)
|
String(stream.readBytes(), Charsets.UTF_8)
|
||||||
}
|
}
|
||||||
val json = JSONObject(body)
|
val json = JSONObject(body)
|
||||||
val results = json.optJSONArray("results") ?: return emptyList()
|
val results = json.optJSONArray("results") ?: return emptyList()
|
||||||
|
|||||||
+1
-1
@@ -83,7 +83,7 @@ class GeckoFetchApiImpl : GeckoFetchApi {
|
|||||||
GeckoFetchResponse(
|
GeckoFetchResponse(
|
||||||
url = response.url,
|
url = response.url,
|
||||||
status = response.status.toLong(),
|
status = response.status.toLong(),
|
||||||
body = response.body.useStream { stream -> stream.readAllBytes() },
|
body = response.body.useStream { stream -> stream.readBytes() },
|
||||||
headers = response.headers.map { it -> GeckoHeader(it.name, it.value) }
|
headers = response.headers.map { it -> GeckoHeader(it.name, it.value) }
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user