forked from melod1n/fast-messenger
upstream changes
upstream changes
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package com.meloda.fast.ext
|
||||
|
||||
import android.content.Context
|
||||
import android.widget.Toast
|
||||
import com.meloda.fast.model.base.UiText
|
||||
|
||||
inline fun String?.ifEmpty(defaultValue: () -> String?): String? =
|
||||
if (this?.isEmpty() == true) defaultValue() else this
|
||||
|
||||
fun String?.orDots(count: Int = 3): String {
|
||||
return this ?: ("." * count)
|
||||
}
|
||||
|
||||
operator fun String.times(count: Int): String {
|
||||
val builder = StringBuilder()
|
||||
for (i in 0 until count) {
|
||||
builder.append(this)
|
||||
}
|
||||
|
||||
return builder.toString()
|
||||
}
|
||||
|
||||
fun String.toast(context: Context, duration: Int = Toast.LENGTH_LONG) {
|
||||
Toast.makeText(context, this, duration).show()
|
||||
}
|
||||
|
||||
context (Context)
|
||||
fun String.toast(duration: Int = Toast.LENGTH_LONG) = toast(this@Context, duration)
|
||||
|
||||
fun String.asUiText(): UiText = UiText.Simple(this)
|
||||
Reference in New Issue
Block a user