pull/83/head
kunfei 5 years ago
parent 46e4916bfe
commit 7487b2a4ca
  1. 8
      app/src/main/java/io/legado/app/ui/importbook/ImportBookActivity.kt
  2. 14
      app/src/main/java/io/legado/app/ui/importbook/ImportBookViewModel.kt

@ -69,10 +69,14 @@ class ImportBookActivity : VMBaseActivity<ImportBookViewModel>(R.layout.activity
goBackDir() goBackDir()
} }
btn_add_book.onClick { btn_add_book.onClick {
viewModel.addToBookshelf(adapter.selectedUris) viewModel.addToBookshelf(adapter.selectedUris) {
upPath()
}
} }
btn_delete.onClick { btn_delete.onClick {
viewModel.deleteDoc(adapter.selectedUris) viewModel.deleteDoc(adapter.selectedUris) {
upPath()
}
} }
cb_selected_all.onClick { cb_selected_all.onClick {
adapter.selectAll(cb_selected_all.isChecked) adapter.selectAll(cb_selected_all.isChecked)

@ -1,17 +1,25 @@
package io.legado.app.ui.importbook package io.legado.app.ui.importbook
import android.app.Application import android.app.Application
import android.net.Uri
import androidx.documentfile.provider.DocumentFile
import io.legado.app.base.BaseViewModel import io.legado.app.base.BaseViewModel
class ImportBookViewModel(application: Application) : BaseViewModel(application) { class ImportBookViewModel(application: Application) : BaseViewModel(application) {
fun addToBookshelf(uriList: HashSet<String>) { fun addToBookshelf(uriList: HashSet<String>, finally: () -> Unit) {
} }
fun deleteDoc(uriList: HashSet<String>) { fun deleteDoc(uriList: HashSet<String>, finally: () -> Unit) {
execute {
uriList.forEach {
DocumentFile.fromSingleUri(context, Uri.parse(it))?.delete()
}
}.onFinally {
finally.invoke()
}
} }
} }
Loading…
Cancel
Save