– capitalize and stylize comments
– fix history items duplication
– fix refresh glitching after removing multiple history items
pull/600/head
mike a 3 years ago committed by mergify[bot]
parent a08b86eeee
commit d7eed1046e

@ -19,7 +19,7 @@ class HistoryDataSource(
override fun getRefreshKey(state: PagingState<Int, History>): Int? = null override fun getRefreshKey(state: PagingState<Int, History>): Int? = null
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, History> { 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 // Get the offset of the last loaded page or default to 0 when it is null on the initial
// load or a refresh. // load or a refresh.
val offset = params.key ?: 0 val offset = params.key ?: 0
val historyItems = historyProvider.getHistory(offset, params.loadSize).run { val historyItems = historyProvider.getHistory(offset, params.loadSize).run {
@ -28,7 +28,7 @@ class HistoryDataSource(
val nextOffset = if (historyItems.isEmpty()) { val nextOffset = if (historyItems.isEmpty()) {
null null
} else { } else {
(offset + historyItems.size) + 1 historyItems.last().position + 1
} }
return LoadResult.Page( return LoadResult.Page(
data = historyItems, data = historyItems,

@ -35,13 +35,12 @@ class HistoryView(
val historyAdapter = HistoryAdapter(interactor).apply { val historyAdapter = HistoryAdapter(interactor).apply {
addLoadStateListener { addLoadStateListener {
// first call will always have itemCount == 0, but we want to keep adapterItemCount // First call will always have itemCount == 0, but we want to keep adapterItemCount
// as null until we can distinguish an empty list from populated, so updateEmptyState() // as null until we can distinguish an empty list from populated, so updateEmptyState()
// could work correctly // could work correctly.
if (itemCount != 0) { if (itemCount > 0) {
adapterItemCount = itemCount adapterItemCount = itemCount
} } else if (it.source.refresh is LoadState.NotLoading &&
if (it.source.refresh is LoadState.NotLoading &&
it.append.endOfPaginationReached && it.append.endOfPaginationReached &&
itemCount < 1 itemCount < 1
) { ) {

@ -25,7 +25,7 @@
layout="@layout/recently_closed_nav_item" layout="@layout/recently_closed_nav_item"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/progress_bar" /> app:layout_constraintTop_toTopOf="parent" />
<TextView <TextView
android:id="@+id/history_empty_view" android:id="@+id/history_empty_view"

Loading…
Cancel
Save