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 
17 package android.graphics.drawable;
18 
19 import android.annotation.NonNull;
20 
21 /**
22  * Abstract class that drawables supporting animations and callbacks should extend.
23  */
24 public interface Animatable2 extends Animatable {
25 
26     /**
27      * Adds a callback to listen to the animation events.
28      *
29      * @param callback Callback to add.
30      */
registerAnimationCallback(@onNull AnimationCallback callback)31     void registerAnimationCallback(@NonNull AnimationCallback callback);
32 
33     /**
34      * Removes the specified animation callback.
35      *
36      * @param callback Callback to remove.
37      * @return {@code false} if callback didn't exist in the call back list, or {@code true} if
38      *         callback has been removed successfully.
39      */
unregisterAnimationCallback(@onNull AnimationCallback callback)40     boolean unregisterAnimationCallback(@NonNull AnimationCallback callback);
41 
42     /**
43      * Removes all existing animation callbacks.
44      */
clearAnimationCallbacks()45     void clearAnimationCallbacks();
46 
47     public static abstract class AnimationCallback {
48         /**
49          * Called when the animation starts.
50          *
51          * @param drawable The drawable started the animation.
52          */
onAnimationStart(Drawable drawable)53         public void onAnimationStart(Drawable drawable) {};
54         /**
55          * Called when the animation ends.
56          *
57          * @param drawable The drawable finished the animation.
58          */
onAnimationEnd(Drawable drawable)59         public void onAnimationEnd(Drawable drawable) {};
60     }
61 }
62