mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2024-11-24 10:54:36 -06:00
[Agenda] Update scroll listeners code.
This commit is contained in:
parent
f5ceaa9afe
commit
12619f6bde
@ -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"
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user