Get default animation resource when not defined by the user - Android Animation

Android examples for Animation:Animation Creation

Description

Get default animation resource when not defined by the user

Demo Code


import android.view.Gravity;

public class Main{
    private static final int INVALID = -1;
    /**/*from   w  ww . j a  v a 2s.  com*/
     * Get default animation resource when not defined by the user
     *
     * @param gravity       the gravity of the dialog
     * @param isInAnimation determine if is in or out animation. true when is is
     * @return the id of the animation resource
     */
    static int getAnimationResource(int gravity, boolean isInAnimation) {
        switch (gravity) {
        case Gravity.BOTTOM:
            return isInAnimation ? R.anim.slide_in_bottom
                    : R.anim.slide_out_bottom;
        case Gravity.CENTER:
            return isInAnimation ? R.anim.fade_in_center
                    : R.anim.fade_out_center;
        }
        return INVALID;
    }
}

Related Tutorials