mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-27 23:40:33 +05:30
Merge pull request #1548 from Bnyro/master
replies performance improvements
This commit is contained in:
commit
5c2013ae56
@ -22,6 +22,7 @@ import com.github.libretube.util.NavigationHelper
|
|||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
class CommentsAdapter(
|
class CommentsAdapter(
|
||||||
private val videoId: String,
|
private val videoId: String,
|
||||||
@ -126,7 +127,7 @@ class CommentsAdapter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun fetchReplies(nextPage: String, onFinished: (CommentsPage) -> Unit) {
|
private fun fetchReplies(nextPage: String, onFinished: (CommentsPage) -> Unit) {
|
||||||
CoroutineScope(Dispatchers.Main).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
if (isLoading) return@launch
|
if (isLoading) return@launch
|
||||||
isLoading = true
|
isLoading = true
|
||||||
repliesPage = try {
|
repliesPage = try {
|
||||||
@ -135,7 +136,9 @@ class CommentsAdapter(
|
|||||||
Log.e(TAG(), "IOException, you might not have internet connection")
|
Log.e(TAG(), "IOException, you might not have internet connection")
|
||||||
return@launch
|
return@launch
|
||||||
}
|
}
|
||||||
|
withContext(Dispatchers.Main) {
|
||||||
onFinished.invoke(repliesPage)
|
onFinished.invoke(repliesPage)
|
||||||
|
}
|
||||||
isLoading = false
|
isLoading = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user