Skip to content
This repository has been archived by the owner on Jul 13, 2020. It is now read-only.

Anko Commons Dialogs - DSL should accept CharSequence instead of String #422

Closed
cs-victor-nascimento opened this issue Jun 25, 2017 · 0 comments
Milestone

Comments

@cs-victor-nascimento
Copy link

All the alert extension functions receive either String or a @StringResource messageResource: Int. The String version should be CharSequence so that we can pass SpannableString as a parameter.

So, just change this:

fun <D : DialogInterface> Context.alert(
        factory: AlertBuilderFactory<D>,
        message: String,
        title: String? = null,
        init: (AlertBuilder<D>.() -> Unit)? = null
): AlertBuilder<D> {
    return factory(this).apply {
        if (title != null) {
            this.title = title
        }
        this.message = message
        if (init != null) init()
    }
}

To:

fun <D : DialogInterface> Context.alert(
        factory: AlertBuilderFactory<D>,
        message: CharSequence, // this line !!!!!!
        title: String? = null,
        init: (AlertBuilder<D>.() -> Unit)? = null
): AlertBuilder<D> {
    return factory(this).apply {
        if (title != null) {
            this.title = title
        }
        this.message = message
        if (init != null) init()
    }
}
@4u7 4u7 closed this as completed in 14a29dc Nov 15, 2017
@4u7 4u7 added this to the Anko 0.10.3 milestone Nov 15, 2017
CrackerCat pushed a commit to CrackerCat/anko that referenced this issue Jul 31, 2024
so SpannableString could be used as a parameter

Fixes Kotlin#422
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants