mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 18:35:40 +03:00
making the incrementing helper specific to increments of 1 and incrementing first before returning the minimum value
This commit is contained in:
parent
fa30691583
commit
486671f385
2 changed files with 10 additions and 3 deletions
|
@ -16,4 +16,11 @@
|
|||
|
||||
package im.vector.app.core.extensions
|
||||
|
||||
fun Int.incrementAndWrap(max: Int, min: Int = 0, amount: Int = 1) = if (this == max) min else this + amount
|
||||
fun Int.incrementByOneAndWrap(max: Int, min: Int = 0): Int {
|
||||
val incrementedValue = this + 1
|
||||
return if (incrementedValue > max) {
|
||||
min
|
||||
} else {
|
||||
incrementedValue
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
|||
import com.google.android.material.tabs.TabLayoutMediator
|
||||
import im.vector.app.BuildConfig
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.extensions.incrementAndWrap
|
||||
import im.vector.app.core.extensions.incrementByOneAndWrap
|
||||
import im.vector.app.core.extensions.setCurrentItem
|
||||
import im.vector.app.core.flow.tickerFlow
|
||||
import im.vector.app.databinding.FragmentFtueSplashCarouselBinding
|
||||
|
@ -83,7 +83,7 @@ class FtueAuthSplashCarouselFragment @Inject constructor(
|
|||
views.splashCarousel.apply {
|
||||
val itemCount = carouselAdapter.itemCount
|
||||
tickerFlow(lifecycleScope, delayMillis = CAROUSEL_ROTATION_DELAY_MS)
|
||||
.onEach { setCurrentItem(currentItem.incrementAndWrap(max = itemCount - 1), duration = CAROUSEL_TRANSITION_TIME_MS) }
|
||||
.onEach { setCurrentItem(currentItem.incrementByOneAndWrap(max = itemCount - 1), duration = CAROUSEL_TRANSITION_TIME_MS) }
|
||||
.launchIn(lifecycleScope)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue