From 8767a5b9502ee226bb71b7aa72b6d7ec85216521 Mon Sep 17 00:00:00 2001 From: 821938089 <821938089@qq.com> Date: Sun, 17 Jul 2022 13:24:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/lib/webdav/WebDav.kt | 11 +++++++---- .../legado/app/ui/book/remote/RemoteBookActivity.kt | 2 +- .../legado/app/ui/book/remote/RemoteBookViewModel.kt | 3 ++- .../io/legado/app/ui/config/BackupConfigFragment.kt | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) 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 0226c8b00..baeedd16e 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 @@ -70,10 +70,13 @@ open class WebDav(val path: String, val authorization: Authorization) { } private val webDavClient by lazy { val authInterceptor = Interceptor { chain -> - val request = chain.request() - .newBuilder() - .header(authorization.name, authorization.data) - .build() + var request = chain.request() + if (request.url.host == host) { + request = request + .newBuilder() + .header(authorization.name, authorization.data) + .build() + } chain.proceed(request) } okHttpClient.newBuilder().run { diff --git a/app/src/main/java/io/legado/app/ui/book/remote/RemoteBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/remote/RemoteBookActivity.kt index 2f7b9296b..eb60584c0 100644 --- a/app/src/main/java/io/legado/app/ui/book/remote/RemoteBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/remote/RemoteBookActivity.kt @@ -151,7 +151,7 @@ class RemoteBookActivity : VMBaseActivity Unit) { + fun loadRemoteBookList(path: String?, loadCallback: (loading: Boolean) -> Unit) { execute { dataCallback?.clear() + val path = path ?: RemoteBookWebDav.rootBookUrl val bookList = RemoteBookWebDav.getRemoteBookList(path) dataCallback?.setItems(bookList) }.onError { diff --git a/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt index b02431dbe..0d3183813 100644 --- a/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt @@ -286,7 +286,7 @@ class BackupConfigFragment : PreferenceFragment(), } fun restore() { - Coroutine.async(context = Main) { + Coroutine.async { AppWebDav.showRestoreDialog(requireContext()) }.onError { alert {