[Android] Add extension to convert from boolean to integer
Robert Stone
git at videolan.org
Thu Aug 5 06:31:28 UTC 2021
vlc-android | branch: master | Robert Stone <rhstone at gmail.com> | Thu Jul 29 08:32:46 2021 -0700| [7db3e06e89db70df11514966aec3027fe469ffc5] | committer: Nicolas Pomepuy
Add extension to convert from boolean to integer
> https://code.videolan.org/videolan/vlc-android/commit/7db3e06e89db70df11514966aec3027fe469ffc5
---
application/tools/src/main/java/org/videolan/tools/KotlinExtensions.kt | 2 ++
1 file changed, 2 insertions(+)
diff --git a/application/tools/src/main/java/org/videolan/tools/KotlinExtensions.kt b/application/tools/src/main/java/org/videolan/tools/KotlinExtensions.kt
index 69d68124b..7be4f2db4 100644
--- a/application/tools/src/main/java/org/videolan/tools/KotlinExtensions.kt
+++ b/application/tools/src/main/java/org/videolan/tools/KotlinExtensions.kt
@@ -55,6 +55,8 @@ fun View?.setGone() = setVisibility(View.GONE)
val Int.dp: Int get() = (this * Resources.getSystem().displayMetrics.density).toInt()
val Int.px: Int get() = (this / Resources.getSystem().displayMetrics.density).toInt()
+fun Boolean.toInt() = if (this) 1 else 0
+
fun CoroutineScope.conflatedActor(time: Long = 2000L, action: suspend () -> Unit) = actor<Unit>(capacity = Channel.CONFLATED) {
for (evt in channel) {
action()
More information about the Android
mailing list