Keep the correct background color during animation

This commit is contained in:
Ash 2022-04-22 04:29:00 +08:00
parent 8546f0f1ed
commit 128178ef86
3 changed files with 11 additions and 9 deletions

View File

@ -14,8 +14,6 @@ import androidx.work.ListenableWorker
import androidx.work.WorkManager import androidx.work.WorkManager
import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import me.ash.reader.MainActivity import me.ash.reader.MainActivity
import me.ash.reader.R import me.ash.reader.R
@ -99,11 +97,12 @@ class LocalRssRepository @Inject constructor(
return withContext(dispatcherDefault) { return withContext(dispatcherDefault) {
val preTime = System.currentTimeMillis() val preTime = System.currentTimeMillis()
val accountId = context.currentAccountId val accountId = context.currentAccountId
val articles = mutableListOf<Article>()
feedDao.queryAll(accountId) feedDao.queryAll(accountId)
.also { coroutineWorker.setProgress(setIsSyncing(true)) } .also { coroutineWorker.setProgress(setIsSyncing(true)) }
.map { feed -> async { syncFeed(feed) } } // For ParseRSS v0.5.0 only
.awaitAll() .map { feed -> syncFeed(feed) }
//.map { feed -> async { syncFeed(feed) } }
//.awaitAll()
.forEach { .forEach {
if (it.isNotify) { if (it.isNotify) {
notify(articleDao.insertIfNotExist(it.articles)) notify(articleDao.insertIfNotExist(it.articles))
@ -111,8 +110,6 @@ class LocalRssRepository @Inject constructor(
articleDao.insertIfNotExist(it.articles) articleDao.insertIfNotExist(it.articles)
} }
} }
// articleDao.insertList(articles)
Log.i("RlOG", "onCompletion: ${System.currentTimeMillis() - preTime}") Log.i("RlOG", "onCompletion: ${System.currentTimeMillis() - preTime}")
accountDao.queryById(accountId)?.let { account -> accountDao.queryById(accountId)?.let { account ->
accountDao.update( accountDao.update(
@ -167,10 +164,11 @@ class LocalRssRepository @Inject constructor(
private suspend fun syncFeed(feed: Feed): ArticleNotify { private suspend fun syncFeed(feed: Feed): ArticleNotify {
val latest = articleDao.queryLatestByFeedId(context.currentAccountId, feed.id) val latest = articleDao.queryLatestByFeedId(context.currentAccountId, feed.id)
var articles: List<Article>? = null val articles: List<Article>?
try { try {
articles = rssHelper.queryRssXml(feed, latest?.link) articles = rssHelper.queryRssXml(feed, latest?.link)
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace()
Log.e("RLog", "queryRssXml[${feed.name}]: ${e.message}") Log.e("RLog", "queryRssXml[${feed.name}]: ${e.message}")
return ArticleNotify(listOf(), false) return ArticleNotify(listOf(), false)
} }

View File

@ -86,7 +86,7 @@ class RssHelper @Inject constructor(
val parseRss = rssNetworkDataSource.parseRss(feed.url) val parseRss = rssNetworkDataSource.parseRss(feed.url)
parseRss.items.forEach { parseRss.items.forEach {
if (latestLink != null && latestLink == it.link) return@withContext a 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( a.add(
Article( Article(
id = accountId.spacerDollar(UUID.randomUUID().toString()), id = accountId.spacerDollar(UUID.randomUUID().toString()),

View File

@ -1,7 +1,10 @@
package me.ash.reader.ui.page.common package me.ash.reader.ui.page.common
import androidx.compose.animation.ExperimentalAnimationApi import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.background
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import com.google.accompanist.navigation.animation.AnimatedNavHost import com.google.accompanist.navigation.animation.AnimatedNavHost
@ -31,6 +34,7 @@ fun HomeEntry() {
} }
AnimatedNavHost( AnimatedNavHost(
modifier = Modifier.background(MaterialTheme.colorScheme.surface),
navController = navController, navController = navController,
startDestination = if (context.isFirstLaunch) RouteName.STARTUP else RouteName.HOME, startDestination = if (context.isFirstLaunch) RouteName.STARTUP else RouteName.HOME,
) { ) {