183a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui/*
283a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui * Copyright (C) 2015 The Android Open Source Project
383a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui *
483a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui * Licensed under the Apache License, Version 2.0 (the "License");
583a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui * you may not use this file except in compliance with the License.
683a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui * You may obtain a copy of the License at
783a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui *
883a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui *      http://www.apache.org/licenses/LICENSE-2.0
983a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui *
1083a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui * Unless required by applicable law or agreed to in writing, software
1183a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui * distributed under the License is distributed on an "AS IS" BASIS,
1283a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1383a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui * See the License for the specific language governing permissions and
1483a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui * limitations under the License.
1583a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui */
1683a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui
1783a52031fd5c277d0c6e75da50bf8013e8a70399ztenghuipackage android.graphics.drawable;
1883a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui
1983a52031fd5c277d0c6e75da50bf8013e8a70399ztenghuiimport android.annotation.NonNull;
2083a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui
2183a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui/**
2283a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui * Abstract class that drawables supporting animations and callbacks should extend.
2383a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui */
2483a52031fd5c277d0c6e75da50bf8013e8a70399ztenghuipublic interface Animatable2 extends Animatable {
2583a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui
2683a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui    /**
2783a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui     * Adds a callback to listen to the animation events.
2883a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui     *
2983a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui     * @param callback Callback to add.
3083a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui     */
3183a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui    void registerAnimationCallback(@NonNull AnimationCallback callback);
3283a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui
3383a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui    /**
3483a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui     * Removes the specified animation callback.
3583a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui     *
3683a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui     * @param callback Callback to remove.
3783a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui     * @return {@code false} if callback didn't exist in the call back list, or {@code true} if
3883a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui     *         callback has been removed successfully.
3983a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui     */
4083a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui    boolean unregisterAnimationCallback(@NonNull AnimationCallback callback);
4183a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui
4283a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui    /**
4383a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui     * Removes all existing animation callbacks.
4483a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui     */
4583a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui    void clearAnimationCallbacks();
4683a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui
4783a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui    public static abstract class AnimationCallback {
4883a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui        /**
4983a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui         * Called when the animation starts.
5083a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui         *
5183a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui         * @param drawable The drawable started the animation.
5283a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui         */
5383a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui        public void onAnimationStart(Drawable drawable) {};
5483a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui        /**
5583a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui         * Called when the animation ends.
5683a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui         *
5783a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui         * @param drawable The drawable finished the animation.
5883a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui         */
5983a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui        public void onAnimationEnd(Drawable drawable) {};
6083a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui    }
6183a52031fd5c277d0c6e75da50bf8013e8a70399ztenghui}
62