pull/35/head
kunfei 5 years ago
parent 3efd936357
commit d8e33b1d9c
  1. 4
      app/src/main/java/io/legado/app/data/entities/BookSource.kt
  2. 2
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
  3. 2
      app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt
  4. 8
      app/src/main/java/io/legado/app/utils/ACache.kt

@ -126,7 +126,7 @@ data class BookSource(
try {
if (it.startsWith("<js>", false)) {
val aCache = ACache.get(App.INSTANCE, "explore")
a = aCache?.getAsString(bookSourceUrl) ?: ""
a = aCache.getAsString(bookSourceUrl) ?: ""
if (a.isBlank()) {
val bindings = SimpleBindings()
bindings["baseUrl"] = bookSourceUrl
@ -135,7 +135,7 @@ data class BookSource(
it.substring(4, it.lastIndexOf("<")),
bindings
).toString()
aCache?.put(bookSourceUrl, a)
aCache.put(bookSourceUrl, a)
}
}
val b = a.split("(&&|\n)+".toRegex())

@ -167,7 +167,7 @@ class BookSourceActivity : VMBaseActivity<BookSourceViewModel>(R.layout.activity
private fun showImportDialog() {
val cacheUrls: List<String>? = ACache
.get(this, "cacheUrls", cacheDir = false)
?.getAsString("sourceUrl")
.getAsString("sourceUrl")
?.splitNotBlank(";")
?.toMutableList()
alert(titleResource = R.string.import_book_source_on_line) {

@ -48,7 +48,7 @@ class ExploreAdapter(context: Context, private val scope: CoroutineScope, val ca
R.id.menu_edit -> callBack.editSource(item.bookSourceUrl)
R.id.menu_top -> callBack.toTop(item)
R.id.menu_refresh -> {
ACache.get(context, "explore")?.remove(item.bookSourceUrl)
ACache.get(context, "explore").remove(item.bookSourceUrl)
notifyItemChanged(holder.layoutPosition)
}
}

@ -776,7 +776,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
maxSize: Long = MAX_SIZE.toLong(),
maxCount: Int = MAX_COUNT,
cacheDir: Boolean = true
): ACache? {
): ACache {
val f = if (cacheDir) File(ctx.cacheDir, cacheName) else File(ctx.filesDir, cacheName)
return get(f, maxSize, maxCount)
}
@ -786,17 +786,15 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
cacheDir: File,
maxSize: Long = MAX_SIZE.toLong(),
maxCount: Int = MAX_COUNT
): ACache? {
try {
): ACache {
synchronized(this) {
var manager = mInstanceMap[cacheDir.absoluteFile.toString() + myPid()]
if (manager == null) {
manager = ACache(cacheDir, maxSize, maxCount)
mInstanceMap[cacheDir.absolutePath + myPid()] = manager
}
return manager
} catch (ignored: Exception) {
}
return null
}
private fun myPid(): String {

Loading…
Cancel
Save