Skip to content
This repository was archived by the owner on Jul 13, 2020. It is now read-only.
This repository was 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

Description

@cs-victor-nascimento

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()
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions