Merge "Fixed that texts of players would often remain empty" into rvc-dev

This commit is contained in:
Selim Cinek
2020-06-30 21:09:34 +00:00
committed by Android (Google) Code Review
2 changed files with 20 additions and 15 deletions

View File

@@ -249,6 +249,7 @@ class MediaCarouselController @Inject constructor(
val lp = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, val lp = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT) ViewGroup.LayoutParams.WRAP_CONTENT)
existingPlayer.view?.player?.setLayoutParams(lp) existingPlayer.view?.player?.setLayoutParams(lp)
existingPlayer.bind(data)
existingPlayer.setListening(currentlyExpanded) existingPlayer.setListening(currentlyExpanded)
updatePlayerToState(existingPlayer, noAnimation = true) updatePlayerToState(existingPlayer, noAnimation = true)
if (existingPlayer.isPlaying) { if (existingPlayer.isPlaying) {
@@ -256,16 +257,18 @@ class MediaCarouselController @Inject constructor(
} else { } else {
mediaContent.addView(existingPlayer.view?.player) mediaContent.addView(existingPlayer.view?.player)
} }
} else if (existingPlayer.isPlaying && } else {
mediaContent.indexOfChild(existingPlayer.view?.player) != 0) { existingPlayer.bind(data)
if (visualStabilityManager.isReorderingAllowed) { if (existingPlayer.isPlaying &&
mediaContent.removeView(existingPlayer.view?.player) mediaContent.indexOfChild(existingPlayer.view?.player) != 0) {
mediaContent.addView(existingPlayer.view?.player, 0) if (visualStabilityManager.isReorderingAllowed) {
} else { mediaContent.removeView(existingPlayer.view?.player)
needsReordering = true mediaContent.addView(existingPlayer.view?.player, 0)
} else {
needsReordering = true
}
} }
} }
existingPlayer?.bind(data)
updatePageIndicator() updatePageIndicator()
mediaCarouselScrollHandler.onPlayersChanged() mediaCarouselScrollHandler.onPlayersChanged()
mediaCarousel.requiresRemeasuring = true mediaCarousel.requiresRemeasuring = true

View File

@@ -268,7 +268,6 @@ class MediaViewController @Inject constructor(
fun attach(transitionLayout: TransitionLayout) { fun attach(transitionLayout: TransitionLayout) {
this.transitionLayout = transitionLayout this.transitionLayout = transitionLayout
layoutController.attach(transitionLayout) layoutController.attach(transitionLayout)
ensureAllMeasurements()
if (currentEndLocation == -1) { if (currentEndLocation == -1) {
return return
} }
@@ -414,13 +413,16 @@ class MediaViewController @Inject constructor(
* Clear all existing measurements and refresh the state to match the view. * Clear all existing measurements and refresh the state to match the view.
*/ */
fun refreshState() { fun refreshState() {
if (!firstRefresh) { // Let's clear all of our measurements and recreate them!
// Let's clear all of our measurements and recreate them! viewStates.clear()
viewStates.clear() if (firstRefresh) {
setCurrentState(currentStartLocation, currentEndLocation, currentTransitionProgress, // This is the first bind, let's ensure we pre-cache all measurements. Otherwise
applyImmediately = true) // We'll just load these on demand.
ensureAllMeasurements()
firstRefresh = false
} }
firstRefresh = false setCurrentState(currentStartLocation, currentEndLocation, currentTransitionProgress,
applyImmediately = true)
} }
} }