From 46d96429e08c53b6c5d6fbf3c7475831fe3fd3ca Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 29 Nov 2019 11:20:46 +0100 Subject: [PATCH] Create ooi extension --- .../java/im/vector/riotx/core/extensions/BasicExtensions.kt | 2 ++ .../features/home/room/detail/composer/ComposerEditText.kt | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/riotx/core/extensions/BasicExtensions.kt b/vector/src/main/java/im/vector/riotx/core/extensions/BasicExtensions.kt index 2dc75c5fa2..1e3da7f878 100644 --- a/vector/src/main/java/im/vector/riotx/core/extensions/BasicExtensions.kt +++ b/vector/src/main/java/im/vector/riotx/core/extensions/BasicExtensions.kt @@ -21,6 +21,8 @@ import androidx.fragment.app.Fragment fun Boolean.toOnOff() = if (this) "ON" else "OFF" +inline fun T.ooi(block: (T) -> Unit): T = also(block) + /** * Apply argument to a Fragment */ diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/composer/ComposerEditText.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/composer/ComposerEditText.kt index ce27b1c098..ab37431103 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/composer/ComposerEditText.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/composer/ComposerEditText.kt @@ -27,6 +27,7 @@ import android.view.inputmethod.InputConnection import androidx.appcompat.widget.AppCompatEditText import androidx.core.view.inputmethod.EditorInfoCompat import androidx.core.view.inputmethod.InputConnectionCompat +import im.vector.riotx.core.extensions.ooi import im.vector.riotx.core.platform.SimpleTextWatcher import im.vector.riotx.features.html.PillImageSpan import timber.log.Timber @@ -75,7 +76,7 @@ class ComposerEditText @JvmOverloads constructor(context: Context, attrs: Attrib // Get the first span at this position spanToRemove = editableText.getSpans(deleteCharPosition, deleteCharPosition, PillImageSpan::class.java) - .also { Timber.v("Pills: beforeTextChanged: found ${it.size} span(s)") } + .ooi { Timber.v("Pills: beforeTextChanged: found ${it.size} span(s)") } .firstOrNull() } }