package br.com.edsilfer.android.presence_control.commons.utils.extension

import android.content.Context
import android.text.Html
import android.text.Spanned

/**
 * Created by ferna on 5/24/2017.
 */
fun String.parseHtml(): Spanned? {
    val result: Spanned
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
        result = Html.fromHtml(this, Html.FROM_HTML_MODE_LEGACY)
    } else {
        result = Html.fromHtml(this)
    }
    return result
}

fun String.setMaxCharacters(maxCharacters: Int): String {
    if (length > maxCharacters) {
        return substring(0, maxCharacters)
    } else {
        return this
    }
}
