10b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta/*
20b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta * Copyright (C) 2014 The Android Open Source Project
30b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta *
40b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta * Licensed under the Apache License, Version 2.0 (the "License");
50b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta * you may not use this file except in compliance with the License.
60b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta * You may obtain a copy of the License at
70b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta *
80b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta *      http://www.apache.org/licenses/LICENSE-2.0
90b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta *
100b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta * Unless required by applicable law or agreed to in writing, software
110b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta * distributed under the License is distributed on an "AS IS" BASIS,
120b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
130b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta * See the License for the specific language governing permissions and
140b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta * limitations under the License.
150b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta */
160b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta
170b42936d860238be9321f05cf70e934f81b94d72Deepanshu Guptapackage android.animation;
180b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta
190b42936d860238be9321f05cf70e934f81b94d72Deepanshu Guptaimport com.android.tools.layoutlib.annotations.LayoutlibDelegate;
200b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta
210b42936d860238be9321f05cf70e934f81b94d72Deepanshu Guptaimport android.content.Context;
220b42936d860238be9321f05cf70e934f81b94d72Deepanshu Guptaimport android.content.res.Resources;
230b42936d860238be9321f05cf70e934f81b94d72Deepanshu Guptaimport android.content.res.Resources.NotFoundException;
240b42936d860238be9321f05cf70e934f81b94d72Deepanshu Guptaimport android.content.res.Resources.Theme;
25617e809731d775d9e05758689bab024e34c9afbfDeepanshu Guptaimport android.util.AttributeSet;
260b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta
270b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta/**
280b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta * Delegate providing alternate implementation to static methods in {@link AnimatorInflater}.
290b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta */
300b42936d860238be9321f05cf70e934f81b94d72Deepanshu Guptapublic class AnimatorInflater_Delegate {
310b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta
320b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta    @LayoutlibDelegate
330b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta    /*package*/ static Animator loadAnimator(Context context, int id)
340b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta            throws NotFoundException {
350b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta        return loadAnimator(context.getResources(), context.getTheme(), id);
360b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta    }
370b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta
380b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta    @LayoutlibDelegate
390b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta    /*package*/ static Animator loadAnimator(Resources resources, Theme theme, int id)
400b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta            throws NotFoundException {
410b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta        return loadAnimator(resources, theme, id, 1);
420b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta    }
430b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta
440b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta    @LayoutlibDelegate
450b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta    /*package*/ static Animator loadAnimator(Resources resources, Theme theme, int id,
460b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta            float pathErrorScale) throws NotFoundException {
470b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta        // This is a temporary fix to http://b.android.com/77865. This skips loading the
480b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta        // animation altogether.
490b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta        // TODO: Remove this override when Path.approximate() is supported.
500b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta        return new FakeAnimator();
510b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta    }
52617e809731d775d9e05758689bab024e34c9afbfDeepanshu Gupta
53617e809731d775d9e05758689bab024e34c9afbfDeepanshu Gupta    @LayoutlibDelegate
54617e809731d775d9e05758689bab024e34c9afbfDeepanshu Gupta    /*package*/ static ValueAnimator loadAnimator(Resources res, Theme theme,
55617e809731d775d9e05758689bab024e34c9afbfDeepanshu Gupta            AttributeSet attrs, ValueAnimator anim, float pathErrorScale)
56617e809731d775d9e05758689bab024e34c9afbfDeepanshu Gupta            throws NotFoundException {
572c5cddbd07bb46b22617a362f3af23be7720f9d5Deepanshu Gupta        return AnimatorInflater.loadAnimator_Original(res, theme, attrs, anim, pathErrorScale);
58617e809731d775d9e05758689bab024e34c9afbfDeepanshu Gupta    }
590b42936d860238be9321f05cf70e934f81b94d72Deepanshu Gupta}
60