diff --git a/app/src/main/java/com/github/libretube/ui/fragments/CommentsRepliesFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/CommentsRepliesFragment.kt index a79afd55e..295b3ef85 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/CommentsRepliesFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/CommentsRepliesFragment.kt @@ -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(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) {