diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt index 7b1488c96..ad96e781c 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt @@ -13,9 +13,8 @@ import io.legado.app.help.http.api.HttpGetApi import io.legado.app.help.http.api.HttpPostApi import io.legado.app.utils.* import okhttp3.FormBody -import okhttp3.MediaType.Companion.toMediaTypeOrNull +import okhttp3.MediaType import okhttp3.RequestBody -import okhttp3.RequestBody.Companion.toRequestBody import retrofit2.Call import java.net.URLEncoder import java.util.* @@ -40,7 +39,7 @@ class AnalyzeUrl( ) : JsExtensions { companion object { private val pagePattern = Pattern.compile("<(.*?)>") - private val jsonType = "application/json; charset=utf-8".toMediaTypeOrNull() + private val jsonType = MediaType.parse("application/json; charset=utf-8") } private var baseUrl: String = "" @@ -182,7 +181,7 @@ class AnalyzeUrl( RequestMethod.POST -> { bodyTxt?.let { if (it.isJson()) { - body = it.toRequestBody(jsonType) + body = RequestBody.create(jsonType, it) } else { analyzeFields(it) } diff --git a/app/src/main/java/io/legado/app/ui/filechooser/utils/ConvertUtils.kt b/app/src/main/java/io/legado/app/ui/filechooser/utils/ConvertUtils.kt index 25ad9d56b..f07371518 100644 --- a/app/src/main/java/io/legado/app/ui/filechooser/utils/ConvertUtils.kt +++ b/app/src/main/java/io/legado/app/ui/filechooser/utils/ConvertUtils.kt @@ -5,7 +5,6 @@ import android.graphics.Bitmap import android.graphics.BitmapFactory import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.Drawable -import okhttp3.internal.and import java.io.BufferedReader import java.io.IOException import java.io.InputStream @@ -36,7 +35,7 @@ object ConvertUtils { var abyte: Byte for (i in bytes.indices) { abyte = bytes[i] - result += abyte and 0xFF shl 8 * i + result += (abyte.toInt() and 0xFF).shl(8 * i) } return result } diff --git a/app/src/main/java/io/legado/app/utils/NetworkUtils.kt b/app/src/main/java/io/legado/app/utils/NetworkUtils.kt index 0c59f05a3..b706a8d5e 100644 --- a/app/src/main/java/io/legado/app/utils/NetworkUtils.kt +++ b/app/src/main/java/io/legado/app/utils/NetworkUtils.kt @@ -11,9 +11,9 @@ import java.util.regex.Pattern @Suppress("unused") object NetworkUtils { fun getUrl(response: Response<*>): String { - val networkResponse = response.raw().networkResponse - return networkResponse?.request?.url?.toString() - ?: response.raw().request.url.toString() + val networkResponse = response.raw().networkResponse() + return networkResponse?.request()?.url()?.toString() + ?: response.raw().request().url().toString() } private val notNeedEncoding: BitSet by lazy {