pull/475/head
gedoor 4 years ago
parent 0e43e6ce43
commit b556dad280
  1. 23
      app/src/main/java/io/legado/app/lib/dialogs/AlertBuilder.kt
  2. 19
      app/src/main/java/io/legado/app/lib/dialogs/AndroidAlertBuilder.kt
  3. 3
      app/src/main/java/io/legado/app/ui/association/ImportBookSourceActivity.kt
  4. 6
      app/src/main/java/io/legado/app/ui/association/ImportReplaceRuleActivity.kt
  5. 3
      app/src/main/java/io/legado/app/ui/association/ImportRssSourceActivity.kt
  6. 3
      app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt

@ -47,19 +47,34 @@ interface AlertBuilder<out D : DialogInterface> {
@Deprecated(NO_GETTER, level = ERROR) get
fun positiveButton(buttonText: String, onClicked: ((dialog: DialogInterface) -> Unit)? = null)
fun positiveButton(@StringRes buttonTextResource: Int, onClicked: ((dialog: DialogInterface) -> Unit)? = null)
fun positiveButton(
@StringRes buttonTextResource: Int,
onClicked: ((dialog: DialogInterface) -> Unit)? = null
)
fun negativeButton(buttonText: String, onClicked: ((dialog: DialogInterface) -> Unit)? = null)
fun negativeButton(@StringRes buttonTextResource: Int, onClicked: ((dialog: DialogInterface) -> Unit)? = null)
fun negativeButton(
@StringRes buttonTextResource: Int,
onClicked: ((dialog: DialogInterface) -> Unit)? = null
)
fun neutralButton(buttonText: String, onClicked: ((dialog: DialogInterface) -> Unit)? = null)
fun neutralButton(@StringRes buttonTextResource: Int, onClicked: ((dialog: DialogInterface) -> Unit)? = null)
fun neutralButton(
@StringRes buttonTextResource: Int,
onClicked: ((dialog: DialogInterface) -> Unit)? = null
)
fun onCancelled(handler: (dialog: DialogInterface) -> Unit)
fun onKeyPressed(handler: (dialog: DialogInterface, keyCode: Int, e: KeyEvent) -> Boolean)
fun items(items: List<CharSequence>, onItemSelected: (dialog: DialogInterface, index: Int) -> Unit)
fun onDismiss(handler: (dialog: DialogInterface) -> Unit)
fun items(
items: List<CharSequence>,
onItemSelected: (dialog: DialogInterface, index: Int) -> Unit
)
fun <T> items(
items: List<T>,
onItemSelected: (dialog: DialogInterface, item: T, index: Int) -> Unit

@ -74,15 +74,28 @@ internal class AndroidAlertBuilder(override val ctx: Context) : AlertBuilder<Ale
builder.setNegativeButton(buttonTextResource) { dialog, _ -> onClicked?.invoke(dialog) }
}
override fun neutralButton(buttonText: String, onClicked: ((dialog: DialogInterface) -> Unit)?) {
override fun neutralButton(
buttonText: String,
onClicked: ((dialog: DialogInterface) -> Unit)?
) {
builder.setNeutralButton(buttonText) { dialog, _ -> onClicked?.invoke(dialog) }
}
override fun neutralButton(buttonTextResource: Int, onClicked: ((dialog: DialogInterface) -> Unit)?) {
override fun neutralButton(
buttonTextResource: Int,
onClicked: ((dialog: DialogInterface) -> Unit)?
) {
builder.setNeutralButton(buttonTextResource) { dialog, _ -> onClicked?.invoke(dialog) }
}
override fun items(items: List<CharSequence>, onItemSelected: (dialog: DialogInterface, index: Int) -> Unit) {
override fun onDismiss(handler: (dialog: DialogInterface) -> Unit) {
builder.setOnDismissListener(handler)
}
override fun items(
items: List<CharSequence>,
onItemSelected: (dialog: DialogInterface, index: Int) -> Unit
) {
builder.setItems(Array(items.size) { i -> items[i].toString() }) { dialog, which ->
onItemSelected(dialog, which)
}

@ -73,9 +73,10 @@ class ImportBookSourceActivity : VMBaseActivity<ImportBookSourceViewModel>(
private fun errorDialog(msg: String) {
alert(getString(R.string.error), msg) {
okButton { }
}.show().setOnDismissListener {
onDismiss {
finish()
}
}.show()
}
private fun successDialog() {

@ -75,9 +75,10 @@ class ImportReplaceRuleActivity : VMBaseActivity<ImportReplaceRuleViewModel>(
private fun errorDialog(msg: String) {
alert("导入出错", msg) {
okButton { }
}.show().setOnDismissListener {
onDismiss {
finish()
}
}.show()
}
private fun successDialog(allSource: ArrayList<ReplaceRule>) {
@ -88,8 +89,9 @@ class ImportReplaceRuleActivity : VMBaseActivity<ImportReplaceRuleViewModel>(
noButton {
}
}.show().setOnDismissListener {
onDismiss {
finish()
}
}.show()
}
}

@ -72,9 +72,10 @@ class ImportRssSourceActivity : VMBaseActivity<ImportRssSourceViewModel>(
private fun errorDialog(msg: String) {
alert(getString(R.string.error), msg) {
okButton { }
}.show().setOnDismissListener {
onDismiss {
finish()
}
}.show()
}
private fun successDialog() {

@ -153,9 +153,10 @@ class BackupConfigFragment : BasePreferenceFragment(),
multiChoiceItems(Restore.ignoreTitle, checkedItems) { _, which, isChecked ->
Restore.ignoreConfig[Restore.ignoreKeys[which]] = isChecked
}
}.show().setOnDismissListener {
onDismiss {
Restore.saveIgnoreConfig()
}
}.show()
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {

Loading…
Cancel
Save