Rect
values.
*/
@RequiresApi(14)
class RectEvaluator implements TypeEvaluatorreuseRect
* in {@link #evaluate(float, android.graphics.Rect, android.graphics.Rect)} calls.
* The value returned from
* {@link #evaluate(float, android.graphics.Rect, android.graphics.Rect)} should
* not be cached because it will change over time as the object is reused on each
* call.
*
* @param reuseRect A Rect to be modified and returned by evaluate.
*/
RectEvaluator(Rect reuseRect) {
mRect = reuseRect;
}
/**
* This function returns the result of linearly interpolating the start and
* end Rect values, with fraction
representing the proportion
* between the start and end values. The calculation is a simple parametric
* calculation on each of the separate components in the Rect objects
* (left, top, right, and bottom).
*
* If {@link #RectEvaluator(android.graphics.Rect)} was used to construct
* this RectEvaluator, the object returned will be the reuseRect
* passed into the constructor.
fraction
parameter.
*/
@Override
public Rect evaluate(float fraction, Rect startValue, Rect endValue) {
int left = startValue.left + (int) ((endValue.left - startValue.left) * fraction);
int top = startValue.top + (int) ((endValue.top - startValue.top) * fraction);
int right = startValue.right + (int) ((endValue.right - startValue.right) * fraction);
int bottom = startValue.bottom + (int) ((endValue.bottom - startValue.bottom) * fraction);
if (mRect == null) {
return new Rect(left, top, right, bottom);
} else {
mRect.set(left, top, right, bottom);
return mRect;
}
}
}