Merge pull request #3475 from Isira-Seneviratne/Use_nullable_binding

Reuse existing nullable binding variables.
This commit is contained in:
Isira Seneviratne 2023-04-02 17:03:54 +05:30 committed by GitHub
commit f1b924e69e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 7 deletions

View File

@ -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)

View File

@ -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
}
}