feat: 优化代码

pull/182/head
kunfei 5 years ago
parent 2c5d968b02
commit 980535d37c
  1. 4
      app/src/main/assets/updateLog.md
  2. 5
      app/src/main/java/io/legado/app/data/dao/RssArticleDao.kt
  3. 2
      app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt

@ -1,7 +1,7 @@
## 更新日志
* 旧版数据导入教程:先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】。
* 请关注[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。
* 弄了个企业公众号[开源阅读](),后面弄好后会把原来的[开源阅读软件]()迁移过来
* 请关注公众号[开源阅读]()支持我,同时关注合作公众号[小说拾遗](),阅读公众号小编。
* 新公众号[开源阅读]()已启用,[开源阅读软件]()备用
**2020/04/02**
* 书架书名和作者作为唯一值

@ -14,9 +14,10 @@ interface RssArticleDao {
@Query(
"""select t1.link, t1.sort, t1.origin, t1.`order`, t1.title, t1.content, t1.description, t1.image, t1.pubDate, ifNull(t2.read, 0) as read
from rssArticles as t1 left join rssReadRecords as t2
on t1.link = t2.record where origin = :origin order by `order` desc"""
on t1.link = t2.record where origin = :origin and sort = :sort
order by `order` desc"""
)
fun liveByOrigin(origin: String): LiveData<List<RssArticle>>
fun liveByOriginSort(origin: String, sort: String): LiveData<List<RssArticle>>
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(vararg rssArticle: RssArticle)

@ -77,7 +77,7 @@ class RssArticlesFragment : VMBaseFragment<RssArticlesViewModel>(R.layout.fragme
private fun initData() {
activityViewModel.url?.let {
rssArticlesData?.removeObservers(this)
rssArticlesData = App.db.rssArticleDao().liveByOrigin(it)
rssArticlesData = App.db.rssArticleDao().liveByOriginSort(it, viewModel.sortName)
rssArticlesData?.observe(viewLifecycleOwner, Observer { list ->
adapter.setItems(list)
})

Loading…
Cancel
Save