Skip to content

Commit

Permalink
Releases/v1.4.8 (#80)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
daytime-em authored Feb 27, 2025
1 parent 9305db9 commit 7cb6698
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ muxDistribution {
dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1"

api "com.mux:stats.muxcore:8.3.0"
api "com.mux:stats.muxcore:8.4.0"

testImplementation 'androidx.test.ext:junit-ktx:1.2.1'
testImplementation 'junit:junit:4.13.2'
Expand Down
29 changes: 29 additions & 0 deletions library/src/main/java/com/mux/android/util/Util.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,27 @@ import kotlin.math.ceil
*/
fun <Any> Any.oneOf(vararg these: Any) = these.contains(this)

/**
* Returns true if the receiver is not in the given objects.
*
* For example `"blue".oneOf("red", "green") == false` and `3.oneOf(3,5,6) == true`
*/
fun <Any> Any.oneOf(these: Collection<Any>) = these.contains(this)

/**
* Returns true if the receiver is not in the given objects.
*
* For example `3.noneOf(1,4,5) == true` and `3.noneOf(3,5,6) = false`
*/
fun <Any> Any.noneOf(vararg these: Any) = !these.contains(this)

/**
* Returns true if the receiver is not in the given objects.
*
* For example `3.noneOf(1,4,5) == true` and `3.noneOf(3,5,6) = false`
*/
fun <Any> Any.noneOf(these: Collection<Any>) = !these.contains(this)

/**
* Return true if all elements in the given set are equal
*/
Expand All @@ -29,6 +43,21 @@ fun <Any> allEqual(vararg these: Any): Boolean {
}
}

/**
* Return true if all elements in the given set are equal
*/
fun <Any> allEqual(these: Collection<Any>): Boolean {
if (these.isEmpty()) {
return true
} else {
val head = these.first()
for (it in these) {
if (head != it) return false
}
return true
}
}

/**
* Clamps an integer between the given min and max
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class AndroidDeviceTests : AbsRobolectricTest() {
incorrectNetworks.onEach { incorrectNet ->
connMgrReturns23.onEach { connType ->
testConnectionType23(
assertMsg = "API 23: network type should not be $correctNetwork",
assertMsg = "API 23: network type should be $correctNetwork",
mockTypeFromConnMgr = connType,
expectedType = incorrectNet,
onThisNetwork = false
Expand All @@ -136,7 +136,7 @@ class AndroidDeviceTests : AbsRobolectricTest() {
incorrectNetworks.onEach { incorrectNet ->
connMgrReturns16.onEach { connType ->
testConnectionType16(
assertMsg = "API 16: network type should not be $correctNetwork",
assertMsg = "API 16: network type should be $correctNetwork",
mockTypeFromConnMgr = connType,
expectedType = incorrectNet,
onThisNetwork = false
Expand Down

0 comments on commit 7cb6698

Please sign in to comment.