1/*
2 * Copyright (C) 2015 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.support.design.widget;
18
19import android.animation.Animator;
20import android.animation.AnimatorListenerAdapter;
21import android.animation.ValueAnimator;
22import android.view.animation.Interpolator;
23
24class ValueAnimatorCompatImplHoneycombMr1 extends ValueAnimatorCompat.Impl {
25
26    final ValueAnimator mValueAnimator;
27
28    ValueAnimatorCompatImplHoneycombMr1() {
29        mValueAnimator = new ValueAnimator();
30    }
31
32    @Override
33    public void start() {
34        mValueAnimator.start();
35    }
36
37    @Override
38    public boolean isRunning() {
39        return mValueAnimator.isRunning();
40    }
41
42    @Override
43    public void setInterpolator(Interpolator interpolator) {
44        mValueAnimator.setInterpolator(interpolator);
45    }
46
47    @Override
48    public void setUpdateListener(final AnimatorUpdateListenerProxy updateListener) {
49        mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
50            @Override
51            public void onAnimationUpdate(ValueAnimator valueAnimator) {
52                updateListener.onAnimationUpdate();
53            }
54        });
55    }
56
57    @Override
58    public void setListener(final AnimatorListenerProxy listener) {
59        mValueAnimator.addListener(new AnimatorListenerAdapter() {
60            @Override
61            public void onAnimationStart(Animator animator) {
62                listener.onAnimationStart();
63            }
64
65            @Override
66            public void onAnimationEnd(Animator animator) {
67                listener.onAnimationEnd();
68            }
69
70            @Override
71            public void onAnimationCancel(Animator animator) {
72                listener.onAnimationCancel();
73            }
74        });
75    }
76
77    @Override
78    public void setIntValues(int from, int to) {
79        mValueAnimator.setIntValues(from, to);
80    }
81
82    @Override
83    public int getAnimatedIntValue() {
84        return (int) mValueAnimator.getAnimatedValue();
85    }
86
87    @Override
88    public void setFloatValues(float from, float to) {
89        mValueAnimator.setFloatValues(from, to);
90    }
91
92    @Override
93    public float getAnimatedFloatValue() {
94        return (float) mValueAnimator.getAnimatedValue();
95    }
96
97    @Override
98    public void setDuration(int duration) {
99        mValueAnimator.setDuration(duration);
100    }
101
102    @Override
103    public void cancel() {
104        mValueAnimator.cancel();
105    }
106
107    @Override
108    public float getAnimatedFraction() {
109        return mValueAnimator.getAnimatedFraction();
110    }
111
112    @Override
113    public void end() {
114        mValueAnimator.end();
115    }
116}
117