This commit is contained in:
kunfei
2022-07-02 15:17:47 +08:00
parent ce41fe1657
commit f421e92b61
4 changed files with 44 additions and 11 deletions
@@ -31,7 +31,14 @@ interface BookSourceDao {
)
fun flowSearchEnabled(searchKey: String): Flow<List<BookSource>>
@Query("select * from book_sources where bookSourceGroup like '%' || :searchKey || '%' order by customOrder asc")
@Query(
"""select * from book_sources
where bookSourceGroup = :searchKey
or bookSourceGroup like :searchKey || ',%'
or bookSourceGroup like '%,' || :searchKey
or bookSourceGroup like '%,' || :searchKey || ',%'
order by customOrder asc"""
)
fun flowGroupSearch(searchKey: String): Flow<List<BookSource>>
@Query("select * from book_sources where enabled = 1 order by customOrder asc")
@@ -50,7 +57,8 @@ interface BookSourceDao {
"""select * from book_sources
where enabledExplore = 1
and trim(exploreUrl) <> ''
and (bookSourceGroup like '%' || :key || '%' or bookSourceName like '%' || :key || '%')
and (bookSourceGroup like '%' || :key || '%'
or bookSourceName like '%' || :key || '%')
order by customOrder asc"""
)
fun flowExplore(key: String): Flow<List<BookSource>>
@@ -59,7 +67,10 @@ interface BookSourceDao {
"""select * from book_sources
where enabledExplore = 1
and trim(exploreUrl) <> ''
and (bookSourceGroup like '%' || :key || '%')
and (bookSourceGroup = :key
or bookSourceGroup like :key || ',%'
or bookSourceGroup like '%,' || :key
or bookSourceGroup like '%,' || :key || ',%')
order by customOrder asc"""
)
fun flowGroupExplore(key: String): Flow<List<BookSource>>
@@ -22,10 +22,23 @@ interface RssSourceDao {
@Query("SELECT * FROM rssSources order by customOrder")
fun flowAll(): Flow<List<RssSource>>
@Query("SELECT * FROM rssSources where sourceName like :key or sourceUrl like :key or sourceGroup like :key order by customOrder")
@Query(
"""SELECT * FROM rssSources
where sourceName like '%' || :key || '%'
or sourceUrl like '%' || :key || '%'
or sourceGroup like '%' || :key || '%'
order by customOrder"""
)
fun flowSearch(key: String): Flow<List<RssSource>>
@Query("SELECT * FROM rssSources where sourceGroup like :key order by customOrder")
@Query(
"""SELECT * FROM rssSources
where (sourceGroup = :key
or sourceGroup like :key || ',%'
or sourceGroup like '%,' || :key
or sourceGroup like '%,' || :key || ',%')
order by customOrder"""
)
fun flowGroupSearch(key: String): Flow<List<RssSource>>
@Query("SELECT * FROM rssSources where enabled = 1 order by customOrder")
@@ -34,12 +47,21 @@ interface RssSourceDao {
@Query(
"""SELECT * FROM rssSources
where enabled = 1
and (sourceName like :searchKey or sourceGroup like :searchKey or sourceUrl like :searchKey)
and (sourceName like '%' || :searchKey || '%'
or sourceGroup like '%' || :searchKey || '%'
or sourceUrl like '%' || :searchKey || '%')
order by customOrder"""
)
fun flowEnabled(searchKey: String): Flow<List<RssSource>>
@Query("SELECT * FROM rssSources where enabled = 1 and sourceGroup like :searchKey order by customOrder")
@Query(
"""SELECT * FROM rssSources
where enabled = 1 and (sourceGroup = :searchKey
or sourceGroup like :searchKey || ',%'
or sourceGroup like '%,' || :searchKey
or sourceGroup like '%,' || :searchKey || ',%')
order by customOrder"""
)
fun flowEnabledByGroup(searchKey: String): Flow<List<RssSource>>
@Query("select distinct sourceGroup from rssSources where trim(sourceGroup) <> ''")
@@ -140,9 +140,9 @@ class RssFragment : VMBaseFragment<RssSourceViewModel>(R.layout.fragment_rss),
searchKey.isNullOrEmpty() -> appDb.rssSourceDao.flowEnabled()
searchKey.startsWith("group:") -> {
val key = searchKey.substringAfter("group:")
appDb.rssSourceDao.flowEnabledByGroup("%$key%")
appDb.rssSourceDao.flowEnabledByGroup(key)
}
else -> appDb.rssSourceDao.flowEnabled("%$searchKey%")
else -> appDb.rssSourceDao.flowEnabled(searchKey)
}.catch {
AppLog.put("订阅界面更新数据出错", it)
}.collect {
@@ -242,10 +242,10 @@ class RssSourceActivity : VMBaseActivity<ActivityRssSourceBinding, RssSourceView
}
searchKey.startsWith("group:") -> {
val key = searchKey.substringAfter("group:")
appDb.rssSourceDao.flowGroupSearch("%$key%")
appDb.rssSourceDao.flowGroupSearch(key)
}
else -> {
appDb.rssSourceDao.flowSearch("%$searchKey%")
appDb.rssSourceDao.flowSearch(searchKey)
}
}.catch {
AppLog.put("订阅源管理界面更新数据出错", it)