– make comments inside HistoryDataSource capitalized and informative
– remove scroll to first item in swipe-to-refresh
– change adapter initialization
– fixed SitePermissionsExceptionsFragment flickering empty state
upstream-sync
mike a 2 years ago committed by mergify[bot]
parent 548ff770f3
commit 5b481ad204

@ -14,12 +14,13 @@ class HistoryDataSource(
private val historyProvider: PagedHistoryProvider
) : PagingSource<Int, History>() {
// having any value but null creates visual glitches in case or swipe to refresh and immediate
// scroll down
// The refresh key is set to null so that it will always reload the entire list for any data
// updates such as pull to refresh, and return the user to the start of the list.
override fun getRefreshKey(state: PagingState<Int, History>): Int? = null
// params.key is expected to be null for the initial load or a refresh
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, History> {
// Get the offset of the last loaded page or default to 0 when it is null, on the initial
// load or a refresh.
val offset = params.key ?: 0
val historyItems = historyProvider.getHistory(offset, params.loadSize).run {
positionWithOffset(offset)
@ -29,10 +30,9 @@ class HistoryDataSource(
} else {
(offset + historyItems.size) + 1
}
// prevKey is needed in case load would work upwards, so passing null is fine
return LoadResult.Page(
data = historyItems,
prevKey = null,
prevKey = null, // Only paging forward.
nextKey = nextOffset
)
}

@ -65,7 +65,6 @@ class HistoryView(
binding.swipeRefresh.setColorSchemeColors(primaryTextColor)
binding.swipeRefresh.setOnRefreshListener {
interactor.onRequestSync()
binding.historyList.scrollToPosition(0)
}
}

@ -68,9 +68,12 @@ class SitePermissionsExceptionsFragment :
) {
showEmptyListMessage()
} else {
hideEmptyListMessage()
if (itemCount != 0) {
hideEmptyListMessage()
}
}
}
recyclerView.adapter = this
}
viewLifecycleOwner.lifecycleScope.launch(Dispatchers.IO) {
@ -85,8 +88,6 @@ class SitePermissionsExceptionsFragment :
adapter.submitData(it)
}
}
recyclerView.adapter = adapter
}
private fun hideEmptyListMessage() {

Loading…
Cancel
Save