修复数据库报错

书源管理增加启用/禁用所选发现
pull/42/head
Celeter 6 years ago
parent b78fd824e9
commit 870c3968f0
  1. 6
      app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt
  2. 2
      app/src/main/java/io/legado/app/data/entities/RssArticle.kt
  3. 2
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
  4. 12
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt
  5. 10
      app/src/main/res/menu/book_source.xml
  6. 2
      app/src/main/res/values/strings.xml

@ -35,6 +35,12 @@ interface BookSourceDao {
@Query("update book_sources set enabled = 0 where bookSourceUrl in (:sourceUrls)")
fun disableSection(vararg sourceUrls: String)
@Query("update book_sources set enabledExplore = 1 where bookSourceUrl in (:sourceUrls)")
fun enableSectionExplore(vararg sourceUrls: String)
@Query("update book_sources set enabledExplore = 0 where bookSourceUrl in (:sourceUrls)")
fun disableSectionExplore(vararg sourceUrls: String)
@Query("delete from book_sources where bookSourceUrl in (:sourceUrls)")
fun delSection(vararg sourceUrls: String)

@ -13,7 +13,7 @@ data class RssArticle(
var title: String = "",
var order: Long = 0,
var author: String? = null,
var link: String? = null,
var link: String = "",
var pubDate: String? = null,
var description: String? = null,
var content: String? = null,

@ -86,6 +86,8 @@ class BookSourceActivity : VMBaseActivity<BookSourceViewModel>(R.layout.activity
R.id.menu_revert_selection -> adapter.revertSelection()
R.id.menu_enable_selection -> viewModel.enableSelection(adapter.getSelectionIds())
R.id.menu_disable_selection -> viewModel.disableSelection(adapter.getSelectionIds())
R.id.menu_enable_explore -> viewModel.enableSelectExplore(adapter.getSelectionIds())
R.id.menu_disable_explore -> viewModel.disableSelectExplore(adapter.getSelectionIds())
R.id.menu_del_selection -> viewModel.delSelection(adapter.getSelectionIds())
R.id.menu_check_source ->
startService<CheckSourceService>(Pair("data", adapter.getSelectionIds()))

@ -52,6 +52,18 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application)
}
}
fun enableSelectExplore(ids: LinkedHashSet<String>) {
execute {
App.db.bookSourceDao().enableSectionExplore(*ids.toTypedArray())
}
}
fun disableSelectExplore(ids: LinkedHashSet<String>) {
execute {
App.db.bookSourceDao().disableSectionExplore(*ids.toTypedArray())
}
}
fun delSelection(ids: LinkedHashSet<String>) {
execute {
App.db.bookSourceDao().delSection(*ids.toTypedArray())

@ -32,6 +32,16 @@
android:title="@string/disable_selection"
app:showAsAction="never" />
<item
android:id="@+id/menu_enable_explore"
android:title="@string/enable_explore"
app:showAsAction="never" />
<item
android:id="@+id/menu_disable_explore"
android:title="@string/disable_explore"
app:showAsAction="never" />
<item
android:id="@+id/menu_del_selection"
android:title="@string/del_select"

@ -526,6 +526,8 @@
<string name="add_group">添加分组</string>
<string name="add_replace_rule">新建替换</string>
<string name="group">分组</string>
<string name="enable_explore">启用所选发现</string>
<string name="disable_explore">禁用所选发现</string>
<string name="enable_selection">启用所选</string>
<string name="disable_selection">禁用所选</string>
<string name="tts">TTS</string>

Loading…
Cancel
Save