Uploads: load element until loader not displayed anymore

This commit is contained in:
Benoit Marty 2020-05-20 09:16:31 +02:00
parent e3ed3e5b05
commit 907a786b1a
2 changed files with 9 additions and 3 deletions

View File

@ -51,6 +51,8 @@ class UploadsFileController @Inject constructor(
var listener: Listener? = null
private var idx = 0
init {
setData(null)
}
@ -92,7 +94,8 @@ class UploadsFileController @Inject constructor(
if (data.hasMore) {
loadingItem {
id("loadMore")
// Always use a different id, because we can be notified several times of visibility state changed
id("loadMore${idx++}")
onVisibilityStateChanged { _, _, visibilityState ->
if (visibilityState == VisibilityState.VISIBLE) {
listener?.loadMore()

View File

@ -58,7 +58,9 @@ class UploadsMediaController @Inject constructor(
var listener: Listener? = null
private val itemSize = dimensionConverter.dpToPx(64)
private var idx = 0
private val itemSize = dimensionConverter.dpToPx(IMAGE_SIZE_DP)
init {
setData(null)
@ -101,7 +103,8 @@ class UploadsMediaController @Inject constructor(
if (data.hasMore) {
squareLoadingItem {
id("loadMore")
// Always use a different id, because we can be notified several times of visibility state changed
id("loadMore${idx++}")
onVisibilityStateChanged { _, _, visibilityState ->
if (visibilityState == VisibilityState.VISIBLE) {
listener?.loadMore()