mirror of https://github.com/Ashinch/ReadYou.git
Support RSS Atom
This commit is contained in:
parent
840970bfe2
commit
2d7ef057f3
|
@ -14,6 +14,8 @@ 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,10 +101,8 @@ class LocalRssRepository @Inject constructor(
|
|||
val accountId = context.currentAccountId
|
||||
feedDao.queryAll(accountId)
|
||||
.also { coroutineWorker.setProgress(setIsSyncing(true)) }
|
||||
// For ParseRSS v0.5.0 only
|
||||
.map { feed -> syncFeed(feed) }
|
||||
//.map { feed -> async { syncFeed(feed) } }
|
||||
//.awaitAll()
|
||||
.map { feed -> async { syncFeed(feed) } }
|
||||
.awaitAll()
|
||||
.forEach {
|
||||
if (it.isNotify) {
|
||||
notify(articleDao.insertIfNotExist(it.articles))
|
||||
|
|
|
@ -86,13 +86,13 @@ 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:\n${feed.name},${feed.url}\n${it.title}")
|
||||
Log.i("RLog", "request rss:\n${feed.name},${feed.url}\n${it.title}\n${it.link}\n")
|
||||
a.add(
|
||||
Article(
|
||||
id = accountId.spacerDollar(UUID.randomUUID().toString()),
|
||||
accountId = accountId,
|
||||
feedId = feed.id,
|
||||
date = it.publishDate.toString().let {
|
||||
date = (it.publishDate ?: it.lastUpdated).toString().let {
|
||||
try {
|
||||
Date(it)
|
||||
} catch (e: IllegalArgumentException) {
|
||||
|
@ -100,9 +100,10 @@ class RssHelper @Inject constructor(
|
|||
}
|
||||
},
|
||||
title = Html.fromHtml(it.title.toString()).toString(),
|
||||
author = it.author,
|
||||
rawDescription = it.description.toString(),
|
||||
shortDescription = (Readability4JExtended("", it.description.toString())
|
||||
author = it.author?.name,
|
||||
rawDescription = it.description ?: it.summary ?: "",
|
||||
shortDescription =
|
||||
(Readability4JExtended("", it.description ?: it.summary ?: "")
|
||||
.parse().textContent ?: "").take(100).trim(),
|
||||
link = it.link ?: "",
|
||||
)
|
||||
|
@ -163,15 +164,17 @@ class RssHelper @Inject constructor(
|
|||
|
||||
private fun parseDate(
|
||||
inputDate: String, patterns: Array<String?> = arrayOf(
|
||||
"yyyy-MM-dd'T'HH:mm:ss'Z'",
|
||||
"yyyy-MM-dd",
|
||||
"yyyy-MM-dd HH:mm:ss",
|
||||
"yyyyMMdd",
|
||||
"yyyy/MM/dd",
|
||||
"yyyy年MM月dd日",
|
||||
"yyyy MM dd"
|
||||
"yyyy MM dd",
|
||||
)
|
||||
): Date? {
|
||||
val df = SimpleDateFormat()
|
||||
df.timeZone = TimeZone.getDefault()
|
||||
for (pattern in patterns) {
|
||||
df.applyPattern(pattern)
|
||||
df.isLenient = false
|
||||
|
|
|
@ -70,9 +70,7 @@ fun WebView(
|
|||
): Boolean {
|
||||
if (null == request?.url) return false
|
||||
val url = request.url.toString()
|
||||
context.startActivity(
|
||||
Intent(Intent.ACTION_VIEW, Uri.parse(url))
|
||||
)
|
||||
if (url.isNotEmpty()) context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
@ -23,9 +23,13 @@ fun Header(
|
|||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.roundClick {
|
||||
context.startActivity(
|
||||
Intent(Intent.ACTION_VIEW, Uri.parse(articleWithFeed.article.link))
|
||||
)
|
||||
articleWithFeed.article.link .let {
|
||||
if (it.isNotEmpty()) {
|
||||
context.startActivity(
|
||||
Intent(Intent.ACTION_VIEW, Uri.parse(articleWithFeed.article.link))
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(12.dp)
|
||||
) {
|
||||
|
|
|
@ -12,7 +12,7 @@ buildscript {
|
|||
profileinstaller = '1.2.0-alpha02'
|
||||
retrofit2 = '2.9.0'
|
||||
coil = '2.0.0-rc03'
|
||||
parseRSS = '0.5.0'
|
||||
parseRSS = '0.6.0'
|
||||
readability4j = '1.0.8'
|
||||
opmlParser = '2.2.0'
|
||||
androidSVG = '1.4'
|
||||
|
|
Loading…
Reference in New Issue