Merge "Fix clipping while scrolling" into rvc-dev am: 4c6f3ff3e2 am: 22d76d1f6b
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11889960 Change-Id: I54db36fc9242f39b706e08caa6131efa3dbd06ae
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
package com.android.systemui.util.animation
|
package com.android.systemui.util.animation
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.graphics.Canvas
|
||||||
import android.graphics.PointF
|
import android.graphics.PointF
|
||||||
import android.graphics.Rect
|
import android.graphics.Rect
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
@@ -37,6 +38,7 @@ class TransitionLayout @JvmOverloads constructor(
|
|||||||
defStyleAttr: Int = 0
|
defStyleAttr: Int = 0
|
||||||
) : ConstraintLayout(context, attrs, defStyleAttr) {
|
) : ConstraintLayout(context, attrs, defStyleAttr) {
|
||||||
|
|
||||||
|
private val boundsRect = Rect()
|
||||||
private val originalGoneChildrenSet: MutableSet<Int> = mutableSetOf()
|
private val originalGoneChildrenSet: MutableSet<Int> = mutableSetOf()
|
||||||
private val originalViewAlphas: MutableMap<Int, Float> = mutableMapOf()
|
private val originalViewAlphas: MutableMap<Int, Float> = mutableMapOf()
|
||||||
private var measureAsConstraint: Boolean = false
|
private var measureAsConstraint: Boolean = false
|
||||||
@@ -147,16 +149,26 @@ class TransitionLayout @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun dispatchDraw(canvas: Canvas?) {
|
||||||
|
val clip = !boundsRect.isEmpty
|
||||||
|
if (clip) {
|
||||||
|
canvas?.save()
|
||||||
|
canvas?.clipRect(boundsRect)
|
||||||
|
}
|
||||||
|
super.dispatchDraw(canvas)
|
||||||
|
if (clip) {
|
||||||
|
canvas?.restore()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun updateBounds() {
|
private fun updateBounds() {
|
||||||
val layoutLeft = left
|
val layoutLeft = left
|
||||||
val layoutTop = top
|
val layoutTop = top
|
||||||
setLeftTopRightBottom(layoutLeft, layoutTop, layoutLeft + currentState.width,
|
setLeftTopRightBottom(layoutLeft, layoutTop, layoutLeft + currentState.width,
|
||||||
layoutTop + currentState.height)
|
layoutTop + currentState.height)
|
||||||
val bounds = clipBounds ?: Rect()
|
|
||||||
bounds.set(left, top, right, bottom)
|
|
||||||
clipBounds = bounds
|
|
||||||
translationX = currentState.translation.x
|
translationX = currentState.translation.x
|
||||||
translationY = currentState.translation.y
|
translationY = currentState.translation.y
|
||||||
|
boundsRect.set(0, 0, (width + translationX).toInt(), (height + translationY).toInt())
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user