From 02307fc507bfdb73c56e15a506adcafa6755ccdb Mon Sep 17 00:00:00 2001 From: Caren Date: Tue, 13 Dec 2022 11:31:55 -0800 Subject: [PATCH] Feeding goes from loading -> success, causing whole feed to recreate? Added logging statements Change-Id: I39f9a31c8fb324bce684f1a0145d58251c70181a --- .../google/samples/apps/nowinandroid/core/ui/NewsFeed.kt | 2 ++ .../apps/nowinandroid/feature/foryou/ForYouScreen.kt | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsFeed.kt b/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsFeed.kt index ecda10819..c5dd78289 100644 --- a/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsFeed.kt +++ b/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsFeed.kt @@ -18,6 +18,7 @@ package com.google.samples.apps.nowinandroid.core.ui import android.content.Context import android.net.Uri +import android.util.Log import androidx.annotation.ColorInt import androidx.browser.customtabs.CustomTabColorSchemeParams import androidx.browser.customtabs.CustomTabsIntent @@ -51,6 +52,7 @@ fun LazyGridScope.newsFeed( when (feedState) { NewsFeedUiState.Loading -> Unit is NewsFeedUiState.Success -> { + Log.i("CarenNewsFeed", "Recreating news feed") items(feedState.feed, key = { it.newsResource.id }) { saveableNewsResource -> val resourceUrl by remember { mutableStateOf(Uri.parse(saveableNewsResource.newsResource.url)) diff --git a/feature/foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.kt b/feature/foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.kt index 1420a7e47..f1e19052a 100644 --- a/feature/foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.kt +++ b/feature/foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.kt @@ -17,6 +17,7 @@ package com.google.samples.apps.nowinandroid.feature.foryou import android.app.Activity +import android.util.Log import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeOut @@ -97,10 +98,13 @@ internal fun ForYouRoute( modifier: Modifier = Modifier, viewModel: ForYouViewModel = hiltViewModel() ) { + val onboardingUiState by viewModel.onboardingUiState.collectAsStateWithLifecycle() val feedState by viewModel.feedState.collectAsStateWithLifecycle() val isSyncing by viewModel.isSyncing.collectAsStateWithLifecycle() + Log.i("Caren", "Executing ForYouRoute: $feedState") + ForYouScreen( isSyncing = isSyncing, onboardingUiState = onboardingUiState, @@ -125,6 +129,8 @@ internal fun ForYouScreen( val isOnboardingLoading = onboardingUiState is OnboardingUiState.Loading val isFeedLoading = feedState is NewsFeedUiState.Loading + Log.i("Caren", "Recreating ForYouScreen") + // Workaround to call Activity.reportFullyDrawn from Jetpack Compose. // This code should be called when the UI is ready for use // and relates to Time To Full Display.