kunfei 3 ani în urmă
părinte
comite
0f4fd68b4e

+ 10 - 2
app/src/main/java/io/legado/app/ui/book/manage/BookshelfManageActivity.kt

@@ -59,6 +59,7 @@ class BookshelfManageActivity :
     private val groupRequestCode = 22
     private val addToGroupRequestCode = 34
     private val adapter by lazy { BookAdapter(this, this) }
+    private val itemTouchCallback by lazy { ItemTouchCallback(adapter) }
     private var booksFlowJob: Job? = null
     private var menu: Menu? = null
     private var searchView: SearchView? = null
@@ -159,7 +160,6 @@ class BookshelfManageActivity :
         binding.recyclerView.layoutManager = LinearLayoutManager(this)
         binding.recyclerView.addItemDecoration(VerticalDivider(this))
         binding.recyclerView.adapter = adapter
-        val itemTouchCallback = ItemTouchCallback(adapter)
         itemTouchCallback.isCanDrag = AppConfig.bookshelfSort == 3
         val dragSelectTouchHelper: DragSelectTouchHelper =
             DragSelectTouchHelper(adapter.dragSelectCallback).setSlideArea(16, 50)
@@ -281,7 +281,15 @@ class BookshelfManageActivity :
 
     private fun alertDelSelection() {
         alert(titleResource = R.string.draw, messageResource = R.string.sure_del) {
-            okButton { viewModel.deleteBook(adapter.selection) }
+            val checkBox = CheckBox(this@BookshelfManageActivity).apply {
+                setText(R.string.delete_book_file)
+            }
+            val view = LinearLayout(this@BookshelfManageActivity).apply {
+                setPadding(16.dpToPx(), 0, 16.dpToPx(), 0)
+                addView(checkBox)
+            }
+            customView { view }
+            okButton { viewModel.deleteBook(adapter.selection, checkBox.isChecked) }
             noButton()
         }
     }