mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 07:50:31 +05:30
Merge pull request #3031 from Isira-Seneviratne/Search_view_binding
Release view bindings in search fragments.
This commit is contained in:
commit
3663583ff9
@ -20,7 +20,9 @@ import com.github.libretube.ui.base.BaseFragment
|
|||||||
import com.github.libretube.ui.models.SearchViewModel
|
import com.github.libretube.ui.models.SearchViewModel
|
||||||
|
|
||||||
class SearchFragment : BaseFragment() {
|
class SearchFragment : BaseFragment() {
|
||||||
private lateinit var binding: FragmentSearchBinding
|
private var _binding: FragmentSearchBinding? = null
|
||||||
|
private val binding get() = _binding!!
|
||||||
|
|
||||||
private val viewModel: SearchViewModel by activityViewModels()
|
private val viewModel: SearchViewModel by activityViewModels()
|
||||||
|
|
||||||
private var query: String? = null
|
private var query: String? = null
|
||||||
@ -35,7 +37,7 @@ class SearchFragment : BaseFragment() {
|
|||||||
container: ViewGroup?,
|
container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View {
|
): View {
|
||||||
binding = FragmentSearchBinding.inflate(layoutInflater, container, false)
|
_binding = FragmentSearchBinding.inflate(layoutInflater, container, false)
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,8 @@ import kotlinx.coroutines.withContext
|
|||||||
import retrofit2.HttpException
|
import retrofit2.HttpException
|
||||||
|
|
||||||
class SearchResultFragment : BaseFragment() {
|
class SearchResultFragment : BaseFragment() {
|
||||||
private lateinit var binding: FragmentSearchResultBinding
|
private var _binding: FragmentSearchResultBinding? = null
|
||||||
|
private val binding get() = _binding!!
|
||||||
|
|
||||||
private var nextPage: String? = null
|
private var nextPage: String? = null
|
||||||
private var query: String = ""
|
private var query: String = ""
|
||||||
@ -43,7 +44,7 @@ class SearchResultFragment : BaseFragment() {
|
|||||||
container: ViewGroup?,
|
container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View {
|
): View {
|
||||||
binding = FragmentSearchResultBinding.inflate(layoutInflater, container, false)
|
_binding = FragmentSearchResultBinding.inflate(layoutInflater, container, false)
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,12 +76,18 @@ class SearchResultFragment : BaseFragment() {
|
|||||||
|
|
||||||
fetchSearch()
|
fetchSearch()
|
||||||
|
|
||||||
binding.searchRecycler.viewTreeObserver
|
binding.searchRecycler.viewTreeObserver.addOnScrollChangedListener {
|
||||||
.addOnScrollChangedListener {
|
if (_binding?.searchRecycler?.canScrollVertically(1) == false &&
|
||||||
if (!binding.searchRecycler.canScrollVertically(1)) {
|
nextPage != null
|
||||||
if (nextPage != null) fetchNextSearchItems()
|
) {
|
||||||
}
|
fetchNextSearchItems()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroyView() {
|
||||||
|
super.onDestroyView()
|
||||||
|
_binding = null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun fetchSearch() {
|
private fun fetchSearch() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user