CheckSource.kt不使用init

pull/1581/head
Xwite 3 years ago
parent 42d0495072
commit a43ca6c521
  1. 23
      app/src/main/java/io/legado/app/model/CheckSource.kt

@ -18,11 +18,7 @@ object CheckSource {
var checkInfo = CacheManager.get("checkInfo")?.toBoolean() ?: true var checkInfo = CacheManager.get("checkInfo")?.toBoolean() ?: true
var checkCategory = CacheManager.get("checkCategory")?.toBoolean() ?: true var checkCategory = CacheManager.get("checkCategory")?.toBoolean() ?: true
var checkContent = CacheManager.get("checkContent")?.toBoolean() ?: true var checkContent = CacheManager.get("checkContent")?.toBoolean() ?: true
var summary = "" val summary get() = upSummary()
init {
upSummary()
}
fun start(context: Context, sources: List<BookSource>) { fun start(context: Context, sources: List<BookSource>) {
val selectedIds: ArrayList<String> = arrayListOf() val selectedIds: ArrayList<String> = arrayListOf()
@ -48,16 +44,15 @@ object CheckSource {
CacheManager.put("checkInfo", checkInfo) CacheManager.put("checkInfo", checkInfo)
CacheManager.put("checkCategory", checkCategory) CacheManager.put("checkCategory", checkCategory)
CacheManager.put("checkContent", checkContent) CacheManager.put("checkContent", checkContent)
upSummary()
} }
fun upSummary() { fun upSummary(): String {
summary = "" var checkItem = ""
if (checkSearch) summary = "${summary} ${appCtx.getString(R.string.search)}" if (checkSearch) checkItem = "${checkItem} ${appCtx.getString(R.string.search)}"
if (checkDiscovery) summary = "${summary} ${appCtx.getString(R.string.discovery)}" if (checkDiscovery) checkItem = "${checkItem} ${appCtx.getString(R.string.discovery)}"
if (checkInfo) summary = "${summary} ${appCtx.getString(R.string.source_tab_info)}" if (checkInfo) checkItem = "${checkItem} ${appCtx.getString(R.string.source_tab_info)}"
if (checkCategory) summary = "${summary} ${appCtx.getString(R.string.chapter_list)}" if (checkCategory) checkItem = "${checkItem} ${appCtx.getString(R.string.chapter_list)}"
if (checkContent) summary = "${summary} ${appCtx.getString(R.string.main_body)}" if (checkContent) checkItem = "${checkItem} ${appCtx.getString(R.string.main_body)}"
summary = appCtx.getString(R.string.check_source_config_summary, (timeout / 1000).toString(), summary) return appCtx.getString(R.string.check_source_config_summary, (timeout / 1000).toString(), checkItem)
} }
} }
Loading…
Cancel
Save