diff --git a/vector/src/main/java/im/vector/app/core/extensions/Integer.kt b/vector/src/main/java/im/vector/app/core/extensions/Integer.kt index 70c834af89..2940c16fa2 100644 --- a/vector/src/main/java/im/vector/app/core/extensions/Integer.kt +++ b/vector/src/main/java/im/vector/app/core/extensions/Integer.kt @@ -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 + } +} diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashCarouselFragment.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashCarouselFragment.kt index 1520ec45b2..5ba7358112 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashCarouselFragment.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashCarouselFragment.kt @@ -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) } }