From a67966aa6a407095000430c47541856c8b7166dc Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 4 Sep 2024 18:29:20 +0000 Subject: [PATCH 01/11] Update dependencies for minor & patch changes --- gradle/libs.versions.toml | 32 ++++++++++++------------ gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e825002..ef462af 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,22 +1,22 @@ [versions] # plugins -android-gradle = "8.5.0" +android-gradle = "8.6.0" detekt = "1.23.6" -junit = "1.10.0.0" -ksp = "2.0.0-1.0.22" -ktlint = "4.3.0" +junit = "1.11.0.0" +ksp = "2.0.20-1.0.24" +ktlint = "4.4.1" # production libraries -coil = "2.6.0" -compose-bom = "2024.06.00" +coil = "2.7.0" +compose-bom = "2024.08.00" compose-compiler = "1.5.14" -compose-rules = "0.4.4" +compose-rules = "0.4.11" compose-material3 = "1.2.1" -hilt = "2.51.1" -kotlin = "2.0.0" +hilt = "2.52" +kotlin = "2.0.20" kotlin-coroutines = "1.8.1" -kotlin-serialization = "1.7.0" -lifecycle = "2.7.0" # update to 2.8.x when it fixes the crash on release version that happens on 2.8.2 +kotlin-serialization = "1.7.2" +lifecycle = "2.8.4" # update to 2.8.x when it fixes the crash on release version that happens on 2.8.2 navigation = "2.7.7" navigation-hilt = "1.2.0" okhttp-logging-interceptor = "4.12.0" @@ -25,16 +25,16 @@ room = "2.6.1" timber = "5.0.1" # test libraries -test-junit = "5.10.2" -test-mockk = "1.13.11" +test-junit = "5.11.0" +test-mockk = "1.13.12" test-turbine = "1.1.0" # android test libraries -test-android-baseline-profile = "1.2.4" +test-android-baseline-profile = "1.3.0" test-android-compose-ui-test = "1.6.8" -test-android-junit = "1.1.5" +test-android-junit = "1.2.1" test-android-profile-installer = "1.3.1" -test-android-runner = "1.5.2" +test-android-runner = "1.6.2" [plugins] diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a441313..9355b41 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME From 3984907703ce9ccddbd6c1236d5b39069c256ad8 Mon Sep 17 00:00:00 2001 From: Krzysztof Dabrowski Date: Wed, 4 Sep 2024 21:17:05 +0200 Subject: [PATCH 02/11] Remove deprecated strong skipping mode flags --- app/build.gradle.kts | 4 ---- basic-feature/build.gradle.kts | 4 ---- core/build.gradle.kts | 4 ---- 3 files changed, 12 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index a4fbb75..f296601 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -39,10 +39,6 @@ android { } } - composeCompiler { - enableStrongSkippingMode = true - } - kotlin { jvmToolchain(17) } diff --git a/basic-feature/build.gradle.kts b/basic-feature/build.gradle.kts index 3e5cf02..f164df6 100644 --- a/basic-feature/build.gradle.kts +++ b/basic-feature/build.gradle.kts @@ -34,10 +34,6 @@ android { } } - composeCompiler { - enableStrongSkippingMode = true - } - kotlin { jvmToolchain(17) diff --git a/core/build.gradle.kts b/core/build.gradle.kts index b8c0f17..c38599e 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -34,10 +34,6 @@ android { } } - composeCompiler { - enableStrongSkippingMode = true - } - kotlin { jvmToolchain(17) From b4294bd5d86b5c4e0c5fb574854cc2cae250f661 Mon Sep 17 00:00:00 2001 From: Krzysztof Dabrowski Date: Thu, 5 Sep 2024 17:31:49 +0200 Subject: [PATCH 03/11] Update Compose to 1.7.0 and Compose-M3 to 1.3.0 --- gradle/libs.versions.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ef462af..896a838 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,10 +8,10 @@ ktlint = "4.4.1" # production libraries coil = "2.7.0" -compose-bom = "2024.08.00" +compose-bom = "2024.09.00" compose-compiler = "1.5.14" compose-rules = "0.4.11" -compose-material3 = "1.2.1" +compose-material3 = "1.3.0" hilt = "2.52" kotlin = "2.0.20" kotlin-coroutines = "1.8.1" From 3365b900df4dcd45cc32a9c5ba0d705897938420 Mon Sep 17 00:00:00 2001 From: Krzysztof Dabrowski Date: Thu, 5 Sep 2024 17:34:37 +0200 Subject: [PATCH 04/11] Remove old Compose compiler version --- gradle/libs.versions.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 896a838..e4894dd 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,7 +9,6 @@ ktlint = "4.4.1" # production libraries coil = "2.7.0" compose-bom = "2024.09.00" -compose-compiler = "1.5.14" compose-rules = "0.4.11" compose-material3 = "1.3.0" hilt = "2.52" From a31ff3d5c2d3ec9ffaa6205a4661af513db0b67a Mon Sep 17 00:00:00 2001 From: Krzysztof Dabrowski Date: Thu, 5 Sep 2024 17:35:39 +0200 Subject: [PATCH 05/11] Update Compose UI test to 1.7.0 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e4894dd..d19d094 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -30,7 +30,7 @@ test-turbine = "1.1.0" # android test libraries test-android-baseline-profile = "1.3.0" -test-android-compose-ui-test = "1.6.8" +test-android-compose-ui-test = "1.7.0" test-android-junit = "1.2.1" test-android-profile-installer = "1.3.1" test-android-runner = "1.6.2" From cf5a58c86c51be015ee7e97cf776329b674c21d2 Mon Sep 17 00:00:00 2001 From: Krzysztof Dabrowski Date: Thu, 5 Sep 2024 17:39:18 +0200 Subject: [PATCH 06/11] Remove old comment for Lifecycle library --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d19d094..878d6a4 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -15,7 +15,7 @@ hilt = "2.52" kotlin = "2.0.20" kotlin-coroutines = "1.8.1" kotlin-serialization = "1.7.2" -lifecycle = "2.8.4" # update to 2.8.x when it fixes the crash on release version that happens on 2.8.2 +lifecycle = "2.8.4" navigation = "2.7.7" navigation-hilt = "1.2.0" okhttp-logging-interceptor = "4.12.0" From 92160de20289b060a27ff59b8ea67dc23c8dfae9 Mon Sep 17 00:00:00 2001 From: Krzysztof Dabrowski Date: Thu, 5 Sep 2024 18:23:40 +0200 Subject: [PATCH 07/11] Add missing ExperimentalCoroutinesApi to compiler options --- basic-feature/build.gradle.kts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/basic-feature/build.gradle.kts b/basic-feature/build.gradle.kts index f164df6..5ddd2cd 100644 --- a/basic-feature/build.gradle.kts +++ b/basic-feature/build.gradle.kts @@ -39,7 +39,8 @@ android { compilerOptions { freeCompilerArgs.addAll( - "-opt-in=androidx.compose.material3.ExperimentalMaterial3Api" + "-opt-in=androidx.compose.material3.ExperimentalMaterial3Api", + "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi" ) } } From 8f21c53f4b79592a45f060e3dd38e0892d1e0dfa Mon Sep 17 00:00:00 2001 From: Krzysztof Dabrowski Date: Thu, 5 Sep 2024 18:52:38 +0200 Subject: [PATCH 08/11] Change LocalLifecycleOwner package --- .../krzdabrowski/starter/core/utils/ExtensionsFlowLifecycle.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/eu/krzdabrowski/starter/core/utils/ExtensionsFlowLifecycle.kt b/core/src/main/java/eu/krzdabrowski/starter/core/utils/ExtensionsFlowLifecycle.kt index 58f8653..9decba1 100644 --- a/core/src/main/java/eu/krzdabrowski/starter/core/utils/ExtensionsFlowLifecycle.kt +++ b/core/src/main/java/eu/krzdabrowski/starter/core/utils/ExtensionsFlowLifecycle.kt @@ -3,9 +3,9 @@ package eu.krzdabrowski.starter.core.utils import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.remember -import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner +import androidx.lifecycle.compose.LocalLifecycleOwner import androidx.lifecycle.flowWithLifecycle import kotlinx.coroutines.flow.Flow From 92ae499b7e3b256a18f5bd489ecb3d0b371b15cf Mon Sep 17 00:00:00 2001 From: Krzysztof Dabrowski Date: Thu, 5 Sep 2024 18:54:04 +0200 Subject: [PATCH 09/11] Adapt pull to refresh to once again the newest API from Compose-M3 1.2.0 to 1.3.0 version --- .../presentation/RocketsViewModel.kt | 4 ++ .../presentation/composable/RocketsScreen.kt | 47 ++----------------- .../presentation/RocketsViewModelTest.kt | 2 + 3 files changed, 11 insertions(+), 42 deletions(-) diff --git a/basic-feature/src/main/java/eu/krzdabrowski/starter/basicfeature/presentation/RocketsViewModel.kt b/basic-feature/src/main/java/eu/krzdabrowski/starter/basicfeature/presentation/RocketsViewModel.kt index ef7926a..3d0428d 100644 --- a/basic-feature/src/main/java/eu/krzdabrowski/starter/basicfeature/presentation/RocketsViewModel.kt +++ b/basic-feature/src/main/java/eu/krzdabrowski/starter/basicfeature/presentation/RocketsViewModel.kt @@ -13,6 +13,7 @@ import eu.krzdabrowski.starter.basicfeature.presentation.RocketsUiState.PartialS import eu.krzdabrowski.starter.basicfeature.presentation.RocketsUiState.PartialState.Loading import eu.krzdabrowski.starter.basicfeature.presentation.mapper.toPresentationModel import eu.krzdabrowski.starter.core.presentation.mvi.BaseViewModel +import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.map @@ -22,6 +23,8 @@ import javax.inject.Inject private const val HTTP_PREFIX = "http" private const val HTTPS_PREFIX = "https" +private const val ROCKETS_REFRESH_FAILURE_INDICATOR_DURATION_IN_MILLIS = 500L // to make refresh indicator visible for a while + @HiltViewModel class RocketsViewModel @Inject constructor( private val getRocketsUseCase: GetRocketsUseCase, @@ -81,6 +84,7 @@ class RocketsViewModel @Inject constructor( private fun refreshRockets(): Flow = flow { refreshRocketsUseCase() .onFailure { + delay(ROCKETS_REFRESH_FAILURE_INDICATOR_DURATION_IN_MILLIS) emit(Error(it)) } }.onStart { diff --git a/basic-feature/src/main/java/eu/krzdabrowski/starter/basicfeature/presentation/composable/RocketsScreen.kt b/basic-feature/src/main/java/eu/krzdabrowski/starter/basicfeature/presentation/composable/RocketsScreen.kt index ea363e2..34425b1 100644 --- a/basic-feature/src/main/java/eu/krzdabrowski/starter/basicfeature/presentation/composable/RocketsScreen.kt +++ b/basic-feature/src/main/java/eu/krzdabrowski/starter/basicfeature/presentation/composable/RocketsScreen.kt @@ -1,20 +1,15 @@ package eu.krzdabrowski.starter.basicfeature.presentation.composable -import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.padding import androidx.compose.material3.Scaffold import androidx.compose.material3.SnackbarHost import androidx.compose.material3.SnackbarHostState -import androidx.compose.material3.pulltorefresh.PullToRefreshContainer -import androidx.compose.material3.pulltorefresh.PullToRefreshState -import androidx.compose.material3.pulltorefresh.rememberPullToRefreshState +import androidx.compose.material3.pulltorefresh.PullToRefreshBox import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.remember -import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.res.stringResource import androidx.hilt.navigation.compose.hiltViewModel @@ -47,21 +42,14 @@ internal fun RocketsScreen( onIntent: (RocketsIntent) -> Unit, ) { val snackbarHostState = remember { SnackbarHostState() } - val pullToRefreshState = rememberPullToRefreshState() - - HandlePullToRefresh( - pullState = pullToRefreshState, - uiState = uiState, - onIntent = onIntent, - ) Scaffold( snackbarHost = { SnackbarHost(snackbarHostState) }, ) { paddingValues -> - Box( - modifier = Modifier - .padding(paddingValues) - .nestedScroll(pullToRefreshState.nestedScrollConnection), + PullToRefreshBox( + modifier = Modifier.padding(paddingValues), + isRefreshing = uiState.isLoading, + onRefresh = { onIntent(RefreshRockets) }, ) { if (uiState.rockets.isNotEmpty()) { RocketsAvailableContent( @@ -74,31 +62,6 @@ internal fun RocketsScreen( uiState = uiState, ) } - - PullToRefreshContainer( - state = pullToRefreshState, - modifier = Modifier - .align(Alignment.TopCenter), - ) - } - } -} - -@Composable -private fun HandlePullToRefresh( - pullState: PullToRefreshState, - uiState: RocketsUiState, - onIntent: (RocketsIntent) -> Unit, -) { - if (pullState.isRefreshing) { - LaunchedEffect(onIntent) { - onIntent(RefreshRockets) - } - } - - if (uiState.isLoading.not()) { - LaunchedEffect(true) { - pullState.endRefresh() } } } diff --git a/basic-feature/src/test/java/eu/krzdabrowski/starter/basicfeature/presentation/RocketsViewModelTest.kt b/basic-feature/src/test/java/eu/krzdabrowski/starter/basicfeature/presentation/RocketsViewModelTest.kt index a8f3e24..53fca07 100644 --- a/basic-feature/src/test/java/eu/krzdabrowski/starter/basicfeature/presentation/RocketsViewModelTest.kt +++ b/basic-feature/src/test/java/eu/krzdabrowski/starter/basicfeature/presentation/RocketsViewModelTest.kt @@ -149,6 +149,8 @@ class RocketsViewModelTest { // Then objectUnderTest.uiState.test { + skipItems(1) // Loading-Refreshing state + val actualItem = awaitItem() assertTrue(actualItem.isError) From 8602fc7f37684e230951ecd8d2b3de4232115809 Mon Sep 17 00:00:00 2001 From: Krzysztof Dabrowski Date: Thu, 5 Sep 2024 20:10:44 +0200 Subject: [PATCH 10/11] Lint fixes from KtLint 1.3.0 --- .editorconfig | 6 ++++ .../starter/database/DatabaseModule.kt | 16 ++++------ .../basicfeature/data/FakeRocketModule.kt | 16 ++++------ .../basicfeature/data/di/RocketModule.kt | 16 +++------- .../data/repository/RocketRepositoryImpl.kt | 19 +++++------ .../domain/usecase/GetRocketsUseCase.kt | 3 +- .../starter/core/utils/HiltTestRunner.kt | 4 +-- .../coroutines/CoroutinesFlowConcurrency.kt | 3 +- .../starter/core/network/NetworkModule.kt | 32 ++++++++----------- .../starter/core/utils/ExtensionsResult.kt | 18 +++++------ .../core/navigation/NavigationManagerTest.kt | 8 ++--- 11 files changed, 60 insertions(+), 81 deletions(-) diff --git a/.editorconfig b/.editorconfig index f5573a7..ebc7d55 100644 --- a/.editorconfig +++ b/.editorconfig @@ -52,6 +52,12 @@ ktlint_standard_no-blank-line-in-list = disabled # Set signature body expression wrapping to default (even if default, it is required for multiline-expression-wrapping) ktlint_function_signature_body_expression_wrapping = default +# Ignore forcing one-line classes into multiple lines +ktlint_standard_class-signature = disabled + +# Ignore putting every dot-chain in the same line as closing parenthesis +ktlint_standard_chain-method-continuation = disabled + [*.md] trim_trailing_whitespace = false diff --git a/app/src/main/java/eu/krzdabrowski/starter/database/DatabaseModule.kt b/app/src/main/java/eu/krzdabrowski/starter/database/DatabaseModule.kt index 4f32fc3..dd926ff 100644 --- a/app/src/main/java/eu/krzdabrowski/starter/database/DatabaseModule.kt +++ b/app/src/main/java/eu/krzdabrowski/starter/database/DatabaseModule.kt @@ -20,17 +20,13 @@ internal object DatabaseModule { @Provides fun provideAppDatabase( @ApplicationContext context: Context, - ): AppDatabase { - return Room.databaseBuilder( - context, - AppDatabase::class.java, - APP_DATABASE_NAME, - ).build() - } + ): AppDatabase = Room.databaseBuilder( + context, + AppDatabase::class.java, + APP_DATABASE_NAME, + ).build() @Singleton @Provides - fun provideRocketDao(database: AppDatabase): RocketDao { - return database.rocketDao() - } + fun provideRocketDao(database: AppDatabase): RocketDao = database.rocketDao() } diff --git a/basic-feature/src/androidTest/java/eu/krzdabrowski/starter/basicfeature/data/FakeRocketModule.kt b/basic-feature/src/androidTest/java/eu/krzdabrowski/starter/basicfeature/data/FakeRocketModule.kt index c3bc6e4..bcd2a1b 100644 --- a/basic-feature/src/androidTest/java/eu/krzdabrowski/starter/basicfeature/data/FakeRocketModule.kt +++ b/basic-feature/src/androidTest/java/eu/krzdabrowski/starter/basicfeature/data/FakeRocketModule.kt @@ -18,18 +18,14 @@ import kotlinx.coroutines.flow.flowOf internal object FakeRocketModule { @Provides - fun provideFakeGetRocketsUseCase(): GetRocketsUseCase { - return GetRocketsUseCase { - flowOf( - Result.success(generateTestRocketsFromDomain()), - ) - } + fun provideFakeGetRocketsUseCase(): GetRocketsUseCase = GetRocketsUseCase { + flowOf( + Result.success(generateTestRocketsFromDomain()), + ) } @Provides - fun provideNoopRefreshRocketsUseCase(): RefreshRocketsUseCase { - return RefreshRocketsUseCase { - resultOf { } - } + fun provideNoopRefreshRocketsUseCase(): RefreshRocketsUseCase = RefreshRocketsUseCase { + resultOf { } } } diff --git a/basic-feature/src/main/java/eu/krzdabrowski/starter/basicfeature/data/di/RocketModule.kt b/basic-feature/src/main/java/eu/krzdabrowski/starter/basicfeature/data/di/RocketModule.kt index b5979e3..44a8479 100644 --- a/basic-feature/src/main/java/eu/krzdabrowski/starter/basicfeature/data/di/RocketModule.kt +++ b/basic-feature/src/main/java/eu/krzdabrowski/starter/basicfeature/data/di/RocketModule.kt @@ -21,22 +21,16 @@ internal object RocketModule { @Provides @Singleton - fun provideRocketApi(retrofit: Retrofit): RocketApi { - return retrofit.create(RocketApi::class.java) - } + fun provideRocketApi(retrofit: Retrofit): RocketApi = retrofit.create(RocketApi::class.java) @Provides - fun provideGetRocketsUseCase(rocketRepository: RocketRepository): GetRocketsUseCase { - return GetRocketsUseCase { - getRockets(rocketRepository) - } + fun provideGetRocketsUseCase(rocketRepository: RocketRepository): GetRocketsUseCase = GetRocketsUseCase { + getRockets(rocketRepository) } @Provides - fun provideRefreshRocketsUseCase(rocketRepository: RocketRepository): RefreshRocketsUseCase { - return RefreshRocketsUseCase { - refreshRockets(rocketRepository) - } + fun provideRefreshRocketsUseCase(rocketRepository: RocketRepository): RefreshRocketsUseCase = RefreshRocketsUseCase { + refreshRockets(rocketRepository) } @Module diff --git a/basic-feature/src/main/java/eu/krzdabrowski/starter/basicfeature/data/repository/RocketRepositoryImpl.kt b/basic-feature/src/main/java/eu/krzdabrowski/starter/basicfeature/data/repository/RocketRepositoryImpl.kt index 66749e1..2bf3d99 100644 --- a/basic-feature/src/main/java/eu/krzdabrowski/starter/basicfeature/data/repository/RocketRepositoryImpl.kt +++ b/basic-feature/src/main/java/eu/krzdabrowski/starter/basicfeature/data/repository/RocketRepositoryImpl.kt @@ -16,18 +16,15 @@ class RocketRepositoryImpl @Inject constructor( private val rocketDao: RocketDao, ) : RocketRepository { - override fun getRockets(): Flow> { - return rocketDao - .getRockets() - .map { rocketsCached -> - rocketsCached.map { it.toDomainModel() } - } - .onEach { rockets -> - if (rockets.isEmpty()) { - refreshRockets() - } + override fun getRockets(): Flow> = rocketDao.getRockets() + .map { rocketsCached -> + rocketsCached.map { it.toDomainModel() } + } + .onEach { rockets -> + if (rockets.isEmpty()) { + refreshRockets() } - } + } override suspend fun refreshRockets() { rocketApi diff --git a/basic-feature/src/main/java/eu/krzdabrowski/starter/basicfeature/domain/usecase/GetRocketsUseCase.kt b/basic-feature/src/main/java/eu/krzdabrowski/starter/basicfeature/domain/usecase/GetRocketsUseCase.kt index 55ae717..932ca16 100644 --- a/basic-feature/src/main/java/eu/krzdabrowski/starter/basicfeature/domain/usecase/GetRocketsUseCase.kt +++ b/basic-feature/src/main/java/eu/krzdabrowski/starter/basicfeature/domain/usecase/GetRocketsUseCase.kt @@ -28,6 +28,7 @@ fun getRockets(rocketRepository: RocketRepository): Flow>> = false } } - .catch { // for other than IOException but it will stop collecting Flow + .catch { + // for other than IOException but it will stop collecting Flow emit(Result.failure(it)) // also catch does re-throw CancellationException } diff --git a/core/src/androidTest/java/eu/krzdabrowski/starter/core/utils/HiltTestRunner.kt b/core/src/androidTest/java/eu/krzdabrowski/starter/core/utils/HiltTestRunner.kt index 2c1f88b..59af535 100644 --- a/core/src/androidTest/java/eu/krzdabrowski/starter/core/utils/HiltTestRunner.kt +++ b/core/src/androidTest/java/eu/krzdabrowski/starter/core/utils/HiltTestRunner.kt @@ -11,7 +11,5 @@ class HiltTestRunner : AndroidJUnitRunner() { cl: ClassLoader?, name: String?, context: Context?, - ): Application { - return super.newApplication(cl, HiltTestApplication::class.java.name, context) - } + ): Application = super.newApplication(cl, HiltTestApplication::class.java.name, context) } diff --git a/core/src/main/java/eu/krzdabrowski/starter/core/coroutines/CoroutinesFlowConcurrency.kt b/core/src/main/java/eu/krzdabrowski/starter/core/coroutines/CoroutinesFlowConcurrency.kt index abfc7f9..999e63b 100644 --- a/core/src/main/java/eu/krzdabrowski/starter/core/coroutines/CoroutinesFlowConcurrency.kt +++ b/core/src/main/java/eu/krzdabrowski/starter/core/coroutines/CoroutinesFlowConcurrency.kt @@ -118,7 +118,8 @@ internal fun Flow.flatMapConcurrently( semaphore.release() } } - exceptionWasThrownEarlier.invokeOnCompletion { thrown -> // should never be null + exceptionWasThrownEarlier.invokeOnCompletion { thrown -> + // should never be null // don't nest CancellationExceptions arbitrarily deep evalTransform.cancel(thrown!!.asCancellation()) diff --git a/core/src/main/java/eu/krzdabrowski/starter/core/network/NetworkModule.kt b/core/src/main/java/eu/krzdabrowski/starter/core/network/NetworkModule.kt index 3d17342..e56a80c 100644 --- a/core/src/main/java/eu/krzdabrowski/starter/core/network/NetworkModule.kt +++ b/core/src/main/java/eu/krzdabrowski/starter/core/network/NetworkModule.kt @@ -23,28 +23,24 @@ internal object NetworkModule { @Provides @Named(INTERCEPTOR_LOGGING_NAME) - fun provideHttpLoggingInterceptor(): Interceptor { - return if (BuildConfig.DEBUG) { - HttpLoggingInterceptor().apply { - level = HttpLoggingInterceptor.Level.BODY - } - } else { - noOpInterceptor() + fun provideHttpLoggingInterceptor(): Interceptor = if (BuildConfig.DEBUG) { + HttpLoggingInterceptor().apply { + level = HttpLoggingInterceptor.Level.BODY } + } else { + noOpInterceptor() } @Provides @Singleton fun provideOkHttpClient( @Named(INTERCEPTOR_LOGGING_NAME) loggingInterceptor: Interceptor, - ): OkHttpClient { - return OkHttpClient - .Builder() - .apply { - addNetworkInterceptor(loggingInterceptor) - } - .build() - } + ): OkHttpClient = OkHttpClient + .Builder() + .apply { + addNetworkInterceptor(loggingInterceptor) + } + .build() @Provides @Singleton @@ -62,9 +58,7 @@ internal object NetworkModule { .build() } - private fun noOpInterceptor(): Interceptor { - return Interceptor { chain -> - chain.proceed(chain.request()) - } + private fun noOpInterceptor(): Interceptor = Interceptor { chain -> + chain.proceed(chain.request()) } } diff --git a/core/src/main/java/eu/krzdabrowski/starter/core/utils/ExtensionsResult.kt b/core/src/main/java/eu/krzdabrowski/starter/core/utils/ExtensionsResult.kt index e3423d0..1015f10 100644 --- a/core/src/main/java/eu/krzdabrowski/starter/core/utils/ExtensionsResult.kt +++ b/core/src/main/java/eu/krzdabrowski/starter/core/utils/ExtensionsResult.kt @@ -11,14 +11,12 @@ import kotlinx.coroutines.TimeoutCancellationException * * Cancellation exceptions need to be rethrown. See https://github.com/Kotlin/kotlinx.coroutines/issues/1814. */ -inline fun resultOf(block: () -> R): Result { - return try { - Result.success(block()) - } catch (t: TimeoutCancellationException) { - Result.failure(t) - } catch (c: CancellationException) { - throw c - } catch (e: Exception) { - Result.failure(e) - } +inline fun resultOf(block: () -> R): Result = try { + Result.success(block()) +} catch (t: TimeoutCancellationException) { + Result.failure(t) +} catch (c: CancellationException) { + throw c +} catch (e: Exception) { + Result.failure(e) } diff --git a/core/src/test/java/eu/krzdabrowski/starter/core/navigation/NavigationManagerTest.kt b/core/src/test/java/eu/krzdabrowski/starter/core/navigation/NavigationManagerTest.kt index 6638a6f..6e40d12 100644 --- a/core/src/test/java/eu/krzdabrowski/starter/core/navigation/NavigationManagerTest.kt +++ b/core/src/test/java/eu/krzdabrowski/starter/core/navigation/NavigationManagerTest.kt @@ -100,11 +100,9 @@ class NavigationManagerTest { } } - private fun generateTestNavigationCommands(number: Int): List { - return List(number) { - object : NavigationCommand { - override val destination = "testDestination$it" - } + private fun generateTestNavigationCommands(number: Int): List = List(number) { + object : NavigationCommand { + override val destination = "testDestination$it" } } From ad629657710554ab900ca357377ac4df6010cf58 Mon Sep 17 00:00:00 2001 From: Krzysztof Dabrowski Date: Thu, 5 Sep 2024 21:14:11 +0200 Subject: [PATCH 11/11] Update Lifecycle to 2.8.5 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 878d6a4..5e843ac 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -15,7 +15,7 @@ hilt = "2.52" kotlin = "2.0.20" kotlin-coroutines = "1.8.1" kotlin-serialization = "1.7.2" -lifecycle = "2.8.4" +lifecycle = "2.8.5" navigation = "2.7.7" navigation-hilt = "1.2.0" okhttp-logging-interceptor = "4.12.0"