mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
Merge pull request #3517 from Bnyro/master
Fix crashes caused by view bindings
This commit is contained in:
commit
f24ef883c3
@ -132,6 +132,7 @@ class HomeFragment : Fragment() {
|
||||
val bookmarkedPlaylists = withContext(Dispatchers.IO) {
|
||||
DatabaseHolder.Database.playlistBookmarkDao().getAll()
|
||||
}.takeIf { it.isNotEmpty() } ?: return
|
||||
val binding = _binding ?: return
|
||||
|
||||
makeVisible(binding.bookmarksTV, binding.bookmarksRV)
|
||||
binding.bookmarksRV.layoutManager = LinearLayoutManager(
|
||||
@ -151,6 +152,7 @@ class HomeFragment : Fragment() {
|
||||
PlaylistsHelper.getPlaylists().take(20)
|
||||
}
|
||||
}.getOrNull()?.takeIf { it.isNotEmpty() } ?: return
|
||||
val binding = _binding ?: return
|
||||
|
||||
makeVisible(binding.playlistsRV, binding.playlistsTV)
|
||||
binding.playlistsRV.layoutManager = LinearLayoutManager(context)
|
||||
|
@ -33,6 +33,7 @@ class WatchHistoryFragment : Fragment() {
|
||||
private var _binding: FragmentWatchHistoryBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
private val playerViewModel: PlayerViewModel by activityViewModels()
|
||||
private var isLoading = false
|
||||
|
||||
@ -49,7 +50,7 @@ class WatchHistoryFragment : Fragment() {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
playerViewModel.isMiniPlayerVisible.observe(viewLifecycleOwner) {
|
||||
binding.watchHistoryRecView.updatePadding(
|
||||
_binding?.watchHistoryRecView?.updatePadding(
|
||||
bottom = if (it) (64).dpToPx().toInt() else 0
|
||||
)
|
||||
}
|
||||
@ -148,7 +149,8 @@ class WatchHistoryFragment : Fragment() {
|
||||
})
|
||||
|
||||
// add a listener for scroll end, delay needed to prevent loading new ones the first time
|
||||
Handler(Looper.getMainLooper()).postDelayed(200) {
|
||||
handler.postDelayed(200) {
|
||||
if (_binding == null) return@postDelayed
|
||||
binding.historyScrollView.viewTreeObserver.addOnScrollChangedListener {
|
||||
if (_binding?.historyScrollView?.canScrollVertically(1) == false &&
|
||||
!isLoading
|
||||
|
Loading…
Reference in New Issue
Block a user