Home | History | Annotate | Download | only in widget
      1 /*
      2  * Copyright (C) 2013 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 com.android.camera.widget;
     18 
     19 import android.animation.Animator;
     20 import android.graphics.Canvas;
     21 import android.view.MotionEvent;
     22 
     23 /**
     24  * This class aims to encapsulate animation internal states, so that different
     25  * animations running on the same view are more independent.
     26  */
     27 public abstract class AnimationEffects {
     28 
     29     public boolean onTouchEvent(MotionEvent ev) {
     30         return false;
     31     }
     32 
     33     public abstract void setSize(int width, int height);
     34 
     35     /**
     36      * Draws what is needed for the animation in the background, before view calls
     37      * super.draw().
     38      *
     39      * @param canvas canvas that the animation effects will draw on
     40      */
     41     public void drawBackground(Canvas canvas) {}
     42 
     43     /**
     44      * Draws what is needed for the animation in the foreground, after view calls
     45      * super.draw().
     46      *
     47      * @param canvas canvas that the animation effects will draw on
     48      */
     49     public abstract void drawForeground(Canvas canvas);
     50 
     51     /**
     52      * Starts the animation and sets the given animator listener as the listener
     53      * for the animation.
     54      */
     55     public abstract void startAnimation(Animator.AnimatorListener animatorListener);
     56 
     57     /**
     58      * Cancels the current animation effects.
     59      *
     60      * @return true if successful, false otherwise.
     61      */
     62     public boolean cancelAnimation() {
     63         return false;
     64     }
     65 
     66     /**
     67      * Ends the current animation effects. This should be called when animation is
     68      * canceled as well, to make sure all the states are properly set.
     69      */
     70     public abstract void endAnimation();
     71 
     72     /**
     73      * Returns whether super should be drawn when the animation is going on.
     74      */
     75     public boolean shouldDrawSuper() {
     76         return true;
     77     }
     78 }
     79