Commit 8fecd4e9 authored by Leonardo Aramaki's avatar Leonardo Aramaki

Add extensions for CharSequence.isEmpty and TextView.content that accepts CharSequence

parent 4c8a0f83
......@@ -5,6 +5,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import ru.noties.markwon.Markwon
fun String.ifEmpty(value: String): String {
if (isEmpty()) {
......@@ -13,6 +14,13 @@ fun String.ifEmpty(value: String): String {
return this
}
fun CharSequence.ifEmpty(value: String): CharSequence {
if (isEmpty()) {
return value
}
return this
}
fun View.setVisible(visible: Boolean) {
visibility = if (visible) {
View.VISIBLE
......@@ -31,6 +39,16 @@ var TextView.textContent: String
text = value
}
var TextView.content: CharSequence
get() = text
set(value) {
Markwon.unscheduleDrawables(this)
Markwon.unscheduleTableRows(this)
text = value
Markwon.scheduleDrawables(this)
Markwon.scheduleTableRows(this)
}
var TextView.hintContent: String
get() = hint.toString()
set(value) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment