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. 40
      app/src/main/java/io/legado/app/data/entities/RssSource.kt
  3. 17
      app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt
  4. 17
      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 { && enabled == source.enabled
return sourceUrl == source.sourceUrl && equal(sourceGroup, source.sourceGroup)
&& sourceName == source.sourceName && equal(ruleArticles, source.ruleArticles)
&& sourceIcon == source.sourceIcon && equal(ruleNextPage, source.ruleNextPage)
&& enabled == source.enabled && equal(ruleTitle, source.ruleTitle)
&& sourceGroup == source.sourceGroup && equal(rulePubDate, source.rulePubDate)
&& ruleArticles == source.ruleArticles && equal(ruleCategories, source.ruleCategories)
&& ruleNextPage == source.ruleNextPage && equal(ruleDescription, source.ruleDescription)
&& ruleTitle == source.ruleTitle && equal(ruleLink, source.ruleLink)
&& rulePubDate == source.rulePubDate && equal(ruleContent, source.ruleContent)
&& ruleCategories == source.ruleCategories && enableJs == source.enableJs
&& ruleDescription == source.ruleDescription && loadWithBaseUrl == source.loadWithBaseUrl
&& ruleLink == source.ruleLink }
&& ruleContent == source.ruleContent
&& enableJs == source.enableJs private fun equal(a: String?, b: String?): Boolean {
&& loadWithBaseUrl == source.loadWithBaseUrl return a == b || (a.isNullOrEmpty() && b.isNullOrEmpty())
&& customOrder == source.customOrder
}
} }
} }

@ -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