优化
This commit is contained in:
@@ -70,10 +70,13 @@ open class WebDav(val path: String, val authorization: Authorization) {
|
|||||||
}
|
}
|
||||||
private val webDavClient by lazy {
|
private val webDavClient by lazy {
|
||||||
val authInterceptor = Interceptor { chain ->
|
val authInterceptor = Interceptor { chain ->
|
||||||
val request = chain.request()
|
var request = chain.request()
|
||||||
.newBuilder()
|
if (request.url.host == host) {
|
||||||
.header(authorization.name, authorization.data)
|
request = request
|
||||||
.build()
|
.newBuilder()
|
||||||
|
.header(authorization.name, authorization.data)
|
||||||
|
.build()
|
||||||
|
}
|
||||||
chain.proceed(request)
|
chain.proceed(request)
|
||||||
}
|
}
|
||||||
okHttpClient.newBuilder().run {
|
okHttpClient.newBuilder().run {
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ class RemoteBookActivity : VMBaseActivity<ActivityImportBookBinding, RemoteBookV
|
|||||||
viewModel.dataCallback?.clear()
|
viewModel.dataCallback?.clear()
|
||||||
adapter.selected.clear()
|
adapter.selected.clear()
|
||||||
viewModel.loadRemoteBookList(
|
viewModel.loadRemoteBookList(
|
||||||
viewModel.dirList.lastOrNull()?.path ?: RemoteBookWebDav.rootBookUrl
|
viewModel.dirList.lastOrNull()?.path
|
||||||
) {
|
) {
|
||||||
if (it) {
|
if (it) {
|
||||||
waitDialog.show()
|
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 {
|
execute {
|
||||||
dataCallback?.clear()
|
dataCallback?.clear()
|
||||||
|
val path = path ?: RemoteBookWebDav.rootBookUrl
|
||||||
val bookList = RemoteBookWebDav.getRemoteBookList(path)
|
val bookList = RemoteBookWebDav.getRemoteBookList(path)
|
||||||
dataCallback?.setItems(bookList)
|
dataCallback?.setItems(bookList)
|
||||||
}.onError {
|
}.onError {
|
||||||
|
|||||||
@@ -286,7 +286,7 @@ class BackupConfigFragment : PreferenceFragment(),
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun restore() {
|
fun restore() {
|
||||||
Coroutine.async(context = Main) {
|
Coroutine.async {
|
||||||
AppWebDav.showRestoreDialog(requireContext())
|
AppWebDav.showRestoreDialog(requireContext())
|
||||||
}.onError {
|
}.onError {
|
||||||
alert {
|
alert {
|
||||||
|
|||||||
Reference in New Issue
Block a user