mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
fix visibility
This commit is contained in:
parent
f98ce0558d
commit
6d51c59b18
2 changed files with 34 additions and 23 deletions
|
@ -385,7 +385,6 @@ class LibraryFragment : Fragment() {
|
|||
val pages = resource.value
|
||||
val showNotice = pages.all { it.items.isEmpty() }
|
||||
|
||||
|
||||
binding?.apply {
|
||||
emptyListTextview.isVisible = showNotice
|
||||
if (showNotice) {
|
||||
|
@ -408,7 +407,10 @@ class LibraryFragment : Fragment() {
|
|||
0,
|
||||
viewpager.adapter?.itemCount ?: 0
|
||||
)
|
||||
binding?.viewpager?.setCurrentItem(libraryViewModel.currentPage, false)
|
||||
|
||||
libraryViewModel.currentPage.value?.let { page ->
|
||||
binding?.viewpager?.setCurrentItem(page, false)
|
||||
}
|
||||
|
||||
// Only stop loading after 300ms to hide the fade effect the viewpager produces when updating
|
||||
// Without this there would be a flashing effect:
|
||||
|
@ -449,27 +451,26 @@ class LibraryFragment : Fragment() {
|
|||
tab.view.nextFocusDownId = R.id.search_result_root
|
||||
|
||||
tab.view.setOnClickListener {
|
||||
libraryViewModel.currentPage = position // updating selected library tab position
|
||||
|
||||
val currentItem =
|
||||
binding?.viewpager?.currentItem ?: return@setOnClickListener
|
||||
val distance = abs(position - currentItem)
|
||||
hideViewpager(distance)
|
||||
}
|
||||
//Expand the appBar on tab focus
|
||||
tab.view.setOnFocusChangeListener { view, b ->
|
||||
tab.view.setOnFocusChangeListener { _, _ ->
|
||||
binding?.searchBar?.setExpanded(true)
|
||||
}
|
||||
}.attach()
|
||||
|
||||
binding?.libraryTabLayout?.addOnTabSelectedListener(object: TabLayout.OnTabSelectedListener {
|
||||
override fun onTabSelected(tab: TabLayout.Tab?) {
|
||||
libraryViewModel.currentPage = binding?.libraryTabLayout?.selectedTabPosition ?:0
|
||||
binding?.libraryTabLayout?.selectedTabPosition?.let { page ->
|
||||
libraryViewModel.switchPage(page)
|
||||
}
|
||||
override fun onTabUnselected(tab: TabLayout.Tab?) {}
|
||||
override fun onTabReselected(tab: TabLayout.Tab?) {}
|
||||
}
|
||||
override fun onTabUnselected(tab: TabLayout.Tab?) = Unit
|
||||
override fun onTabReselected(tab: TabLayout.Tab?) = Unit
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -485,9 +486,8 @@ class LibraryFragment : Fragment() {
|
|||
}
|
||||
}
|
||||
}
|
||||
binding?.viewpager?.registerOnPageChangeCallback(object :
|
||||
ViewPager2.OnPageChangeCallback() {
|
||||
override fun onPageSelected(position: Int) {
|
||||
|
||||
observe(libraryViewModel.currentPage) { position ->
|
||||
val all = binding?.viewpager?.allViews?.toList()
|
||||
?.filterIsInstance<AutofitRecyclerView>()
|
||||
|
||||
|
@ -500,9 +500,15 @@ class LibraryFragment : Fragment() {
|
|||
else
|
||||
view.descendantFocusability = FOCUS_BLOCK_DESCENDANTS
|
||||
}
|
||||
}
|
||||
|
||||
/*binding?.viewpager?.registerOnPageChangeCallback(object :
|
||||
ViewPager2.OnPageChangeCallback() {
|
||||
override fun onPageSelected(position: Int) {
|
||||
|
||||
super.onPageSelected(position)
|
||||
}
|
||||
})
|
||||
})*/
|
||||
}
|
||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||
(binding?.viewpager?.adapter as? ViewpagerAdapter)?.rebind()
|
||||
|
|
|
@ -28,7 +28,12 @@ enum class ListSorting(@StringRes val stringRes: Int) {
|
|||
const val LAST_SYNC_API_KEY = "last_sync_api"
|
||||
|
||||
class LibraryViewModel : ViewModel() {
|
||||
var currentPage: Int = 0
|
||||
fun switchPage(page : Int) {
|
||||
_currentPage.postValue(page)
|
||||
}
|
||||
|
||||
private val _currentPage: MutableLiveData<Int> = MutableLiveData(0)
|
||||
val currentPage: LiveData<Int> = _currentPage
|
||||
|
||||
private val _pages: MutableLiveData<Resource<List<SyncAPI.Page>>> = MutableLiveData(null)
|
||||
val pages: LiveData<Resource<List<SyncAPI.Page>>> = _pages
|
||||
|
|
Loading…
Reference in a new issue