diff --git a/app/src/main/java/io/legado/app/lib/webdav/WebDav.kt b/app/src/main/java/io/legado/app/lib/webdav/WebDav.kt index 4ca1966c8..f35e41db3 100644 --- a/app/src/main/java/io/legado/app/lib/webdav/WebDav.kt +++ b/app/src/main/java/io/legado/app/lib/webdav/WebDav.kt @@ -32,7 +32,7 @@ constructor(url: String) { return field } - private val okHttpClient: OkHttpClient = OkHttp.SingletonHelper.okHttpClient + private val okHttpClient: OkHttpClient = OkHttp.okHttpClient val path: String get() = url.toString() @@ -207,7 +207,7 @@ constructor(url: String) { fun upload(localPath: String, contentType: String? = null): Boolean { val file = File(localPath) if (!file.exists()) return false - val mediaType = if (contentType == null) null else contentType.toMediaTypeOrNull() + val mediaType = contentType?.toMediaTypeOrNull() // 务必注意RequestBody不要嵌套,不然上传时内容可能会被追加多余的文件信息 val fileBody = RequestBody.create(mediaType, file) getUrl()?.let { diff --git a/app/src/main/java/io/legado/app/lib/webdav/http/HttpAuth.kt b/app/src/main/java/io/legado/app/lib/webdav/http/HttpAuth.kt index 3a6f31b48..07cab5855 100644 --- a/app/src/main/java/io/legado/app/lib/webdav/http/HttpAuth.kt +++ b/app/src/main/java/io/legado/app/lib/webdav/http/HttpAuth.kt @@ -3,11 +3,6 @@ package io.legado.app.lib.webdav.http object HttpAuth { var auth: Auth? = null - private set - - fun setAuth(user: String, password: String) { - auth = Auth(user, password) - } class Auth internal constructor(val user: String, val pass: String) diff --git a/app/src/main/java/io/legado/app/lib/webdav/http/OkHttp.kt b/app/src/main/java/io/legado/app/lib/webdav/http/OkHttp.kt index f088fc785..6861deb62 100644 --- a/app/src/main/java/io/legado/app/lib/webdav/http/OkHttp.kt +++ b/app/src/main/java/io/legado/app/lib/webdav/http/OkHttp.kt @@ -2,10 +2,6 @@ package io.legado.app.lib.webdav.http import okhttp3.OkHttpClient -class OkHttp private constructor() { - - object SingletonHelper { - val okHttpClient: OkHttpClient = OkHttpClient.Builder().build() - } - -} +object OkHttp { + val okHttpClient: OkHttpClient = OkHttpClient.Builder().build() +} \ No newline at end of file