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 17package android.animation; 18 19import com.android.tools.layoutlib.annotations.LayoutlibDelegate; 20 21import android.content.Context; 22import android.content.res.Resources; 23import android.content.res.Resources.NotFoundException; 24import android.content.res.Resources.Theme; 25import android.util.AttributeSet; 26 27/** 28 * Delegate providing alternate implementation to static methods in {@link AnimatorInflater}. 29 */ 30public class AnimatorInflater_Delegate { 31 32 @LayoutlibDelegate 33 /*package*/ static Animator loadAnimator(Context context, int id) 34 throws NotFoundException { 35 return loadAnimator(context.getResources(), context.getTheme(), id); 36 } 37 38 @LayoutlibDelegate 39 /*package*/ static Animator loadAnimator(Resources resources, Theme theme, int id) 40 throws NotFoundException { 41 return loadAnimator(resources, theme, id, 1); 42 } 43 44 @LayoutlibDelegate 45 /*package*/ static Animator loadAnimator(Resources resources, Theme theme, int id, 46 float pathErrorScale) throws NotFoundException { 47 // This is a temporary fix to http://b.android.com/77865. This skips loading the 48 // animation altogether. 49 // TODO: Remove this override when Path.approximate() is supported. 50 return new FakeAnimator(); 51 } 52 53 @LayoutlibDelegate 54 /*package*/ static ValueAnimator loadAnimator(Resources res, Theme theme, 55 AttributeSet attrs, ValueAnimator anim, float pathErrorScale) 56 throws NotFoundException { 57 return AnimatorInflater.loadAnimator_Original(res, theme, attrs, anim, pathErrorScale); 58 } 59} 60