pull/48/head
kunfei 5 years ago
parent 3d6c22d1b7
commit 7f443158cf
  1. 36
      app/src/main/java/io/legado/app/data/entities/BookSource.kt
  2. 32
      app/src/main/java/io/legado/app/data/entities/RssSource.kt
  3. 15
      app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt
  4. 15
      app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt
  5. 2
      app/src/main/res/values/strings.xml

@ -169,27 +169,27 @@ data class BookSource(
return AppConst.SCRIPT_ENGINE.eval(jsStr, bindings)
}
fun equal(source: BookSource?): Boolean {
if (source == null) {
return false
}
return bookSourceName == source.bookSourceName
&& bookSourceUrl == source.bookSourceUrl
&& bookSourceGroup == source.bookSourceGroup
fun equal(source: BookSource): Boolean {
return equal(bookSourceName, source.bookSourceName)
&& equal(bookSourceUrl, source.bookSourceUrl)
&& equal(bookSourceGroup, source.bookSourceGroup)
&& bookSourceType == source.bookSourceType
&& bookUrlPattern == source.bookUrlPattern
&& equal(bookUrlPattern, source.bookUrlPattern)
&& enabled == source.enabled
&& enabledExplore == source.enabledExplore
&& header == source.header
&& loginUrl == source.loginUrl
&& lastUpdateTime == source.lastUpdateTime
&& exploreUrl == source.exploreUrl
&& searchUrl == source.searchUrl
&& ruleSearch == source.ruleSearch
&& ruleExplore == source.ruleExplore
&& ruleBookInfo == source.ruleBookInfo
&& ruleToc == source.ruleToc
&& ruleContent == source.ruleContent
&& equal(header, source.header)
&& equal(loginUrl, source.loginUrl)
&& equal(exploreUrl, source.exploreUrl)
&& equal(searchUrl, source.searchUrl)
&& getSearchRule() == source.getSearchRule()
&& getExploreRule() == source.getExploreRule()
&& getBookInfoRule() == source.getBookInfoRule()
&& getTocRule() == source.getTocRule()
&& getContentRule() == source.getContentRule()
}
private fun equal(a: String?, b: String?): Boolean {
return a == b || (a.isNullOrEmpty() && b.isNullOrEmpty())
}
data class ExploreKind(

@ -32,27 +32,25 @@ data class RssSource(
var customOrder: Int = 0
) : Parcelable {
fun equal(source: RssSource?): Boolean {
if (source == null) {
return false
} else {
return sourceUrl == source.sourceUrl
&& sourceName == source.sourceName
&& sourceIcon == source.sourceIcon
fun equal(source: RssSource): Boolean {
return equal(sourceUrl, source.sourceUrl)
&& equal(sourceIcon, source.sourceIcon)
&& enabled == source.enabled
&& sourceGroup == source.sourceGroup
&& ruleArticles == source.ruleArticles
&& ruleNextPage == source.ruleNextPage
&& ruleTitle == source.ruleTitle
&& rulePubDate == source.rulePubDate
&& ruleCategories == source.ruleCategories
&& ruleDescription == source.ruleDescription
&& ruleLink == source.ruleLink
&& ruleContent == source.ruleContent
&& equal(sourceGroup, source.sourceGroup)
&& equal(ruleArticles, source.ruleArticles)
&& equal(ruleNextPage, source.ruleNextPage)
&& equal(ruleTitle, source.ruleTitle)
&& equal(rulePubDate, source.rulePubDate)
&& equal(ruleCategories, source.ruleCategories)
&& equal(ruleDescription, source.ruleDescription)
&& equal(ruleLink, source.ruleLink)
&& equal(ruleContent, source.ruleContent)
&& enableJs == source.enableJs
&& loadWithBaseUrl == source.loadWithBaseUrl
&& customOrder == source.customOrder
}
private fun equal(a: String?, b: String?): Boolean {
return a == b || (a.isNullOrEmpty() && b.isNullOrEmpty())
}
}

@ -21,8 +21,6 @@ import io.legado.app.data.entities.BookSource
import io.legado.app.data.entities.EditEntity
import io.legado.app.data.entities.rule.*
import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.dialogs.noButton
import io.legado.app.lib.dialogs.yesButton
import io.legado.app.lib.theme.ATH
import io.legado.app.ui.book.source.debug.BookSourceDebugActivity
import io.legado.app.ui.widget.KeyboardToolPop
@ -114,16 +112,13 @@ class BookSourceEditActivity :
override fun finish() {
val source = getSource()
if (!source.equal(viewModel.bookSource)) {
alert(R.string.exit_no_save) {
yesButton {
if (checkSource(source)) {
viewModel.save(source) {
if (!source.equal(viewModel.bookSource ?: BookSource())) {
alert(R.string.exit) {
messageResource = R.string.exit_no_save
positiveButton(R.string.yes)
negativeButton(R.string.no) {
super.finish()
}
}
}
noButton { }
}.show().applyTint()
} else {
super.finish()

@ -19,8 +19,6 @@ 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.dialogs.alert
import io.legado.app.lib.dialogs.noButton
import io.legado.app.lib.dialogs.yesButton
import io.legado.app.lib.theme.ATH
import io.legado.app.ui.rss.source.debug.RssSourceDebugActivity
import io.legado.app.ui.widget.KeyboardToolPop
@ -56,16 +54,13 @@ class RssSourceEditActivity :
override fun finish() {
val source = getRssSource()
if (!source.equal(viewModel.rssSource)) {
alert(R.string.exit_no_save) {
yesButton {
if (checkSource(source)) {
viewModel.save(source) {
if (!source.equal(viewModel.rssSource ?: RssSource())) {
alert(R.string.exit) {
messageResource = R.string.exit_no_save
positiveButton(R.string.yes)
negativeButton(R.string.no) {
super.finish()
}
}
}
noButton { }
}.show().applyTint()
} else {
super.finish()

@ -59,7 +59,7 @@
<string name="about">关于</string>
<string name="donate">捐赠</string>
<string name="exit">退出</string>
<string name="exit_no_save">是否保存</string>
<string name="exit_no_save">尚未保存,是否继续编辑</string>
<string name="read_style">阅读样式设置</string>
<string name="version">版本</string>
<string name="local">本地</string>

Loading…
Cancel
Save