pull/42/head
kunfei 5 years ago
parent 8c66391703
commit 5ee320e440
  1. 4
      app/src/main/java/io/legado/app/data/dao/RssArticleDao.kt
  2. 2
      app/src/main/java/io/legado/app/data/entities/RssArticle.kt
  3. 2
      app/src/main/java/io/legado/app/ui/rss/article/RssArticlesActivity.kt
  4. 6
      app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt

@ -7,8 +7,8 @@ import io.legado.app.data.entities.RssArticle
@Dao
interface RssArticleDao {
@Query("select * from rssArticles where origin = :origin and title = :title")
fun get(origin: String, title: String): RssArticle?
@Query("select * from rssArticles where origin = :origin and link = :link")
fun get(origin: String, link: String): RssArticle?
@Query("select * from rssArticles where origin = :origin order by `order` desc")
fun liveByOrigin(origin: String): LiveData<List<RssArticle>>

@ -6,7 +6,7 @@ import androidx.room.Ignore
@Entity(
tableName = "rssArticles",
primaryKeys = ["origin", "title"]
primaryKeys = ["origin", "link"]
)
data class RssArticle(
var origin: String = "",

@ -122,7 +122,7 @@ class RssArticlesActivity : VMBaseActivity<RssArticlesViewModel>(R.layout.activi
viewModel.read(rssArticle)
startActivity<ReadRssActivity>(
Pair("origin", rssArticle.origin),
Pair("title", rssArticle.title)
Pair("link", rssArticle.link)
)
}
}

@ -20,13 +20,13 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application) {
fun initData(intent: Intent) {
execute {
val origin = intent.getStringExtra("origin")
val title = intent.getStringExtra("title")
val link = intent.getStringExtra("link")
val rssSource = App.db.rssSourceDao().getByKey(origin)
rssSource?.let {
rssSourceLiveData.postValue(it)
}
if (origin != null && title != null) {
App.db.rssArticleDao().get(origin, title)?.let { rssArticle ->
if (origin != null && link != null) {
App.db.rssArticleDao().get(origin, link)?.let { rssArticle ->
rssArticleLiveData.postValue(rssArticle)
if (!rssArticle.description.isNullOrBlank()) {
contentLiveData.postValue(rssArticle.description)

Loading…
Cancel
Save