Merge pull request #2076 from 821938089/compatible-custom-webdav

优化自建webdav
pull/2077/head
kunfei 2 years ago committed by GitHub
commit fbc001df9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      app/src/main/java/io/legado/app/lib/webdav/WebDav.kt
  2. 2
      app/src/main/java/io/legado/app/ui/book/remote/RemoteBookActivity.kt
  3. 3
      app/src/main/java/io/legado/app/ui/book/remote/RemoteBookViewModel.kt
  4. 2
      app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.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 {

@ -151,7 +151,7 @@ class RemoteBookActivity : VMBaseActivity<ActivityImportBookBinding, RemoteBookV
viewModel.dataCallback?.clear()
adapter.selected.clear()
viewModel.loadRemoteBookList(
viewModel.dirList.lastOrNull()?.path ?: RemoteBookWebDav.rootBookUrl
viewModel.dirList.lastOrNull()?.path
) {
if (it) {
waitDialog.show()

@ -74,9 +74,10 @@ class RemoteBookViewModel(application: Application) : BaseViewModel(application)
}
}
fun loadRemoteBookList(path: String, loadCallback: (loading: Boolean) -> 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 {

@ -286,7 +286,7 @@ class BackupConfigFragment : PreferenceFragment(),
}
fun restore() {
Coroutine.async(context = Main) {
Coroutine.async {
AppWebDav.showRestoreDialog(requireContext())
}.onError {
alert {

Loading…
Cancel
Save