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.view;
18
19import android.animation.Animator;
20import android.animation.Animator.AnimatorListener;
21import android.animation.RevealAnimator;
22
23/**
24 * Defines common utilities for working with View's animations.
25 *
26 */
27public final class ViewAnimationUtils {
28    private ViewAnimationUtils() {}
29    /**
30     * Returns an Animator which can animate a clipping circle.
31     * <p>
32     * Any shadow cast by the View will respect the circular clip from this animator.
33     * <p>
34     * Only a single non-rectangular clip can be applied on a View at any time.
35     * Views clipped by a circular reveal animation take priority over
36     * {@link View#setClipToOutline(boolean) View Outline clipping}.
37     * <p>
38     * Note that the animation returned here is a one-shot animation. It cannot
39     * be re-used, and once started it cannot be paused or resumed. It is also
40     * an asynchronous animation that automatically runs off of the UI thread.
41     * As a result {@link AnimatorListener#onAnimationEnd(Animator)}
42     * will occur after the animation has ended, but it may be delayed depending
43     * on thread responsiveness.
44     *
45     * @param view The View will be clipped to the animating circle.
46     * @param centerX The x coordinate of the center of the animating circle, relative to
47     *                <code>view</code>.
48     * @param centerY The y coordinate of the center of the animating circle, relative to
49     *                <code>view</code>.
50     * @param startRadius The starting radius of the animating circle.
51     * @param endRadius The ending radius of the animating circle.
52     */
53    public static Animator createCircularReveal(View view,
54            int centerX,  int centerY, float startRadius, float endRadius) {
55        return new RevealAnimator(view, centerX, centerY, startRadius, endRadius);
56    }
57}
58