[Agenda] Update scroll listeners code.

This commit is contained in:
Kuba Szczodrzyński 2021-04-12 11:50:54 +02:00
parent f5ceaa9afe
commit 12619f6bde
No known key found for this signature in database
GPG Key ID: 70CB8A85BA1633CB
2 changed files with 17 additions and 12 deletions

View File

@ -152,7 +152,7 @@ dependencies {
implementation "pl.droidsonroids.retrofit2:converter-jspoon:1.3.2"
// Szkolny.eu libraries/forks
implementation "eu.szkolny:agendacalendarview:1799f8ef47"
implementation "eu.szkolny:agendacalendarview:5431f03098"
implementation "eu.szkolny:cafebar:5bf0c618de"
implementation "eu.szkolny.fslogin:lib:2.0.0"
implementation "eu.szkolny:material-about-library:1d5ebaf47c"

View File

@ -59,18 +59,28 @@ class AgendaFragmentDefault(
private val manager
get() = CalendarManager.getInstance()
// TODO: 2021-04-11 find a way to attach the OnScrollListener automatically
// then set this to IDLE by default
// the FAB also needs the original listener, though
private var scrollState = OnScrollListener.SCROLL_STATE_TOUCH_SCROLL
private var scrollState = OnScrollListener.SCROLL_STATE_IDLE
private var updatePending = false
private var notifyPending = false
override fun onScrollStateChanged(view: AbsListView?, newScrollState: Int) {
b.agendaDefaultView.agendaScrollListener.onScrollStateChanged(view, scrollState)
scrollState = newScrollState
if (updatePending) updateData()
if (notifyPending) notifyDataSetChanged()
}
override fun onScroll(
view: AbsListView?,
firstVisibleItem: Int,
visibleItemCount: Int,
totalItemCount: Int
) = b.agendaDefaultView.agendaScrollListener.onScroll(
view,
firstVisibleItem,
visibleItemCount,
totalItemCount
)
/**
* Mark the data as needing update, either after 1 second (when
* not scrolling) or 1 second after scrolling stops.
@ -94,13 +104,6 @@ class AgendaFragmentDefault(
} else notifyPending = true
}
override fun onScroll(
view: AbsListView?,
firstVisibleItem: Int,
visibleItemCount: Int,
totalItemCount: Int
) = Unit
suspend fun initView(fragment: AgendaFragment) {
isInitialized = false
@ -183,6 +186,8 @@ class AgendaFragmentDefault(
TeacherAbsenceEventRenderer()
)
listView.setOnScrollListener(this)
isInitialized = true
b.progressBar.isVisible = false
}