pull/36/head
kunfei 5 years ago
parent 498cbf99a5
commit 4ff6ea6653
  1. 8
      app/src/main/java/io/legado/app/data/entities/RssSource.kt
  2. 348
      app/src/main/java/io/legado/app/ui/book/source/edit/SourceEditActivity.kt
  3. 29
      app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt
  4. 15
      app/src/main/res/values/strings.xml

@ -16,11 +16,13 @@ data class RssSource(
var ruleGuid: String? = null,
var ruleTitle: String? = null,
var ruleAuthor: String? = null,
var ruleLink: String? = null,
var rulePubDate: String? = null,
//类别
var ruleCategories: String? = null,
//描述
var ruleDescription: String? = null,
var ruleContent: String? = null,
var ruleImage: String? = null,
var ruleCategories: String? = null,
var ruleContent: String? = null,
var ruleLink: String? = null,
var customOrder: Int = 0
) : Parcelable

@ -146,322 +146,92 @@ class SourceEditActivity :
cb_is_enable_find.isChecked = it.enabledExplore
}
//基本信息
with(bookSource) {
sourceEntities.clear()
sourceEntities
.add(
EditEntity(
"bookSourceUrl",
this?.bookSourceUrl,
R.string.book_source_url
)
)
sourceEntities
.add(
EditEntity(
"bookSourceName",
this?.bookSourceName,
R.string.book_source_name
)
)
sourceEntities.add(
searchEntities.apply {
add(EditEntity("bookSourceUrl", bookSource?.bookSourceUrl, R.string.book_source_url))
add(EditEntity("bookSourceName", bookSource?.bookSourceName, R.string.book_source_name))
add(
EditEntity(
"bookSourceGroup",
this?.bookSourceGroup,
bookSource?.bookSourceGroup,
R.string.book_source_group
)
)
sourceEntities
.add(
EditEntity(
"loginUrl",
this?.loginUrl,
R.string.book_source_login_url
)
)
sourceEntities
.add(
EditEntity(
"bookUrlPattern",
this?.bookUrlPattern,
R.string.book_url_pattern
)
)
sourceEntities.add(
EditEntity(
"header",
this?.header,
R.string.source_http_header
)
)
add(EditEntity("loginUrl", bookSource?.loginUrl, R.string.book_source_login_url))
add(EditEntity("bookUrlPattern", bookSource?.bookUrlPattern, R.string.book_url_pattern))
add(EditEntity("header", bookSource?.header, R.string.source_http_header))
}
//搜索
with(bookSource?.getSearchRule()) {
(bookSource?.getSearchRule()).let { searchRule ->
searchEntities.clear()
searchEntities
.add(
EditEntity(
"searchUrl",
bookSource?.searchUrl,
R.string.rule_search_url
)
)
searchEntities.add(
EditEntity(
"bookList",
this?.bookList,
R.string.rule_book_list
)
)
searchEntities.add(
EditEntity(
"name",
this?.name,
R.string.rule_book_name
)
)
searchEntities.add(
EditEntity(
"author",
this?.author,
R.string.rule_book_author
)
)
searchEntities.add(
EditEntity(
"kind",
this?.kind,
R.string.rule_book_kind
)
)
searchEntities.add(
EditEntity(
"wordCount",
this?.wordCount,
R.string.rule_word_count
)
)
searchEntities
.add(
EditEntity(
"lastChapter",
this?.lastChapter,
R.string.rule_last_chapter
)
)
searchEntities.add(
EditEntity(
"intro",
this?.intro,
R.string.rule_book_intro
)
)
searchEntities.add(
EditEntity(
"coverUrl",
this?.coverUrl,
R.string.rule_cover_url
)
)
searchEntities.add(
EditEntity(
"bookUrl",
this?.bookUrl,
R.string.rule_book_url
)
)
searchEntities.apply {
add(EditEntity("searchUrl", bookSource?.searchUrl, R.string.rule_search_url))
add(EditEntity("bookList", searchRule?.bookList, R.string.rule_book_list))
add(EditEntity("name", searchRule?.name, R.string.rule_book_name))
add(EditEntity("author", searchRule?.author, R.string.rule_book_author))
add(EditEntity("kind", searchRule?.kind, R.string.rule_book_kind))
add(EditEntity("wordCount", searchRule?.wordCount, R.string.rule_word_count))
add(EditEntity("lastChapter", searchRule?.lastChapter, R.string.rule_last_chapter))
add(EditEntity("intro", searchRule?.intro, R.string.rule_book_intro))
add(EditEntity("coverUrl", searchRule?.coverUrl, R.string.rule_cover_url))
add(EditEntity("bookUrl", searchRule?.bookUrl, R.string.rule_book_url))
}
}
//详情页
with(bookSource?.getBookInfoRule()) {
(bookSource?.getBookInfoRule()).let { infoRule ->
infoEntities.clear()
infoEntities.add(
EditEntity(
"init",
this?.init,
R.string.rule_book_info_init
)
)
infoEntities.add(
EditEntity(
"name",
this?.name,
R.string.rule_book_name
)
)
infoEntities.add(
EditEntity(
"author",
this?.author,
R.string.rule_book_author
)
)
infoEntities.add(
EditEntity(
"coverUrl",
this?.coverUrl,
R.string.rule_cover_url
)
)
infoEntities.add(
EditEntity(
"intro",
this?.intro,
R.string.rule_book_intro
)
)
infoEntities.add(
EditEntity(
"kind",
this?.kind,
R.string.rule_book_kind
)
)
infoEntities.add(
EditEntity(
"wordCount",
this?.wordCount,
R.string.rule_word_count
)
)
infoEntities.add(
EditEntity(
"lastChapter",
this?.lastChapter,
R.string.rule_last_chapter
)
)
infoEntities.add(
EditEntity(
"tocUrl",
this?.tocUrl,
R.string.rule_toc_url
)
)
infoEntities.apply {
add(EditEntity("init", infoRule?.init, R.string.rule_book_info_init))
add(EditEntity("name", infoRule?.name, R.string.rule_book_name))
add(EditEntity("author", infoRule?.author, R.string.rule_book_author))
add(EditEntity("coverUrl", infoRule?.coverUrl, R.string.rule_cover_url))
add(EditEntity("intro", infoRule?.intro, R.string.rule_book_intro))
add(EditEntity("kind", infoRule?.kind, R.string.rule_book_kind))
add(EditEntity("wordCount", infoRule?.wordCount, R.string.rule_word_count))
add(EditEntity("lastChapter", infoRule?.lastChapter, R.string.rule_last_chapter))
add(EditEntity("tocUrl", infoRule?.tocUrl, R.string.rule_toc_url))
}
}
//目录页
with(bookSource?.getTocRule()) {
(bookSource?.getTocRule()).let { tocRule ->
tocEntities.clear()
tocEntities.add(
EditEntity(
"chapterList",
this?.chapterList,
R.string.rule_chapter_list
)
)
tocEntities.add(
EditEntity(
"chapterName",
this?.chapterName,
R.string.rule_chapter_name
)
)
tocEntities.add(
EditEntity(
"chapterUrl",
this?.chapterUrl,
R.string.rule_chapter_url
)
)
tocEntities.add(
EditEntity(
"nextTocUrl",
this?.nextTocUrl,
R.string.rule_next_toc_url
)
)
tocEntities.apply {
add(EditEntity("chapterList", tocRule?.chapterList, R.string.rule_chapter_list))
add(EditEntity("chapterName", tocRule?.chapterName, R.string.rule_chapter_name))
add(EditEntity("chapterUrl", tocRule?.chapterUrl, R.string.rule_chapter_url))
add(EditEntity("nextTocUrl", tocRule?.nextTocUrl, R.string.rule_next_toc_url))
}
}
//正文页
with(bookSource?.getContentRule()) {
(bookSource?.getContentRule()).let { contentRule ->
contentEntities.clear()
contentEntities.add(
EditEntity(
"content",
this?.content,
R.string.rule_book_content
)
)
contentEntities.add(
contentEntities.apply {
add(EditEntity("content", contentRule?.content, R.string.rule_book_content))
add(
EditEntity(
"nextContentUrl",
this?.nextContentUrl,
contentRule?.nextContentUrl,
R.string.rule_content_url_next
)
)
}
}
//发现
with(bookSource?.getExploreRule()) {
(bookSource?.getExploreRule()).let { exploreRule ->
findEntities.clear()
findEntities.add(
EditEntity(
"exploreUrl",
bookSource?.exploreUrl,
R.string.rule_find_url
)
)
findEntities.add(
EditEntity(
"bookList",
this?.bookList,
R.string.rule_book_list
)
)
findEntities.add(
EditEntity(
"name",
this?.name,
R.string.rule_book_name
)
)
findEntities.add(
EditEntity(
"author",
this?.author,
R.string.rule_book_author
)
)
findEntities.add(
EditEntity(
"kind",
this?.kind,
R.string.rule_book_kind
)
)
findEntities.add(
EditEntity(
"wordCount",
this?.wordCount,
R.string.rule_word_count
)
)
findEntities.add(
EditEntity(
"intro",
this?.intro,
R.string.rule_book_intro
)
)
findEntities.add(
EditEntity(
"lastChapter",
this?.lastChapter,
R.string.rule_last_chapter
)
)
findEntities.add(
EditEntity(
"coverUrl",
this?.coverUrl,
R.string.rule_cover_url
)
)
findEntities.add(
EditEntity(
"bookUrl",
this?.bookUrl,
R.string.rule_book_url
)
)
findEntities.apply {
add(EditEntity("exploreUrl", bookSource?.exploreUrl, R.string.rule_find_url))
add(EditEntity("bookList", exploreRule?.bookList, R.string.rule_book_list))
add(EditEntity("name", exploreRule?.name, R.string.rule_book_name))
add(EditEntity("author", exploreRule?.author, R.string.rule_book_author))
add(EditEntity("kind", exploreRule?.kind, R.string.rule_book_kind))
add(EditEntity("wordCount", exploreRule?.wordCount, R.string.rule_word_count))
add(EditEntity("intro", exploreRule?.intro, R.string.rule_book_intro))
add(EditEntity("lastChapter", exploreRule?.lastChapter, R.string.rule_last_chapter))
add(EditEntity("coverUrl", exploreRule?.coverUrl, R.string.rule_cover_url))
add(EditEntity("bookUrl", exploreRule?.bookUrl, R.string.rule_book_url))
}
}
setEditEntities(0)
}

@ -12,6 +12,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.R
import io.legado.app.base.VMBaseActivity
import io.legado.app.constant.AppConst
import io.legado.app.data.entities.EditEntity
import io.legado.app.data.entities.RssSource
import io.legado.app.lib.theme.ATH
import io.legado.app.ui.widget.KeyboardToolPop
@ -28,6 +29,7 @@ class RssSourceEditActivity :
private var mIsSoftKeyBoardShowing = false
private lateinit var adapter: RssSourceEditAdapter
private val sourceEntities: ArrayList<EditEntity> = ArrayList()
override val viewModel: RssSourceEditViewModel
get() = getViewModel(RssSourceEditViewModel::class.java)
@ -69,6 +71,33 @@ class RssSourceEditActivity :
}
private fun upRecyclerView(rssSource: RssSource?) {
sourceEntities.clear()
sourceEntities.apply {
add(EditEntity("sourceName", rssSource?.sourceName, R.string.rss_source_name))
add(EditEntity("sourceUrl", rssSource?.sourceUrl, R.string.rss_source_url))
add(EditEntity("iconUrl", rssSource?.iconUrl, R.string.rss_source_icon))
add(EditEntity("ruleTitle", rssSource?.ruleTitle, R.string.rss_rule_title))
add(EditEntity("ruleAuthor", rssSource?.ruleAuthor, R.string.rss_rule_author))
add(EditEntity("ruleGuid", rssSource?.ruleGuid, R.string.rss_rule_guid))
add(EditEntity("rulePubDate", rssSource?.rulePubDate, R.string.rss_rule_date))
add(
EditEntity(
"ruleCategories",
rssSource?.ruleCategories,
R.string.rss_rule_categories
)
)
add(
EditEntity(
"ruleDescription",
rssSource?.ruleDescription,
R.string.rss_rule_description
)
)
add(EditEntity("ruleImage", rssSource?.ruleImage, R.string.rss_rule_image))
add(EditEntity("ruleContent", rssSource?.ruleContent, R.string.rss_rule_content))
add(EditEntity("ruleLink", rssSource?.ruleLink, R.string.rss_rule_link))
}
}

@ -375,6 +375,21 @@
<string name="rule_content_url_next">正文下一页URL规则(nextContentUrl)</string>
<!--book source end-->
<!-- rss source start-->
<string name="rss_source_name">名称</string>
<string name="rss_source_url">url</string>
<string name="rss_source_icon">图标</string>
<string name="rss_rule_title">标题</string>
<string name="rss_rule_author">作者</string>
<string name="rss_rule_guid">guid</string>
<string name="rss_rule_date">时间</string>
<string name="rss_rule_categories">类别</string>
<string name="rss_rule_description">描述</string>
<string name="rss_rule_image">图片url</string>
<string name="rss_rule_content">内容</string>
<string name="rss_rule_link">链接</string>
<!-- rss source end-->
<!--error string start-->
<string name="error_no_source">没有书源</string>
<string name="error_get_book_info">书籍信息获取失败</string>

Loading…
Cancel
Save