adding extension for checking if charsequence is a matrix id
This commit is contained in:
parent
38763d0575
commit
a02141c7c2
|
@ -19,6 +19,7 @@ package im.vector.app.core.extensions
|
||||||
import android.util.Patterns
|
import android.util.Patterns
|
||||||
import com.google.i18n.phonenumbers.NumberParseException
|
import com.google.i18n.phonenumbers.NumberParseException
|
||||||
import com.google.i18n.phonenumbers.PhoneNumberUtil
|
import com.google.i18n.phonenumbers.PhoneNumberUtil
|
||||||
|
import org.matrix.android.sdk.api.MatrixPatterns
|
||||||
import org.matrix.android.sdk.api.extensions.ensurePrefix
|
import org.matrix.android.sdk.api.extensions.ensurePrefix
|
||||||
|
|
||||||
fun Boolean.toOnOff() = if (this) "ON" else "OFF"
|
fun Boolean.toOnOff() = if (this) "ON" else "OFF"
|
||||||
|
@ -30,6 +31,8 @@ inline fun <T> T.ooi(block: (T) -> Unit): T = also(block)
|
||||||
*/
|
*/
|
||||||
fun CharSequence.isEmail() = Patterns.EMAIL_ADDRESS.matcher(this).matches()
|
fun CharSequence.isEmail() = Patterns.EMAIL_ADDRESS.matcher(this).matches()
|
||||||
|
|
||||||
|
fun CharSequence.isMatrixId() = MatrixPatterns.isUserId(this.toString())
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return empty CharSequence if the CharSequence is null.
|
* Return empty CharSequence if the CharSequence is null.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue