up importSource

pull/849/head
gedoor 4 years ago
parent ee57ad886a
commit 2ab2d4c1fa
  1. 20
      app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt
  2. 10
      app/src/main/java/io/legado/app/ui/association/ImportBookSourceViewModel.kt
  3. 20
      app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt
  4. 10
      app/src/main/java/io/legado/app/ui/association/ImportRssSourceViewModel.kt
  5. 2
      app/src/main/res/values-zh-rHK/strings.xml
  6. 2
      app/src/main/res/values-zh-rTW/strings.xml
  7. 2
      app/src/main/res/values-zh/strings.xml
  8. 2
      app/src/main/res/values/strings.xml

@ -74,7 +74,7 @@ class ImportBookSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickList
dismiss()
}
}
binding.tvFooterLeft.setText(R.string.select_all)
upSelectText()
binding.tvFooterLeft.setOnClickListener {
val selectAll = viewModel.isSelectAll()
viewModel.selectStatus.forEachIndexed { index, b ->
@ -83,6 +83,23 @@ class ImportBookSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickList
}
}
adapter.notifyDataSetChanged()
upSelectText()
}
}
private fun upSelectText() {
if (viewModel.isSelectAll()) {
binding.tvFooterLeft.text = getString(
R.string.select_cancel_count,
viewModel.selectCount(),
viewModel.allSources.size
)
} else {
binding.tvFooterLeft.text = getString(
R.string.select_all_count,
viewModel.selectCount(),
viewModel.allSources.size
)
}
}
@ -162,6 +179,7 @@ class ImportBookSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickList
cbSourceName.setOnCheckedChangeListener { buttonView, isChecked ->
if (buttonView.isPressed) {
viewModel.selectStatus[holder.layoutPosition] = isChecked
upSelectText()
}
}
}

@ -36,6 +36,16 @@ class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) {
return true
}
fun selectCount(): Int {
var count = 0
selectStatus.forEach {
if (it) {
count++
}
}
return count
}
fun importSelect(finally: () -> Unit) {
execute {
val keepName = AppConfig.importKeepName

@ -72,7 +72,7 @@ class ImportRssSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListe
dismiss()
}
}
binding.tvFooterLeft.setText(R.string.select_all)
upSelectText()
binding.tvFooterLeft.setOnClickListener {
val selectAll = viewModel.isSelectAll()
viewModel.selectStatus.forEachIndexed { index, b ->
@ -81,6 +81,23 @@ class ImportRssSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListe
}
}
adapter.notifyDataSetChanged()
upSelectText()
}
}
private fun upSelectText() {
if (viewModel.isSelectAll()) {
binding.tvFooterLeft.text = getString(
R.string.select_cancel_count,
viewModel.selectCount(),
viewModel.allSources.size
)
} else {
binding.tvFooterLeft.text = getString(
R.string.select_all_count,
viewModel.selectCount(),
viewModel.allSources.size
)
}
}
@ -158,6 +175,7 @@ class ImportRssSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListe
cbSourceName.setOnCheckedChangeListener { buttonView, isChecked ->
if (buttonView.isPressed) {
viewModel.selectStatus[holder.layoutPosition] = isChecked
upSelectText()
}
}
}

@ -35,6 +35,16 @@ class ImportRssSourceViewModel(app: Application) : BaseViewModel(app) {
return true
}
fun selectCount(): Int {
var count = 0
selectStatus.forEach {
if (it) {
count++
}
}
return count
}
fun importSelect(finally: () -> Unit) {
execute {
val keepName = AppConfig.importKeepName

@ -212,7 +212,7 @@
<string name="select_action">選擇操作</string>
<string name="select_all">全選</string>
<string name="select_all_count">全選 (%1$d/%2$d)</string>
<string name="select_cancel_count">取消 (%1$d/%2$d)</string>
<string name="select_cancel_count">取消全選 (%1$d/%2$d)</string>
<string name="dark_theme">深色模式</string>
<string name="welcome">啟動頁</string>
<string name="download_start">開始下載</string>

@ -214,7 +214,7 @@
<string name="select_action">選擇操作</string>
<string name="select_all">全選</string>
<string name="select_all_count">全選(%1$d/%2$d)</string>
<string name="select_cancel_count">取消(%1$d/%2$d)</string>
<string name="select_cancel_count">取消全選(%1$d/%2$d)</string>
<string name="dark_theme">深色模式</string>
<string name="welcome">啟動頁</string>
<string name="download_start">開始下載</string>

@ -214,7 +214,7 @@
<string name="select_action">选择操作</string>
<string name="select_all">全选</string>
<string name="select_all_count">全选(%1$d/%2$d)</string>
<string name="select_cancel_count">取消(%1$d/%2$d)</string>
<string name="select_cancel_count">取消全选(%1$d/%2$d)</string>
<string name="dark_theme">深色模式</string>
<string name="welcome">启动页</string>
<string name="download_start">开始下载</string>

@ -215,7 +215,7 @@
<string name="select_action">Selection action</string>
<string name="select_all">Select all</string>
<string name="select_all_count">Select all(%1$d/%2$d)</string>
<string name="select_cancel_count">Cancel(%1$d/%2$d)</string>
<string name="select_cancel_count">Cancel select all(%1$d/%2$d)</string>
<string name="dark_theme">Dark mode</string>
<string name="welcome">Welcome page</string>
<string name="download_start">Download start</string>

Loading…
Cancel
Save