Merge remote-tracking branch 'origin/master'

pull/1999/head
kunfei 2 years ago
commit e5346b3862
  1. 1
      app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt
  2. 8
      app/src/main/java/io/legado/app/ui/book/remote/RemoteBookActivity.kt
  3. 6
      app/src/main/java/io/legado/app/ui/book/remote/RemoteBookViewModel.kt
  4. 2
      app/src/main/res/layout/activity_import_book.xml

@ -115,6 +115,7 @@ class ImportBookActivity : VMBaseActivity<ActivityImportBookBinding, ImportBookV
private fun initView() { private fun initView() {
binding.layTop.setBackgroundColor(backgroundColor) binding.layTop.setBackgroundColor(backgroundColor)
binding.tvEmptyMsg.setText(R.string.empty_msg_import_book)
binding.recyclerView.layoutManager = LinearLayoutManager(this) binding.recyclerView.layoutManager = LinearLayoutManager(this)
binding.recyclerView.adapter = adapter binding.recyclerView.adapter = adapter
binding.selectActionBar.setMainActionText(R.string.add_to_shelf) binding.selectActionBar.setMainActionText(R.string.add_to_shelf)

@ -122,7 +122,13 @@ class RemoteBookActivity : VMBaseActivity<ActivityImportBookBinding, RemoteBookV
adapter.selected.clear() adapter.selected.clear()
viewModel.loadRemoteBookList( viewModel.loadRemoteBookList(
viewModel.dirList.lastOrNull()?.path ?: RemoteBookWebDav.rootBookUrl viewModel.dirList.lastOrNull()?.path ?: RemoteBookWebDav.rootBookUrl
) ) {
if (it) {
waitDialog.show()
} else {
waitDialog.dismiss()
}
}
} }
override fun openDir(remoteBook: RemoteBook) { override fun openDir(remoteBook: RemoteBook) {

@ -52,7 +52,7 @@ class RemoteBookViewModel(application: Application): BaseViewModel(application){
} }
} }
fun loadRemoteBookList(path: String) { fun loadRemoteBookList(path: String, loadCallback: (loading: Boolean) -> Unit) {
execute { execute {
dataCallback?.clear() dataCallback?.clear()
val bookList = RemoteBookWebDav.getRemoteBookList(path) val bookList = RemoteBookWebDav.getRemoteBookList(path)
@ -60,6 +60,10 @@ class RemoteBookViewModel(application: Application): BaseViewModel(application){
}.onError { }.onError {
AppLog.put("获取webDav书籍出错\n${it.localizedMessage}", it) AppLog.put("获取webDav书籍出错\n${it.localizedMessage}", it)
context.toastOnUi("获取webDav书籍出错\n${it.localizedMessage}") context.toastOnUi("获取webDav书籍出错\n${it.localizedMessage}")
}.onStart {
loadCallback.invoke(true)
}.onFinally {
loadCallback.invoke(false)
} }
} }

@ -78,7 +78,7 @@
android:layout_gravity="center" android:layout_gravity="center"
android:layout_margin="16dp" android:layout_margin="16dp"
android:gravity="center" android:gravity="center"
android:text="@string/empty_msg_import_book" android:text="@string/empty"
android:visibility="gone" android:visibility="gone"
tools:text="TextView" /> tools:text="TextView" />

Loading…
Cancel
Save