MCPcopy Create free account
hub / github.com/Snapchat/Valdi / onFrameChanged

Method onFrameChanged

valdi/src/java/com/snap/valdi/ViewRef.kt:111–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109 }
110 }
111
112 fun onFrameChanged(x: Int, y: Int, width: Int, height: Int, isRightToLeft: Boolean, animator: Any?) {
113 val view = get() ?: return
114
115 val typedAnimator = animator as? ValdiAnimator
116
117 val wasAnimating = ViewUtils.cancelAnimation(view, "frame")
118 ViewUtils.setIsRightToLeft(view, isRightToLeft)
119
120 if (typedAnimator == null) {
121 measureAndLayout(view, x, y, width, height, false)
122 } else {
123 val fromX: Int
124 val fromY: Int
125 val fromWidth: Int
126 val fromHeight: Int
127 if (!typedAnimator.beginFromCurrentState || !wasAnimating) {
128 fromX = ViewUtils.getCalculatedX(view)
129 fromY = ViewUtils.getCalculatedY(view)
130 fromWidth = ViewUtils.getCalculatedWidth(view)
131 fromHeight = ViewUtils.getCalculatedHeight(view)
132 } else {
133 fromX = view.left
134 fromY = view.top
135 fromWidth = view.width
136 fromHeight = view.height
137 }
138
139 val valueAnimation = ValdiValueAnimation(ValdiValueAnimation.MinimumVisibleChange.PIXEL) { progress ->
140 val fractionX = fromX + ((x - fromX) * progress).toInt()
141 val fractionY = fromY + ((y - fromY) * progress).toInt()
142 val fractionWidth = fromWidth + ((width - fromWidth) * progress).toInt()
143 val fractionHeight = fromHeight + ((height - fromHeight) * progress).toInt()
144
145 measureAndLayout(view, fractionX, fractionY, fractionWidth, fractionHeight, true)
146 }
147 typedAnimator.addValueAnimation("frame", view, valueAnimation)
148 }
149 }
150
151 fun onScrollSpecsChanged(contentOffsetX: Int,

Callers 1

setFrameMethod · 0.45

Calls 10

ValdiValueAnimationClass · 0.85
getCalculatedXMethod · 0.80
getCalculatedYMethod · 0.80
getCalculatedWidthMethod · 0.80
getCalculatedHeightMethod · 0.80
cancelAnimationMethod · 0.65
getFunction · 0.50
setIsRightToLeftMethod · 0.45
toIntMethod · 0.45
addValueAnimationMethod · 0.45

Tested by

no test coverage detected