Fix infinite cluster load animation
This commit is contained in:
@@ -60,9 +60,17 @@ class StreamBrowseViewModel @Inject constructor(
|
|||||||
liveData.postValue(streamCluster)
|
liveData.postValue(streamCluster)
|
||||||
} else {
|
} else {
|
||||||
Log.i(TAG, "End of Cluster")
|
Log.i(TAG, "End of Cluster")
|
||||||
|
postClusterEnd()
|
||||||
}
|
}
|
||||||
} catch (_: Exception) {
|
} catch (_: Exception) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun postClusterEnd() {
|
||||||
|
streamCluster = streamCluster.copy(
|
||||||
|
clusterNextPageUrl = ""
|
||||||
|
)
|
||||||
|
liveData.postValue(streamCluster)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,7 +114,11 @@ class StreamViewModel @Inject constructor(
|
|||||||
|
|
||||||
liveData.postValue(ViewState.Success(stash.toMap()))
|
liveData.postValue(ViewState.Success(stash.toMap()))
|
||||||
} else {
|
} else {
|
||||||
Log.i(TAG, "End of cluster ${streamCluster.id}")
|
stashMutex.withLock {
|
||||||
|
postClusterEnd(category, streamCluster.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
liveData.postValue(ViewState.Success(stash.toMap()))
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
liveData.postValue(ViewState.Error(e.message))
|
liveData.postValue(ViewState.Error(e.message))
|
||||||
@@ -142,6 +146,18 @@ class StreamViewModel @Inject constructor(
|
|||||||
stash[category] = bundle.copy(streamClusters = updatedClusters)
|
stash[category] = bundle.copy(streamClusters = updatedClusters)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun postClusterEnd(category: StreamContract.Category, clusterID: Int) {
|
||||||
|
val bundle = stash[category] ?: return
|
||||||
|
val oldCluster = bundle.streamClusters[clusterID] ?: return
|
||||||
|
|
||||||
|
val updatedCluster = oldCluster.copy(clusterNextPageUrl = "")
|
||||||
|
val updatedClusters = bundle.streamClusters.toMutableMap().apply {
|
||||||
|
this[clusterID] = updatedCluster
|
||||||
|
}
|
||||||
|
|
||||||
|
stash[category] = bundle.copy(streamClusters = updatedClusters)
|
||||||
|
}
|
||||||
|
|
||||||
private fun targetBundle(category: StreamContract.Category): StreamBundle {
|
private fun targetBundle(category: StreamContract.Category): StreamBundle {
|
||||||
return stash.getOrPut(category) { StreamBundle() }
|
return stash.getOrPut(category) { StreamBundle() }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user