1 /* 2 * Copyright (C) 2016 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 package android.view; 17 18 import android.animation.TimeInterpolator; 19 import android.graphics.RecordingCanvas; 20 import android.graphics.RenderNode; 21 22 import com.android.internal.view.animation.FallbackLUTInterpolator; 23 import com.android.internal.view.animation.NativeInterpolatorFactory; 24 import com.android.internal.view.animation.NativeInterpolatorFactoryHelper; 25 26 /** 27 * This is a helper class to get access to methods and fields needed for RenderNodeAnimatorSet 28 * that are internal or package private to android.view package. 29 * 30 * @hide 31 */ 32 public class RenderNodeAnimatorSetHelper { 33 34 /** checkstyle @hide */ getTarget(RecordingCanvas recordingCanvas)35 public static RenderNode getTarget(RecordingCanvas recordingCanvas) { 36 return recordingCanvas.mNode; 37 } 38 39 /** checkstyle @hide */ createNativeInterpolator(TimeInterpolator interpolator, long duration)40 public static long createNativeInterpolator(TimeInterpolator interpolator, long 41 duration) { 42 if (interpolator == null) { 43 // create LinearInterpolator 44 return NativeInterpolatorFactoryHelper.createLinearInterpolator(); 45 } else if (RenderNodeAnimator.isNativeInterpolator(interpolator)) { 46 return ((NativeInterpolatorFactory)interpolator).createNativeInterpolator(); 47 } else { 48 return FallbackLUTInterpolator.createNativeInterpolator(interpolator, duration); 49 } 50 } 51 52 } 53