pull/2076/head
821938089 2 years ago
parent f924f74ee8
commit 8767a5b950
  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