fix: fixed refresh Issue

This commit is contained in:
Stefan Schüller 2022-02-04 23:42:31 +01:00
parent ed49946fb3
commit ca0734e977
4 changed files with 14 additions and 10 deletions

View File

@ -30,7 +30,7 @@ Issues:
- Memory issue on explore list
- Word "Subscribe" too long in app bar
- VideoList meta bar can't be dynamic height, causes scroll back issue.
- Refreshing video list causes odd loading order of video items
x Refreshing video list causes odd loading order of video items
- playback rotate on click doesn't re-hide buttons
- Explore list is memory intensive, leak??
- Access Token refresh circular injection problem

View File

@ -53,10 +53,12 @@ class SearchPagingSource (
// We need to get the previous key (or next key if previous is null) of the page
// that was closest to the most recently accessed index.
// Anchor position is the most recently accessed index
return state.anchorPosition?.let { anchorPosition ->
state.closestPageToPosition(anchorPosition)?.prevKey?.plus(1)
?: state.closestPageToPosition(anchorPosition)?.nextKey?.minus(1)
}
// return state.anchorPosition?.let { anchorPosition ->
// state.closestPageToPosition(anchorPosition)?.prevKey?.plus(1)
// ?: state.closestPageToPosition(anchorPosition)?.nextKey?.minus(1)
// }
//
return 0
}

View File

@ -49,13 +49,15 @@ class VideoPagingSource (
}
// The refresh key is used for subsequent refresh calls to PagingSource.load after the initial load
override fun getRefreshKey(state: PagingState<Int, Video>): Int? {
Log.v("video1", "getRefreshKey")
// We need to get the previous key (or next key if previous is null) of the page
// that was closest to the most recently accessed index.
// Anchor position is the most recently accessed index
return state.anchorPosition?.let { anchorPosition ->
state.closestPageToPosition(anchorPosition)?.prevKey?.plus(1)
?: state.closestPageToPosition(anchorPosition)?.nextKey?.minus(1)
}
// return state.anchorPosition?.let { anchorPosition ->
// state.closestPageToPosition(anchorPosition)?.prevKey?.plus(1)
// ?: state.closestPageToPosition(anchorPosition)?.nextKey?.minus(1)
// }
return 0
}

View File

@ -180,7 +180,7 @@ fun VideoListScreen(
} else {
itemsIndexed(lazyVideoItems) { item, video ->
if (video != null) {
// Log.v("VLV", video.id.toString() + "-" + item.toString())
Log.v("VLV", video.id.toString() + "-" + item.toString())
VideoListItem(
video = video,
onItemClick = {