From 128178ef86c3d19f1874a03ac8344c189c605d6b Mon Sep 17 00:00:00 2001 From: Ash Date: Fri, 22 Apr 2022 04:29:00 +0800 Subject: [PATCH] Keep the correct background color during animation --- .../reader/data/repository/LocalRssRepository.kt | 14 ++++++-------- .../me/ash/reader/data/repository/RssHelper.kt | 2 +- .../java/me/ash/reader/ui/page/common/HomeEntry.kt | 4 ++++ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/me/ash/reader/data/repository/LocalRssRepository.kt b/app/src/main/java/me/ash/reader/data/repository/LocalRssRepository.kt index 7db8cc6..f91b7fe 100644 --- a/app/src/main/java/me/ash/reader/data/repository/LocalRssRepository.kt +++ b/app/src/main/java/me/ash/reader/data/repository/LocalRssRepository.kt @@ -14,8 +14,6 @@ import androidx.work.ListenableWorker import androidx.work.WorkManager import dagger.hilt.android.qualifiers.ApplicationContext import kotlinx.coroutines.CoroutineDispatcher -import kotlinx.coroutines.async -import kotlinx.coroutines.awaitAll import kotlinx.coroutines.withContext import me.ash.reader.MainActivity import me.ash.reader.R @@ -99,11 +97,12 @@ class LocalRssRepository @Inject constructor( return withContext(dispatcherDefault) { val preTime = System.currentTimeMillis() val accountId = context.currentAccountId - val articles = mutableListOf
() feedDao.queryAll(accountId) .also { coroutineWorker.setProgress(setIsSyncing(true)) } - .map { feed -> async { syncFeed(feed) } } - .awaitAll() + // For ParseRSS v0.5.0 only + .map { feed -> syncFeed(feed) } + //.map { feed -> async { syncFeed(feed) } } + //.awaitAll() .forEach { if (it.isNotify) { notify(articleDao.insertIfNotExist(it.articles)) @@ -111,8 +110,6 @@ class LocalRssRepository @Inject constructor( articleDao.insertIfNotExist(it.articles) } } - -// articleDao.insertList(articles) Log.i("RlOG", "onCompletion: ${System.currentTimeMillis() - preTime}") accountDao.queryById(accountId)?.let { account -> accountDao.update( @@ -167,10 +164,11 @@ class LocalRssRepository @Inject constructor( private suspend fun syncFeed(feed: Feed): ArticleNotify { val latest = articleDao.queryLatestByFeedId(context.currentAccountId, feed.id) - var articles: List
? = null + val articles: List
? try { articles = rssHelper.queryRssXml(feed, latest?.link) } catch (e: Exception) { + e.printStackTrace() Log.e("RLog", "queryRssXml[${feed.name}]: ${e.message}") return ArticleNotify(listOf(), false) } diff --git a/app/src/main/java/me/ash/reader/data/repository/RssHelper.kt b/app/src/main/java/me/ash/reader/data/repository/RssHelper.kt index f38997a..fcd0f76 100644 --- a/app/src/main/java/me/ash/reader/data/repository/RssHelper.kt +++ b/app/src/main/java/me/ash/reader/data/repository/RssHelper.kt @@ -86,7 +86,7 @@ class RssHelper @Inject constructor( val parseRss = rssNetworkDataSource.parseRss(feed.url) parseRss.items.forEach { if (latestLink != null && latestLink == it.link) return@withContext a - Log.i("RLog", "request rss ${feed.name}: ${it.title}") + Log.i("RLog", "request rss:\n${feed.name},${feed.url}\n${it.title}") a.add( Article( id = accountId.spacerDollar(UUID.randomUUID().toString()), diff --git a/app/src/main/java/me/ash/reader/ui/page/common/HomeEntry.kt b/app/src/main/java/me/ash/reader/ui/page/common/HomeEntry.kt index d8f1fb9..8a70858 100644 --- a/app/src/main/java/me/ash/reader/ui/page/common/HomeEntry.kt +++ b/app/src/main/java/me/ash/reader/ui/page/common/HomeEntry.kt @@ -1,7 +1,10 @@ package me.ash.reader.ui.page.common import androidx.compose.animation.ExperimentalAnimationApi +import androidx.compose.foundation.background +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext import com.google.accompanist.navigation.animation.AnimatedNavHost @@ -31,6 +34,7 @@ fun HomeEntry() { } AnimatedNavHost( + modifier = Modifier.background(MaterialTheme.colorScheme.surface), navController = navController, startDestination = if (context.isFirstLaunch) RouteName.STARTUP else RouteName.HOME, ) {