fix: source record

source record
pull/95/head
kunfei 5 years ago
parent dbb7a62452
commit d1a4c9daef
  1. 8
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
  2. 7
      app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt
  3. 8
      app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt

@ -50,7 +50,7 @@ class BookSourceActivity : VMBaseActivity<BookSourceViewModel>(R.layout.activity
SearchView.OnQueryTextListener { SearchView.OnQueryTextListener {
override val viewModel: BookSourceViewModel override val viewModel: BookSourceViewModel
get() = getViewModel(BookSourceViewModel::class.java) get() = getViewModel(BookSourceViewModel::class.java)
private val importRecordKey = "bookSourceRecordKey"
private val qrRequestCode = 101 private val qrRequestCode = 101
private val importSource = 132 private val importSource = 132
private lateinit var adapter: BookSourceAdapter private lateinit var adapter: BookSourceAdapter
@ -199,7 +199,7 @@ class BookSourceActivity : VMBaseActivity<BookSourceViewModel>(R.layout.activity
private fun showImportDialog() { private fun showImportDialog() {
val aCache = ACache.get(this, cacheDir = false) val aCache = ACache.get(this, cacheDir = false)
val cacheUrls: MutableList<String> = aCache val cacheUrls: MutableList<String> = aCache
.getAsString("sourceUrl") .getAsString(importRecordKey)
?.splitNotBlank(",") ?.splitNotBlank(",")
?.toMutableList() ?: mutableListOf() ?.toMutableList() ?: mutableListOf()
alert(titleResource = R.string.import_book_source_on_line) { alert(titleResource = R.string.import_book_source_on_line) {
@ -209,7 +209,7 @@ class BookSourceActivity : VMBaseActivity<BookSourceViewModel>(R.layout.activity
editText = edit_view editText = edit_view
edit_view.setFilterValues(cacheUrls) { edit_view.setFilterValues(cacheUrls) {
cacheUrls.remove(it) cacheUrls.remove(it)
aCache.put("sourceUrl", cacheUrls.joinToString(",")) aCache.put(importRecordKey, cacheUrls.joinToString(","))
} }
} }
} }
@ -218,7 +218,7 @@ class BookSourceActivity : VMBaseActivity<BookSourceViewModel>(R.layout.activity
text?.let { text?.let {
if (!cacheUrls.contains(it)) { if (!cacheUrls.contains(it)) {
cacheUrls.add(0, it) cacheUrls.add(0, it)
aCache.put("sourceUrl", cacheUrls.joinToString(",")) aCache.put(importRecordKey, cacheUrls.joinToString(","))
} }
Snackbar.make(title_bar, R.string.importing, Snackbar.LENGTH_INDEFINITE).show() Snackbar.make(title_bar, R.string.importing, Snackbar.LENGTH_INDEFINITE).show()
viewModel.importSource(it) { msg -> viewModel.importSource(it) { msg ->

@ -45,6 +45,7 @@ class ReplaceRuleActivity : VMBaseActivity<ReplaceRuleViewModel>(R.layout.activi
ReplaceRuleAdapter.CallBack { ReplaceRuleAdapter.CallBack {
override val viewModel: ReplaceRuleViewModel override val viewModel: ReplaceRuleViewModel
get() = getViewModel(ReplaceRuleViewModel::class.java) get() = getViewModel(ReplaceRuleViewModel::class.java)
private val importRecordKey = "replaceRuleRecordKey"
private val importSource = 132 private val importSource = 132
private lateinit var adapter: ReplaceRuleAdapter private lateinit var adapter: ReplaceRuleAdapter
private var groups = hashSetOf<String>() private var groups = hashSetOf<String>()
@ -149,7 +150,7 @@ class ReplaceRuleActivity : VMBaseActivity<ReplaceRuleViewModel>(R.layout.activi
private fun showImportDialog() { private fun showImportDialog() {
val aCache = ACache.get(this, cacheDir = false) val aCache = ACache.get(this, cacheDir = false)
val cacheUrls: MutableList<String> = aCache val cacheUrls: MutableList<String> = aCache
.getAsString("replaceRuleUrl") .getAsString(importRecordKey)
?.splitNotBlank(",") ?.splitNotBlank(",")
?.toMutableList() ?: mutableListOf() ?.toMutableList() ?: mutableListOf()
alert(titleResource = R.string.import_replace_rule_on_line) { alert(titleResource = R.string.import_replace_rule_on_line) {
@ -159,7 +160,7 @@ class ReplaceRuleActivity : VMBaseActivity<ReplaceRuleViewModel>(R.layout.activi
editText = edit_view editText = edit_view
edit_view.setFilterValues(cacheUrls) { edit_view.setFilterValues(cacheUrls) {
cacheUrls.remove(it) cacheUrls.remove(it)
aCache.put("replaceRuleUrl", cacheUrls.joinToString(",")) aCache.put(importRecordKey, cacheUrls.joinToString(","))
} }
} }
} }
@ -168,7 +169,7 @@ class ReplaceRuleActivity : VMBaseActivity<ReplaceRuleViewModel>(R.layout.activi
text?.let { text?.let {
if (!cacheUrls.contains(it)) { if (!cacheUrls.contains(it)) {
cacheUrls.add(0, it) cacheUrls.add(0, it)
aCache.put("replaceRuleUrl", cacheUrls.joinToString(",")) aCache.put(importRecordKey, cacheUrls.joinToString(","))
} }
Snackbar.make(title_bar, R.string.importing, Snackbar.LENGTH_INDEFINITE).show() Snackbar.make(title_bar, R.string.importing, Snackbar.LENGTH_INDEFINITE).show()
viewModel.importSource(it) { msg -> viewModel.importSource(it) { msg ->

@ -50,7 +50,7 @@ class RssSourceActivity : VMBaseActivity<RssSourceViewModel>(R.layout.activity_r
override val viewModel: RssSourceViewModel override val viewModel: RssSourceViewModel
get() = getViewModel(RssSourceViewModel::class.java) get() = getViewModel(RssSourceViewModel::class.java)
private val importRecordKey = "rssSourceRecordKey"
private val qrRequestCode = 101 private val qrRequestCode = 101
private val importSource = 13141 private val importSource = 13141
private lateinit var adapter: RssSourceAdapter private lateinit var adapter: RssSourceAdapter
@ -227,7 +227,7 @@ class RssSourceActivity : VMBaseActivity<RssSourceViewModel>(R.layout.activity_r
private fun showImportDialog() { private fun showImportDialog() {
val aCache = ACache.get(this, cacheDir = false) val aCache = ACache.get(this, cacheDir = false)
val cacheUrls: MutableList<String> = aCache val cacheUrls: MutableList<String> = aCache
.getAsString("sourceUrl") .getAsString(importRecordKey)
?.splitNotBlank(",") ?.splitNotBlank(",")
?.toMutableList() ?: mutableListOf() ?.toMutableList() ?: mutableListOf()
alert(titleResource = R.string.import_book_source_on_line) { alert(titleResource = R.string.import_book_source_on_line) {
@ -237,7 +237,7 @@ class RssSourceActivity : VMBaseActivity<RssSourceViewModel>(R.layout.activity_r
editText = edit_view editText = edit_view
edit_view.setFilterValues(cacheUrls) { edit_view.setFilterValues(cacheUrls) {
cacheUrls.remove(it) cacheUrls.remove(it)
aCache.put("sourceUrl", cacheUrls.joinToString(",")) aCache.put(importRecordKey, cacheUrls.joinToString(","))
} }
} }
} }
@ -246,7 +246,7 @@ class RssSourceActivity : VMBaseActivity<RssSourceViewModel>(R.layout.activity_r
text?.let { text?.let {
if (!cacheUrls.contains(it)) { if (!cacheUrls.contains(it)) {
cacheUrls.add(0, it) cacheUrls.add(0, it)
aCache.put("sourceUrl", cacheUrls.joinToString(",")) aCache.put(importRecordKey, cacheUrls.joinToString(","))
} }
Snackbar.make(title_bar, R.string.importing, Snackbar.LENGTH_INDEFINITE).show() Snackbar.make(title_bar, R.string.importing, Snackbar.LENGTH_INDEFINITE).show()
viewModel.importSource(it) { msg -> viewModel.importSource(it) { msg ->

Loading…
Cancel
Save