diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index faaf89f1b..6219c22bf 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -243,7 +243,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions { container: ViewGroup?, savedInstanceState: Bundle? ): View { - _binding = FragmentPlayerBinding.inflate(layoutInflater) + _binding = FragmentPlayerBinding.inflate(inflater) return binding.root } @@ -271,7 +271,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions { * somehow the bottom bar is invisible on low screen resolutions, this fixes it */ private fun showBottomBar() { - if (isAdded && !binding.player.isPlayerLocked) { + if (_binding?.player?.isPlayerLocked == false) { playerBinding.bottomBar.isVisible = true } handler.postDelayed(this::showBottomBar, 100) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/SearchResultFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/SearchResultFragment.kt index 52860e169..511ce6dbd 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/SearchResultFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/SearchResultFragment.kt @@ -45,7 +45,7 @@ class SearchResultFragment : Fragment() { container: ViewGroup?, savedInstanceState: Bundle? ): View { - _binding = FragmentSearchResultBinding.inflate(layoutInflater) + _binding = FragmentSearchResultBinding.inflate(inflater) return binding.root } @@ -78,7 +78,7 @@ class SearchResultFragment : Fragment() { fetchSearch() binding.searchRecycler.viewTreeObserver.addOnScrollChangedListener { - if (isAdded && !binding.searchRecycler.canScrollVertically(1) && + if (_binding?.searchRecycler?.canScrollVertically(1) == false && nextPage != null ) { fetchNextSearchItems() @@ -144,9 +144,8 @@ class SearchResultFragment : Fragment() { } } - override fun onDestroy() { - super.onDestroy() - + override fun onDestroyView() { + super.onDestroyView() _binding = null } }