-
Notifications
You must be signed in to change notification settings - Fork 748
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'hotfix/1.5.25' into main
- Loading branch information
Showing
8 changed files
with
188 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Main changes in this version: Mainly bugfixing, in particular fix message not appearing on the timeline. | ||
Full changelog: https://github.com/vector-im/element-android/releases |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
library/core-utils/src/main/java/im/vector/lib/core/utils/timer/SpecialRound.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (c) 2023 New Vector Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package im.vector.lib.core.utils.timer | ||
|
||
import kotlin.math.round | ||
|
||
class SpecialRound(private val step: Long) { | ||
/** | ||
* Round the provided value to the nearest multiple of `step`. | ||
*/ | ||
fun round(value: Long): Long { | ||
return round(value.toDouble() / step).toLong() * step | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
library/core-utils/src/test/java/im/vector/lib/core/utils/timer/SpecialRoundTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (c) 2023 New Vector Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package im.vector.lib.core.utils.timer | ||
|
||
import org.amshove.kluent.shouldBeEqualTo | ||
import org.junit.Test | ||
|
||
class SpecialRoundTest { | ||
@Test | ||
fun `test special round 500`() { | ||
val sut = SpecialRound(500) | ||
sut.round(1) shouldBeEqualTo 0 | ||
sut.round(499) shouldBeEqualTo 500 | ||
sut.round(500) shouldBeEqualTo 500 | ||
sut.round(501) shouldBeEqualTo 500 | ||
sut.round(999) shouldBeEqualTo 1_000 | ||
sut.round(1000) shouldBeEqualTo 1_000 | ||
sut.round(1001) shouldBeEqualTo 1_000 | ||
sut.round(1499) shouldBeEqualTo 1_500 | ||
sut.round(1500) shouldBeEqualTo 1_500 | ||
sut.round(1501) shouldBeEqualTo 1_500 | ||
} | ||
|
||
@Test | ||
fun `test special round 1_000`() { | ||
val sut = SpecialRound(1_000) | ||
sut.round(1) shouldBeEqualTo 0 | ||
sut.round(499) shouldBeEqualTo 0 | ||
sut.round(500) shouldBeEqualTo 0 | ||
sut.round(501) shouldBeEqualTo 1_000 | ||
sut.round(999) shouldBeEqualTo 1_000 | ||
sut.round(1000) shouldBeEqualTo 1_000 | ||
sut.round(1001) shouldBeEqualTo 1_000 | ||
sut.round(1499) shouldBeEqualTo 1_000 | ||
sut.round(1500) shouldBeEqualTo 2_000 | ||
sut.round(1501) shouldBeEqualTo 2_000 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters