Skip to content

Commit 7cb6698

Browse files
authored
Releases/v1.4.8 (#80)
## Updates * Adds `CustomerVideoData::videoCreatorId` ## Improvements * Add overloads for `Util.oneOf`/`Util.noneOf`/`Util.allEqual` that take Collections ### Internal lib updates * Update `stats.muxcore` to v8.4.0
1 parent 9305db9 commit 7cb6698

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

library/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ muxDistribution {
7676
dependencies {
7777
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1"
7878

79-
api "com.mux:stats.muxcore:8.3.0"
79+
api "com.mux:stats.muxcore:8.4.0"
8080

8181
testImplementation 'androidx.test.ext:junit-ktx:1.2.1'
8282
testImplementation 'junit:junit:4.13.2'

library/src/main/java/com/mux/android/util/Util.kt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,27 @@ import kotlin.math.ceil
99
*/
1010
fun <Any> Any.oneOf(vararg these: Any) = these.contains(this)
1111

12+
/**
13+
* Returns true if the receiver is not in the given objects.
14+
*
15+
* For example `"blue".oneOf("red", "green") == false` and `3.oneOf(3,5,6) == true`
16+
*/
17+
fun <Any> Any.oneOf(these: Collection<Any>) = these.contains(this)
18+
1219
/**
1320
* Returns true if the receiver is not in the given objects.
1421
*
1522
* For example `3.noneOf(1,4,5) == true` and `3.noneOf(3,5,6) = false`
1623
*/
1724
fun <Any> Any.noneOf(vararg these: Any) = !these.contains(this)
1825

26+
/**
27+
* Returns true if the receiver is not in the given objects.
28+
*
29+
* For example `3.noneOf(1,4,5) == true` and `3.noneOf(3,5,6) = false`
30+
*/
31+
fun <Any> Any.noneOf(these: Collection<Any>) = !these.contains(this)
32+
1933
/**
2034
* Return true if all elements in the given set are equal
2135
*/
@@ -29,6 +43,21 @@ fun <Any> allEqual(vararg these: Any): Boolean {
2943
}
3044
}
3145

46+
/**
47+
* Return true if all elements in the given set are equal
48+
*/
49+
fun <Any> allEqual(these: Collection<Any>): Boolean {
50+
if (these.isEmpty()) {
51+
return true
52+
} else {
53+
val head = these.first()
54+
for (it in these) {
55+
if (head != it) return false
56+
}
57+
return true
58+
}
59+
}
60+
3261
/**
3362
* Clamps an integer between the given min and max
3463
*/

library/src/test/java/com/mux/core_android/AndroidDeviceTests.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class AndroidDeviceTests : AbsRobolectricTest() {
115115
incorrectNetworks.onEach { incorrectNet ->
116116
connMgrReturns23.onEach { connType ->
117117
testConnectionType23(
118-
assertMsg = "API 23: network type should not be $correctNetwork",
118+
assertMsg = "API 23: network type should be $correctNetwork",
119119
mockTypeFromConnMgr = connType,
120120
expectedType = incorrectNet,
121121
onThisNetwork = false
@@ -136,7 +136,7 @@ class AndroidDeviceTests : AbsRobolectricTest() {
136136
incorrectNetworks.onEach { incorrectNet ->
137137
connMgrReturns16.onEach { connType ->
138138
testConnectionType16(
139-
assertMsg = "API 16: network type should not be $correctNetwork",
139+
assertMsg = "API 16: network type should be $correctNetwork",
140140
mockTypeFromConnMgr = connType,
141141
expectedType = incorrectNet,
142142
onThisNetwork = false

0 commit comments

Comments
 (0)