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 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<Article>()
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<Article>? = null
val articles: List<Article>?
try {
articles = rssHelper.queryRssXml(feed, latest?.link)
} catch (e: Exception) {
e.printStackTrace()
Log.e("RLog", "queryRssXml[${feed.name}]: ${e.message}")
return ArticleNotify(listOf(), false)
}

View File

@ -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()),

View File

@ -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,
) {