mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2024-11-24 19:04:38 -06:00
[UI] Fix disabling pull to refresh when changing page using tab layout.
This commit is contained in:
parent
0db6393bb0
commit
b794b30346
@ -13,10 +13,12 @@ class LazyViewPager @JvmOverloads constructor(
|
||||
) : ViewPager(context, attrs) {
|
||||
|
||||
private var pageSelection = -1
|
||||
private var scrollState = 0
|
||||
|
||||
init {
|
||||
addOnPageChangeListener(object : OnPageChangeListener {
|
||||
override fun onPageScrollStateChanged(state: Int) {
|
||||
scrollState = state
|
||||
(adapter as? LazyPagerAdapter)?.let {
|
||||
it.swipeRefreshLayout?.isEnabled = state == SCROLL_STATE_IDLE && it.enabledList[pageSelection, true]
|
||||
}
|
||||
@ -28,7 +30,8 @@ class LazyViewPager @JvmOverloads constructor(
|
||||
|
||||
override fun onPageSelected(position: Int) {
|
||||
pageSelection = position
|
||||
if (adapter is LazyPagerAdapter) {
|
||||
(adapter as? LazyPagerAdapter)?.let {
|
||||
it.swipeRefreshLayout?.isEnabled = scrollState == SCROLL_STATE_IDLE && it.enabledList[pageSelection, true]
|
||||
val fragment = adapter?.instantiateItem(this@LazyViewPager, position)
|
||||
val lazyFragment = fragment as? LazyFragment
|
||||
lazyFragment?.createPage()
|
||||
|
@ -93,6 +93,7 @@ class HomeworkListFragment : LazyFragment(), CoroutineScope {
|
||||
}
|
||||
}
|
||||
adapter.notifyDataSetChanged()
|
||||
setSwipeToRefresh(false) // TODO
|
||||
|
||||
// show/hide relevant views
|
||||
b.progressBar.isVisible = false
|
||||
|
@ -64,6 +64,7 @@ class TemplateListFragment : Fragment(), CoroutineScope {
|
||||
}
|
||||
}
|
||||
adapter.notifyDataSetChanged()
|
||||
b.refreshLayout.isEnabled = false // TODO
|
||||
|
||||
// show/hide relevant views
|
||||
b.progressBar.isVisible = false
|
||||
|
@ -64,6 +64,7 @@ class TemplateListPageFragment : LazyFragment(), CoroutineScope {
|
||||
}
|
||||
}
|
||||
adapter.notifyDataSetChanged()
|
||||
setSwipeToRefresh(false) // TODO
|
||||
|
||||
// show/hide relevant views
|
||||
b.progressBar.isVisible = false
|
||||
|
Loading…
Reference in New Issue
Block a user