Fixed an issue where scrolling didn't work anymore after going to landscape am: f629b618a4 am: e3a958a448 am: 3cd1f298d2
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12013417 Change-Id: I17590d07f17b730615fca775a01b87b33bd9d2d5
This commit is contained in:
@@ -464,7 +464,7 @@ class MediaCarouselController @Inject constructor(
|
|||||||
val width = desiredHostState?.measurementInput?.width ?: 0
|
val width = desiredHostState?.measurementInput?.width ?: 0
|
||||||
val height = desiredHostState?.measurementInput?.height ?: 0
|
val height = desiredHostState?.measurementInput?.height ?: 0
|
||||||
if (width != carouselMeasureWidth && width != 0 ||
|
if (width != carouselMeasureWidth && width != 0 ||
|
||||||
height != carouselMeasureWidth && height != 0) {
|
height != carouselMeasureHeight && height != 0) {
|
||||||
carouselMeasureWidth = width
|
carouselMeasureWidth = width
|
||||||
carouselMeasureHeight = height
|
carouselMeasureHeight = height
|
||||||
val playerWidthPlusPadding = carouselMeasureWidth +
|
val playerWidthPlusPadding = carouselMeasureWidth +
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ class MediaCarouselScrollHandler(
|
|||||||
}
|
}
|
||||||
val rotation = (1.0f - settingsOffset) * 50
|
val rotation = (1.0f - settingsOffset) * 50
|
||||||
settingsButton.rotation = rotation * -Math.signum(contentTranslation)
|
settingsButton.rotation = rotation * -Math.signum(contentTranslation)
|
||||||
val alpha = MathUtils.map(0.5f, 1.0f, 0.0f, 1.0f, settingsOffset)
|
val alpha = MathUtils.saturate(MathUtils.map(0.5f, 1.0f, 0.0f, 1.0f, settingsOffset))
|
||||||
settingsButton.alpha = alpha
|
settingsButton.alpha = alpha
|
||||||
settingsButton.visibility = if (alpha != 0.0f) View.VISIBLE else View.INVISIBLE
|
settingsButton.visibility = if (alpha != 0.0f) View.VISIBLE else View.INVISIBLE
|
||||||
settingsButton.translationX = newTranslationX
|
settingsButton.translationX = newTranslationX
|
||||||
|
|||||||
@@ -47,12 +47,29 @@ class TransitionLayout @JvmOverloads constructor(
|
|||||||
private var currentState: TransitionViewState = TransitionViewState()
|
private var currentState: TransitionViewState = TransitionViewState()
|
||||||
private var updateScheduled = false
|
private var updateScheduled = false
|
||||||
|
|
||||||
|
private var desiredMeasureWidth = 0
|
||||||
|
private var desiredMeasureHeight = 0
|
||||||
/**
|
/**
|
||||||
* The measured state of this view which is the one we will lay ourselves out with. This
|
* The measured state of this view which is the one we will lay ourselves out with. This
|
||||||
* may differ from the currentState if there is an external animation or transition running.
|
* may differ from the currentState if there is an external animation or transition running.
|
||||||
* This state will not be used to measure the widgets, where the current state is preferred.
|
* This state will not be used to measure the widgets, where the current state is preferred.
|
||||||
*/
|
*/
|
||||||
var measureState: TransitionViewState = TransitionViewState()
|
var measureState: TransitionViewState = TransitionViewState()
|
||||||
|
set(value) {
|
||||||
|
val newWidth = value.width
|
||||||
|
val newHeight = value.height
|
||||||
|
if (newWidth != desiredMeasureWidth || newHeight != desiredMeasureHeight) {
|
||||||
|
desiredMeasureWidth = newWidth
|
||||||
|
desiredMeasureHeight = newHeight
|
||||||
|
// We need to make sure next time we're measured that our onMeasure will be called.
|
||||||
|
// Otherwise our parent thinks we still have the same height
|
||||||
|
if (isInLayout()) {
|
||||||
|
forceLayout()
|
||||||
|
} else {
|
||||||
|
requestLayout()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
private val preDrawApplicator = object : ViewTreeObserver.OnPreDrawListener {
|
private val preDrawApplicator = object : ViewTreeObserver.OnPreDrawListener {
|
||||||
override fun onPreDraw(): Boolean {
|
override fun onPreDraw(): Boolean {
|
||||||
updateScheduled = false
|
updateScheduled = false
|
||||||
@@ -158,7 +175,7 @@ class TransitionLayout @JvmOverloads constructor(
|
|||||||
MeasureSpec.EXACTLY)
|
MeasureSpec.EXACTLY)
|
||||||
child.measure(measureWidthSpec, measureHeightSpec)
|
child.measure(measureWidthSpec, measureHeightSpec)
|
||||||
}
|
}
|
||||||
setMeasuredDimension(measureState.width, measureState.height)
|
setMeasuredDimension(desiredMeasureWidth, desiredMeasureHeight)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user