Update coil to 2.6.0 to fix initialization performance cost

Change-Id: Ib5740ab24af3e1fe0ba0036713a9b0aa3249bc5b
pull/1269/head
Tomáš Mlynarič 9 months ago
commit 1a1719277c

@ -26,11 +26,11 @@ import com.google.samples.apps.nowinandroid.core.data.repository.RecentSearchRep
import com.google.samples.apps.nowinandroid.core.domain.GetRecentSearchQueriesUseCase import com.google.samples.apps.nowinandroid.core.domain.GetRecentSearchQueriesUseCase
import com.google.samples.apps.nowinandroid.core.domain.GetSearchContentsCountUseCase import com.google.samples.apps.nowinandroid.core.domain.GetSearchContentsCountUseCase
import com.google.samples.apps.nowinandroid.core.domain.GetSearchContentsUseCase import com.google.samples.apps.nowinandroid.core.domain.GetSearchContentsUseCase
import com.google.samples.apps.nowinandroid.core.result.Result import com.google.samples.apps.nowinandroid.core.model.data.UserSearchResult
import com.google.samples.apps.nowinandroid.core.result.asResult
import dagger.hilt.android.lifecycle.HiltViewModel import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.map
@ -61,18 +61,15 @@ class SearchViewModel @Inject constructor(
flowOf(SearchResultUiState.EmptyQuery) flowOf(SearchResultUiState.EmptyQuery)
} else { } else {
getSearchContentsUseCase(query) getSearchContentsUseCase(query)
.asResult() // Not using .asResult() here, because it emits Loading state every
.map { result -> // time the user types a letter in the search box, which flickers the screen.
when (result) { .map<UserSearchResult, SearchResultUiState> { data ->
is Result.Success -> SearchResultUiState.Success( SearchResultUiState.Success(
topics = result.data.topics, topics = data.topics,
newsResources = result.data.newsResources, newsResources = data.newsResources,
) )
is Result.Loading -> SearchResultUiState.Loading
is Result.Error -> SearchResultUiState.LoadFailed
}
} }
.catch { emit(SearchResultUiState.LoadFailed) }
} }
} }
} }

@ -29,7 +29,7 @@ androidxTracing = "1.3.0-alpha02"
androidxUiAutomator = "2.2.0" androidxUiAutomator = "2.2.0"
androidxWindowManager = "1.2.0" androidxWindowManager = "1.2.0"
androidxWork = "2.9.0" androidxWork = "2.9.0"
coil = "2.5.0" coil = "2.6.0"
dependencyGuard = "0.4.3" dependencyGuard = "0.4.3"
firebaseBom = "32.4.0" firebaseBom = "32.4.0"
firebaseCrashlyticsPlugin = "2.9.9" firebaseCrashlyticsPlugin = "2.9.9"

Loading…
Cancel
Save