updatetime 和 comment 优化

当书源有改动时更新书源的lastupdatetime
改变booksourcecomment位置到booksourcegroup之下
pull/370/head
Jason Yao 4 years ago
parent e9d597c1de
commit 609fb92aee
  1. 2
      app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt
  2. 4
      app/src/main/java/io/legado/app/data/entities/BookSource.kt
  3. 6
      app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt

@ -11,7 +11,7 @@ interface BookSourceDao {
@Query("select * from book_sources order by customOrder asc")
fun liveDataAll(): LiveData<List<BookSource>>
@Query("select * from book_sources where bookSourceName like :searchKey or bookSourceGroup like :searchKey or bookSourceUrl like :searchKey order by customOrder asc")
@Query("select * from book_sources where bookSourceName like :searchKey or bookSourceGroup like :searchKey or bookSourceUrl like :searchKey or bookSourceComment like :searchKey order by customOrder asc")
fun liveDataSearch(searchKey: String = ""): LiveData<List<BookSource>>
@Query("select * from book_sources where enabled = 1 order by customOrder asc")

@ -135,7 +135,7 @@ data class BookSource(
bindings["java"] = this
return AppConst.SCRIPT_ENGINE.eval(jsStr, bindings)
}
fun equal(source: BookSource) =
equal(bookSourceName, source.bookSourceName)
&& equal(bookSourceUrl, source.bookSourceUrl)
@ -156,7 +156,7 @@ data class BookSource(
&& getContentRule() == source.getContentRule()
private fun equal(a: String?, b: String?) = a == b || (a.isNullOrEmpty() && b.isNullOrEmpty())
data class ExploreKind(
var title: String,
var url: String? = null

@ -63,6 +63,9 @@ class BookSourceEditActivity :
override fun onCompatOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.menu_save -> getSource().let { source ->
if (!source.equal(viewModel.bookSource ?: BookSource())){
source.lastUpdateTime = System.currentTimeMillis()
}
if (checkSource(source)) {
viewModel.save(source) { setResult(Activity.RESULT_OK); finish() }
}
@ -170,10 +173,11 @@ class BookSourceEditActivity :
add(EditEntity("bookSourceUrl", source?.bookSourceUrl, R.string.source_url))
add(EditEntity("bookSourceName", source?.bookSourceName, R.string.source_name))
add(EditEntity("bookSourceGroup", source?.bookSourceGroup, R.string.source_group))
add(EditEntity("bookSourceComment", source?.bookSourceComment, R.string.comment))
add(EditEntity("loginUrl", source?.loginUrl, R.string.login_url))
add(EditEntity("bookUrlPattern", source?.bookUrlPattern, R.string.book_url_pattern))
add(EditEntity("header", source?.header, R.string.source_http_header))
add(EditEntity("bookSourceComment", source?.bookSourceComment, R.string.comment))
}
//搜索
val sr = source?.getSearchRule()

Loading…
Cancel
Save