pull/43/head^2
kunfei 5 years ago
parent 8d6756202e
commit 73bda2ec01
  1. 12
      app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt
  2. 6
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt

@ -29,14 +29,14 @@ interface BookSourceDao {
@Query("select distinct enabled from book_sources where bookSourceName like :searchKey or bookSourceGroup like :searchKey or bookSourceUrl like :searchKey")
fun searchIsEnable(searchKey: String = ""): List<Boolean>
@Query("update book_sources set enabled = 1 where bookSourceUrl in (:sourceUrls)")
fun enableSection(vararg sourceUrls: String)
@Query("update book_sources set enabled = 1 where bookSourceUrl = :sourceUrl")
fun enableSection(sourceUrl: String)
@Query("update book_sources set enabled = 0 where bookSourceUrl in (:sourceUrls)")
fun disableSection(vararg sourceUrls: String)
@Query("update book_sources set enabled = 0 where bookSourceUrl = :sourceUrl")
fun disableSection(sourceUrl: String)
@Query("delete from book_sources where bookSourceUrl in (:sourceUrls)")
fun delSection(vararg sourceUrls: String)
@Query("delete from book_sources where bookSourceUrl = :sourceUrl")
fun delSection(sourceUrl: String)
@Query("select * from book_sources where enabledExplore = 1 order by customOrder asc")
fun observeFind(): DataSource.Factory<Int, BookSource>

@ -69,8 +69,8 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application)
val sources = App.db.bookSourceDao().noGroup
sources.map { source ->
source.bookSourceGroup = group
App.db.bookSourceDao().update(source)
}
App.db.bookSourceDao().update(*sources.toTypedArray())
}
}
@ -84,8 +84,8 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application)
it.add(newGroup)
source.bookSourceGroup = TextUtils.join(",", it)
}
App.db.bookSourceDao().update(source)
}
App.db.bookSourceDao().update(*sources.toTypedArray())
}
}
@ -98,8 +98,8 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application)
it.remove(group)
source.bookSourceGroup = TextUtils.join(",", it)
}
App.db.bookSourceDao().update(source)
}
App.db.bookSourceDao().update(*sources.toTypedArray())
}
}
}

Loading…
Cancel
Save