1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.view; 18 19 import android.annotation.NonNull; 20 import android.graphics.CanvasProperty; 21 import android.graphics.Paint; 22 23 /** 24 * @hide 25 */ 26 public class RenderNodeAnimator extends android.graphics.animation.RenderNodeAnimator 27 implements android.graphics.animation.RenderNodeAnimator.ViewListener { 28 29 private View mViewTarget; 30 RenderNodeAnimator(int property, float finalValue)31 public RenderNodeAnimator(int property, float finalValue) { 32 super(property, finalValue); 33 } 34 RenderNodeAnimator(CanvasProperty<Float> property, float finalValue)35 public RenderNodeAnimator(CanvasProperty<Float> property, float finalValue) { 36 super(property, finalValue); 37 } 38 RenderNodeAnimator(CanvasProperty<Paint> property, int paintField, float finalValue)39 public RenderNodeAnimator(CanvasProperty<Paint> property, int paintField, float finalValue) { 40 super(property, paintField, finalValue); 41 } 42 RenderNodeAnimator(int x, int y, float startRadius, float endRadius)43 public RenderNodeAnimator(int x, int y, float startRadius, float endRadius) { 44 super(x, y, startRadius, endRadius); 45 } 46 47 @Override onAlphaAnimationStart(float finalAlpha)48 public void onAlphaAnimationStart(float finalAlpha) { 49 // Alpha is a special snowflake that has the canonical value stored 50 // in mTransformationInfo instead of in RenderNode, so we need to update 51 // it with the final value here. 52 mViewTarget.ensureTransformationInfo(); 53 mViewTarget.setAlphaInternal(finalAlpha); 54 } 55 56 @Override invalidateParent(boolean forceRedraw)57 public void invalidateParent(boolean forceRedraw) { 58 mViewTarget.invalidateViewProperty(true, false); 59 } 60 61 /** @hide */ setTarget(@onNull View view)62 public void setTarget(@NonNull View view) { 63 mViewTarget = view; 64 setViewListener(this); 65 setTarget(mViewTarget.mRenderNode); 66 } 67 } 68