From 19358f38473b8d914f072c5613fc75cc35776edf Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 13 Jul 2019 07:56:54 +0800 Subject: [PATCH] up --- .../io/legado/app/data/entities/BookSource.kt | 1 + .../app/data/entities/rule/BookInfoRule.kt | 1 - .../io/legado/app/help/storage/Restore.kt | 2 +- .../app/ui/sourceedit/SourceEditActivity.kt | 66 ++++++++++++------- 4 files changed, 43 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/entities/BookSource.kt b/app/src/main/java/io/legado/app/data/entities/BookSource.kt index eaf37c9be..df10b0a06 100644 --- a/app/src/main/java/io/legado/app/data/entities/BookSource.kt +++ b/app/src/main/java/io/legado/app/data/entities/BookSource.kt @@ -26,6 +26,7 @@ data class BookSource( @PrimaryKey var bookSourceUrl: String = "", // 地址,包括 http/https var bookSourceType: Int = 0, // 类型,0 文本,1 音频 + var infoUrlPattern: String? = null, var customOrder: Int = 0, // 手动排序编号 var enabled: Boolean = true, // 是否启用 var enabledExplore: Boolean = true, //启用发现 diff --git a/app/src/main/java/io/legado/app/data/entities/rule/BookInfoRule.kt b/app/src/main/java/io/legado/app/data/entities/rule/BookInfoRule.kt index fd213d6ae..a28f3c6e6 100644 --- a/app/src/main/java/io/legado/app/data/entities/rule/BookInfoRule.kt +++ b/app/src/main/java/io/legado/app/data/entities/rule/BookInfoRule.kt @@ -1,7 +1,6 @@ package io.legado.app.data.entities.rule data class BookInfoRule( - var urlPattern: String? = null, var init: String? = null, var name: String? = null, var author: String? = null, diff --git a/app/src/main/java/io/legado/app/help/storage/Restore.kt b/app/src/main/java/io/legado/app/help/storage/Restore.kt index ea889688c..a502ce82e 100644 --- a/app/src/main/java/io/legado/app/help/storage/Restore.kt +++ b/app/src/main/java/io/legado/app/help/storage/Restore.kt @@ -105,6 +105,7 @@ object Restore { source.bookSourceName = jsonItem.readString("bookSourceName") ?: "" source.bookSourceGroup = jsonItem.readString("bookSourceGroup") ?: "" source.loginUrl = jsonItem.readString("loginUrl") + source.infoUrlPattern = jsonItem.readString("ruleBookUrlPattern") val searchRule = SearchRule( searchUrl = jsonItem.readString("ruleSearchUrl"), bookList = jsonItem.readString("ruleSearchList"), @@ -130,7 +131,6 @@ object Restore { ) source.ruleExplore = GSON.toJson(exploreRule) val bookInfoRule = BookInfoRule( - urlPattern = jsonItem.readString("ruleBookUrlPattern"), init = jsonItem.readString("ruleBookInfoInit"), name = jsonItem.readString("ruleBookName"), author = jsonItem.readString("ruleBookAuthor"), diff --git a/app/src/main/java/io/legado/app/ui/sourceedit/SourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/sourceedit/SourceEditActivity.kt index aa7bab2d6..ea30d500b 100644 --- a/app/src/main/java/io/legado/app/ui/sourceedit/SourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/sourceedit/SourceEditActivity.kt @@ -112,12 +112,46 @@ class SourceEditActivity : BaseActivity(false), KeyboardToo cb_is_enable.isChecked = it.enabled cb_is_enable_find.isChecked = it.enabledExplore } - sourceEditList.clear() - sourceEditList.add(EditEntity("bookSourceUrl", bookSource?.bookSourceUrl, R.string.book_source_url)) - sourceEditList.add(EditEntity("bookSourceName", bookSource?.bookSourceName, R.string.book_source_name)) - sourceEditList.add(EditEntity("bookSourceGroup", bookSource?.bookSourceGroup, R.string.book_source_group)) - sourceEditList.add(EditEntity("loginUrl", bookSource?.loginUrl, R.string.book_source_login_url)) - sourceEditList.add(EditEntity("header", bookSource?.header, R.string.source_http_header)) + //基本信息 + with(bookSource) { + sourceEditList.clear() + sourceEditList.add( + EditEntity( + "bookSourceUrl", + this?.bookSourceUrl, + R.string.book_source_url + ) + ) + sourceEditList.add( + EditEntity( + "bookSourceName", + this?.bookSourceName, + R.string.book_source_name + ) + ) + sourceEditList.add( + EditEntity( + "bookSourceGroup", + this?.bookSourceGroup, + R.string.book_source_group + ) + ) + sourceEditList.add( + EditEntity( + "loginUrl", + this?.loginUrl, + R.string.book_source_login_url + ) + ) + sourceEditList.add( + EditEntity( + "urlPattern", + this?.infoUrlPattern, + R.string.book_url_pattern + ) + ) + sourceEditList.add(EditEntity("header", this?.header, R.string.source_http_header)) + } //搜索 with(bookSource?.getSearchRule()) { searchEditList.clear() @@ -135,7 +169,6 @@ class SourceEditActivity : BaseActivity(false), KeyboardToo //详情页 with(bookSource?.getBookInfoRule()) { infoEditList.clear() - infoEditList.add(EditEntity("urlPattern", this?.urlPattern, R.string.book_url_pattern)) infoEditList.add(EditEntity("init", this?.init, R.string.rule_book_info_init)) infoEditList.add(EditEntity("name", this?.name, R.string.rule_book_name)) infoEditList.add(EditEntity("author", this?.author, R.string.rule_book_author)) @@ -199,6 +232,7 @@ class SourceEditActivity : BaseActivity(false), KeyboardToo "bookSourceName" -> if (value != null) source.bookSourceName = value!! else return null "bookSourceGroup" -> source.bookSourceGroup = value "loginUrl" -> source.loginUrl = value + "infoUrlPattern" -> source.infoUrlPattern = value "header" -> source.header = value } } @@ -240,24 +274,6 @@ class SourceEditActivity : BaseActivity(false), KeyboardToo for (entity in infoEditList) { with(entity) { when (key) { - "urlPattern" -> bookInfoRule.urlPattern = value - "init" -> bookInfoRule.init = value - "searchName" -> bookInfoRule.name = value - "searchAuthor" -> bookInfoRule.author = value - "searchKind" -> bookInfoRule.kind = value - "searchIntro" -> bookInfoRule.intro = value - "updateTime" -> bookInfoRule.updateTime = value - "wordCount" -> bookInfoRule.wordCount = value - "lastChapter" -> bookInfoRule.lastChapter = value - "coverUrl" -> bookInfoRule.coverUrl = value - "tocUrl" -> bookInfoRule.tocUrl = value - } - } - } - for (entity in infoEditList) { - with(entity) { - when (key) { - "urlPattern" -> bookInfoRule.urlPattern = value "init" -> bookInfoRule.init = value "searchName" -> bookInfoRule.name = value "searchAuthor" -> bookInfoRule.author = value