mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 06:10:31 +05:30
Merge pull request #4859 from Bnyro/master
fix: crash when navigating too fast in replies
This commit is contained in:
commit
16c6c69bc8
@ -31,7 +31,6 @@ import kotlinx.coroutines.withContext
|
||||
|
||||
class CommentsRepliesFragment : Fragment() {
|
||||
private var _binding: FragmentCommentsBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
private lateinit var repliesPage: CommentsPage
|
||||
private lateinit var repliesAdapter: CommentsAdapter
|
||||
@ -45,7 +44,7 @@ class CommentsRepliesFragment : Fragment() {
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
_binding = FragmentCommentsBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
return _binding!!.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
@ -54,6 +53,8 @@ class CommentsRepliesFragment : Fragment() {
|
||||
val videoId = arguments.getString(IntentData.videoId, "")
|
||||
val comment = arguments.parcelable<Comment>(IntentData.comment)!!
|
||||
|
||||
val binding = _binding ?: return
|
||||
|
||||
repliesAdapter = CommentsAdapter(
|
||||
null,
|
||||
videoId,
|
||||
@ -96,10 +97,10 @@ class CommentsRepliesFragment : Fragment() {
|
||||
nextPage: String,
|
||||
repliesAdapter: CommentsAdapter
|
||||
) {
|
||||
binding.progress.isVisible = true
|
||||
_binding?.progress?.isVisible = true
|
||||
fetchReplies(videoId, nextPage) {
|
||||
repliesAdapter.updateItems(it.comments)
|
||||
binding.progress.isGone = true
|
||||
_binding?.progress?.isGone = true
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,6 +112,7 @@ class CommentsRepliesFragment : Fragment() {
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
if (isLoading) return@launch
|
||||
isLoading = true
|
||||
|
||||
repliesPage = try {
|
||||
RetrofitInstance.api.getCommentsNextPage(videoId, nextPage)
|
||||
} catch (e: Exception) {
|
||||
|
Loading…
Reference in New Issue
Block a user