|
|
@ -20,6 +20,7 @@ import io.legado.app.utils.longToastOnUi |
|
|
|
import io.legado.app.utils.visible |
|
|
|
import io.legado.app.utils.visible |
|
|
|
import kotlinx.coroutines.CoroutineScope |
|
|
|
import kotlinx.coroutines.CoroutineScope |
|
|
|
import kotlinx.coroutines.Dispatchers.Main |
|
|
|
import kotlinx.coroutines.Dispatchers.Main |
|
|
|
|
|
|
|
import kotlinx.coroutines.async |
|
|
|
import kotlinx.coroutines.ensureActive |
|
|
|
import kotlinx.coroutines.ensureActive |
|
|
|
import kotlinx.coroutines.withContext |
|
|
|
import kotlinx.coroutines.withContext |
|
|
|
import java.util.concurrent.ConcurrentHashMap |
|
|
|
import java.util.concurrent.ConcurrentHashMap |
|
|
@ -79,30 +80,34 @@ class ChapterListAdapter(context: Context, val callback: Callback) : |
|
|
|
val replaceRules = replaceRules |
|
|
|
val replaceRules = replaceRules |
|
|
|
val useReplace = useReplace |
|
|
|
val useReplace = useReplace |
|
|
|
val items = getItems() |
|
|
|
val items = getItems() |
|
|
|
for (i in startIndex until items.size) { |
|
|
|
async { |
|
|
|
val item = items[i] |
|
|
|
for (i in startIndex until items.size) { |
|
|
|
if (displayTitleMap[item.title] == null) { |
|
|
|
val item = items[i] |
|
|
|
ensureActive() |
|
|
|
if (displayTitleMap[item.title] == null) { |
|
|
|
val displayTitle = item.getDisplayTitle(replaceRules, useReplace) |
|
|
|
ensureActive() |
|
|
|
ensureActive() |
|
|
|
val displayTitle = item.getDisplayTitle(replaceRules, useReplace) |
|
|
|
displayTitleMap[item.title] = displayTitle |
|
|
|
ensureActive() |
|
|
|
withContext(Main) { |
|
|
|
displayTitleMap[item.title] = displayTitle |
|
|
|
notifyItemChanged(i, true) |
|
|
|
withContext(Main) { |
|
|
|
|
|
|
|
notifyItemChanged(i, true) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}.start() |
|
|
|
for (i in 0 until startIndex) { |
|
|
|
async { |
|
|
|
val item = items[i] |
|
|
|
for (i in startIndex downTo 0) { |
|
|
|
if (displayTitleMap[item.title] == null) { |
|
|
|
val item = items[i] |
|
|
|
ensureActive() |
|
|
|
if (displayTitleMap[item.title] == null) { |
|
|
|
val displayTitle = item.getDisplayTitle(replaceRules, useReplace) |
|
|
|
ensureActive() |
|
|
|
ensureActive() |
|
|
|
val displayTitle = item.getDisplayTitle(replaceRules, useReplace) |
|
|
|
displayTitleMap[item.title] = displayTitle |
|
|
|
ensureActive() |
|
|
|
withContext(Main) { |
|
|
|
displayTitleMap[item.title] = displayTitle |
|
|
|
notifyItemChanged(i, true) |
|
|
|
withContext(Main) { |
|
|
|
|
|
|
|
notifyItemChanged(i, true) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}.start() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|