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

@ -32,27 +32,25 @@ data class RssSource(
var customOrder: Int = 0 var customOrder: Int = 0
) : Parcelable { ) : Parcelable {
fun equal(source: RssSource?): Boolean { fun equal(source: RssSource): Boolean {
if (source == null) { return equal(sourceUrl, source.sourceUrl)
return false && equal(sourceIcon, source.sourceIcon)
} else {
return sourceUrl == source.sourceUrl
&& sourceName == source.sourceName
&& sourceIcon == source.sourceIcon
&& enabled == source.enabled && enabled == source.enabled
&& sourceGroup == source.sourceGroup && equal(sourceGroup, source.sourceGroup)
&& ruleArticles == source.ruleArticles && equal(ruleArticles, source.ruleArticles)
&& ruleNextPage == source.ruleNextPage && equal(ruleNextPage, source.ruleNextPage)
&& ruleTitle == source.ruleTitle && equal(ruleTitle, source.ruleTitle)
&& rulePubDate == source.rulePubDate && equal(rulePubDate, source.rulePubDate)
&& ruleCategories == source.ruleCategories && equal(ruleCategories, source.ruleCategories)
&& ruleDescription == source.ruleDescription && equal(ruleDescription, source.ruleDescription)
&& ruleLink == source.ruleLink && equal(ruleLink, source.ruleLink)
&& ruleContent == source.ruleContent && equal(ruleContent, source.ruleContent)
&& enableJs == source.enableJs && enableJs == source.enableJs
&& loadWithBaseUrl == source.loadWithBaseUrl && 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.EditEntity
import io.legado.app.data.entities.rule.* import io.legado.app.data.entities.rule.*
import io.legado.app.lib.dialogs.alert 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.lib.theme.ATH
import io.legado.app.ui.book.source.debug.BookSourceDebugActivity import io.legado.app.ui.book.source.debug.BookSourceDebugActivity
import io.legado.app.ui.widget.KeyboardToolPop import io.legado.app.ui.widget.KeyboardToolPop
@ -114,16 +112,13 @@ class BookSourceEditActivity :
override fun finish() { override fun finish() {
val source = getSource() val source = getSource()
if (!source.equal(viewModel.bookSource)) { if (!source.equal(viewModel.bookSource ?: BookSource())) {
alert(R.string.exit_no_save) { alert(R.string.exit) {
yesButton { messageResource = R.string.exit_no_save
if (checkSource(source)) { positiveButton(R.string.yes)
viewModel.save(source) { negativeButton(R.string.no) {
super.finish() super.finish()
} }
}
}
noButton { }
}.show().applyTint() }.show().applyTint()
} else { } else {
super.finish() 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.EditEntity
import io.legado.app.data.entities.RssSource import io.legado.app.data.entities.RssSource
import io.legado.app.lib.dialogs.alert 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.lib.theme.ATH
import io.legado.app.ui.rss.source.debug.RssSourceDebugActivity import io.legado.app.ui.rss.source.debug.RssSourceDebugActivity
import io.legado.app.ui.widget.KeyboardToolPop import io.legado.app.ui.widget.KeyboardToolPop
@ -56,16 +54,13 @@ class RssSourceEditActivity :
override fun finish() { override fun finish() {
val source = getRssSource() val source = getRssSource()
if (!source.equal(viewModel.rssSource)) { if (!source.equal(viewModel.rssSource ?: RssSource())) {
alert(R.string.exit_no_save) { alert(R.string.exit) {
yesButton { messageResource = R.string.exit_no_save
if (checkSource(source)) { positiveButton(R.string.yes)
viewModel.save(source) { negativeButton(R.string.no) {
super.finish() super.finish()
} }
}
}
noButton { }
}.show().applyTint() }.show().applyTint()
} else { } else {
super.finish() super.finish()

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

Loading…
Cancel
Save