up importSource

pull/849/head
gedoor 4 years ago
parent f5907f7534
commit ee57ad886a
  1. 26
      app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt
  2. 8
      app/src/main/java/io/legado/app/ui/association/ImportBookSourceViewModel.kt
  3. 26
      app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt
  4. 8
      app/src/main/java/io/legado/app/ui/association/ImportRssSourceViewModel.kt
  5. 1
      app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineDialog.kt
  6. 2
      app/src/main/res/layout/dialog_recycler_view.xml
  7. 11
      app/src/main/res/menu/import_source.xml

@ -74,6 +74,16 @@ class ImportBookSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickList
dismiss()
}
}
binding.tvFooterLeft.setText(R.string.select_all)
binding.tvFooterLeft.setOnClickListener {
val selectAll = viewModel.isSelectAll()
viewModel.selectStatus.forEachIndexed { index, b ->
if (b != !selectAll) {
viewModel.selectStatus[index] = !selectAll
}
}
adapter.notifyDataSetChanged()
}
}
private fun initMenu() {
@ -108,22 +118,6 @@ class ImportBookSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickList
noButton()
}.show()
}
R.id.menu_select_all -> {
viewModel.selectStatus.forEachIndexed { index, b ->
if (!b) {
viewModel.selectStatus[index] = true
}
}
adapter.notifyDataSetChanged()
}
R.id.menu_un_select_all -> {
viewModel.selectStatus.forEachIndexed { index, b ->
if (b) {
viewModel.selectStatus[index] = false
}
}
adapter.notifyDataSetChanged()
}
R.id.menu_Keep_original_name -> {
item.isChecked = !item.isChecked
putPrefBoolean(PreferKey.importKeepName, item.isChecked)

@ -27,6 +27,14 @@ class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) {
val checkSources = arrayListOf<BookSource?>()
val selectStatus = arrayListOf<Boolean>()
fun isSelectAll(): Boolean {
selectStatus.forEach {
if (!it) {
return false
}
}
return true
}
fun importSelect(finally: () -> Unit) {
execute {

@ -72,6 +72,16 @@ class ImportRssSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListe
dismiss()
}
}
binding.tvFooterLeft.setText(R.string.select_all)
binding.tvFooterLeft.setOnClickListener {
val selectAll = viewModel.isSelectAll()
viewModel.selectStatus.forEachIndexed { index, b ->
if (b != !selectAll) {
viewModel.selectStatus[index] = !selectAll
}
}
adapter.notifyDataSetChanged()
}
}
private fun initMenu() {
@ -106,22 +116,6 @@ class ImportRssSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListe
noButton()
}.show()
}
R.id.menu_select_all -> {
viewModel.selectStatus.forEachIndexed { index, b ->
if (!b) {
viewModel.selectStatus[index] = true
}
}
adapter.notifyDataSetChanged()
}
R.id.menu_un_select_all -> {
viewModel.selectStatus.forEachIndexed { index, b ->
if (b) {
viewModel.selectStatus[index] = false
}
}
adapter.notifyDataSetChanged()
}
R.id.menu_Keep_original_name -> {
item.isChecked = !item.isChecked
putPrefBoolean(PreferKey.importKeepName, item.isChecked)

@ -26,6 +26,14 @@ class ImportRssSourceViewModel(app: Application) : BaseViewModel(app) {
val checkSources = arrayListOf<RssSource?>()
val selectStatus = arrayListOf<Boolean>()
fun isSelectAll(): Boolean {
selectStatus.forEach {
if (!it) {
return false
}
}
return true
}
fun importSelect(finally: () -> Unit) {
execute {

@ -66,7 +66,6 @@ class SpeakEngineDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
adapter = Adapter(requireContext())
recyclerView.adapter = adapter
tvFooterLeft.setText(R.string.local_tts)
tvFooterLeft.visible()
tvFooterLeft.setOnClickListener {
removePref(PreferKey.speakEngine)
dismiss()

@ -37,8 +37,6 @@
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:padding="12dp"
android:text="@string/cancel"
android:visibility="gone"
tools:ignore="RtlHardcoded" />
<Space

@ -9,17 +9,6 @@
app:showAsAction="always"
tools:ignore="AlwaysShowAction" />
<item
android:id="@+id/menu_select_all"
android:title="@string/select_all"
app:showAsAction="always"
tools:ignore="AlwaysShowAction" />
<item
android:id="@+id/menu_un_select_all"
android:title="@string/un_select_all"
app:showAsAction="never" />
<item
android:id="@+id/menu_Keep_original_name"
android:title="@string/keep_original_name"

Loading…
Cancel
Save