pull/1434/head
gedoor 3 years ago
parent 2c6f3a9950
commit 29d31190dc
  1. 2
      app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt
  2. 2
      app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt
  3. 11
      app/src/main/java/io/legado/app/ui/book/local/rule/TxtTocRuleActivity.kt
  4. 4
      app/src/main/java/io/legado/app/ui/book/local/rule/TxtTocRuleViewModel.kt
  5. 2
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
  6. 2
      app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt
  7. 5
      app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt
  8. 10
      app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt
  9. 4
      app/src/main/java/io/legado/app/ui/widget/SelectActionBar.kt

@ -84,7 +84,7 @@ class ArrangeBookActivity : VMBaseActivity<ActivityArrangeBookBinding, ArrangeBo
adapter.revertSelection() adapter.revertSelection()
} }
override fun onClickMainAction() { override fun onClickSelectBarMainAction() {
selectGroup(groupRequestCode, 0) selectGroup(groupRequestCode, 0)
} }

@ -98,7 +98,7 @@ class ImportBookActivity : VMBaseActivity<ActivityImportBookBinding, ImportBookV
} }
@SuppressLint("NotifyDataSetChanged") @SuppressLint("NotifyDataSetChanged")
override fun onClickMainAction() { override fun onClickSelectBarMainAction() {
viewModel.addToBookshelf(adapter.selectedUris) { viewModel.addToBookshelf(adapter.selectedUris) {
adapter.notifyDataSetChanged() adapter.notifyDataSetChanged()
} }

@ -111,6 +111,10 @@ class TxtTocRuleActivity : VMBaseActivity<ActivityTxtTocRuleBinding, TxtTocRuleV
} }
} }
override fun onClickSelectBarMainAction() {
delSourceDialog()
}
override fun revertSelection() { override fun revertSelection() {
adapter.revertSelection() adapter.revertSelection()
} }
@ -144,6 +148,13 @@ class TxtTocRuleActivity : VMBaseActivity<ActivityTxtTocRuleBinding, TxtTocRuleV
.upCountView(adapter.selection.size, adapter.itemCount) .upCountView(adapter.selection.size, adapter.itemCount)
} }
private fun delSourceDialog() {
alert(titleResource = R.string.draw, messageResource = R.string.sure_del) {
okButton { viewModel.del(*adapter.selection.toTypedArray()) }
noButton()
}
}
@SuppressLint("InflateParams") @SuppressLint("InflateParams")
private fun showImportDialog() { private fun showImportDialog() {
val aCache = ACache.get(this, cacheDir = false) val aCache = ACache.get(this, cacheDir = false)

@ -19,9 +19,9 @@ class TxtTocRuleViewModel(app: Application) : BaseViewModel(app) {
} }
} }
fun del(txtTocRule: TxtTocRule) { fun del(vararg txtTocRule: TxtTocRule) {
execute { execute {
appDb.txtTocRuleDao.delete(txtTocRule) appDb.txtTocRuleDao.delete(*txtTocRule)
} }
} }

@ -306,7 +306,7 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
adapter.revertSelection() adapter.revertSelection()
} }
override fun onClickMainAction() { override fun onClickSelectBarMainAction() {
alert(titleResource = R.string.draw, messageResource = R.string.sure_del) { alert(titleResource = R.string.draw, messageResource = R.string.sure_del) {
okButton { viewModel.delSelection(adapter.selection) } okButton { viewModel.delSelection(adapter.selection) }
noButton() noButton()

@ -158,7 +158,7 @@ class ReplaceRuleActivity : VMBaseActivity<ActivityReplaceRuleBinding, ReplaceRu
adapter.revertSelection() adapter.revertSelection()
} }
override fun onClickMainAction() { override fun onClickSelectBarMainAction() {
delSourceDialog() delSourceDialog()
} }

@ -130,7 +130,6 @@ class RssSourceActivity : VMBaseActivity<ActivityRssSourceBinding, RssSourceView
when (item?.itemId) { when (item?.itemId) {
R.id.menu_enable_selection -> viewModel.enableSelection(adapter.selection) R.id.menu_enable_selection -> viewModel.enableSelection(adapter.selection)
R.id.menu_disable_selection -> viewModel.disableSelection(adapter.selection) R.id.menu_disable_selection -> viewModel.disableSelection(adapter.selection)
R.id.menu_del_selection -> viewModel.delSelection(adapter.selection)
R.id.menu_top_sel -> viewModel.topSource(*adapter.selection.toTypedArray()) R.id.menu_top_sel -> viewModel.topSource(*adapter.selection.toTypedArray())
R.id.menu_bottom_sel -> viewModel.bottomSource(*adapter.selection.toTypedArray()) R.id.menu_bottom_sel -> viewModel.bottomSource(*adapter.selection.toTypedArray())
R.id.menu_export_selection -> viewModel.saveToFile(adapter.selection) { file -> R.id.menu_export_selection -> viewModel.saveToFile(adapter.selection) { file ->
@ -211,13 +210,13 @@ class RssSourceActivity : VMBaseActivity<ActivityRssSourceBinding, RssSourceView
adapter.revertSelection() adapter.revertSelection()
} }
override fun onClickMainAction() { override fun onClickSelectBarMainAction() {
delSourceDialog() delSourceDialog()
} }
private fun delSourceDialog() { private fun delSourceDialog() {
alert(titleResource = R.string.draw, messageResource = R.string.sure_del) { alert(titleResource = R.string.draw, messageResource = R.string.sure_del) {
okButton { viewModel.delSelection(adapter.selection) } okButton { viewModel.del(*adapter.selection.toTypedArray()) }
noButton() noButton()
} }
} }

@ -31,8 +31,8 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application)
} }
} }
fun del(rssSource: RssSource) { fun del(vararg rssSource: RssSource) {
execute { appDb.rssSourceDao.delete(rssSource) } execute { appDb.rssSourceDao.delete(*rssSource) }
} }
fun update(vararg rssSource: RssSource) { fun update(vararg rssSource: RssSource) {
@ -69,12 +69,6 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application)
} }
} }
fun delSelection(sources: List<RssSource>) {
execute {
appDb.rssSourceDao.delete(*sources.toTypedArray())
}
}
fun saveToFile(sources: List<RssSource>, success: (file: File) -> Unit) { fun saveToFile(sources: List<RssSource>, success: (file: File) -> Unit) {
execute { execute {
val path = "${context.filesDir}/shareRssSource.json" val path = "${context.filesDir}/shareRssSource.json"

@ -42,7 +42,7 @@ class SelectActionBar @JvmOverloads constructor(
} }
} }
binding.btnRevertSelection.setOnClickListener { callBack?.revertSelection() } binding.btnRevertSelection.setOnClickListener { callBack?.revertSelection() }
binding.btnSelectActionMain.setOnClickListener { callBack?.onClickMainAction() } binding.btnSelectActionMain.setOnClickListener { callBack?.onClickSelectBarMainAction() }
binding.ivMenuMore.setOnClickListener { selMenu?.show() } binding.ivMenuMore.setOnClickListener { selMenu?.show() }
} }
@ -108,6 +108,6 @@ class SelectActionBar @JvmOverloads constructor(
fun revertSelection() fun revertSelection()
fun onClickMainAction() {} fun onClickSelectBarMainAction() {}
} }
} }
Loading…
Cancel
Save