Back to project page EBrowser.
The source code is released under:
GNU General Public License
If you think the Android project EBrowser listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* * Zirco Browser for Android/*from w w w. j a va2 s . c o m*/ * * Copyright (C) 2010 J. Devauchelle and contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 3 as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package org.zirco.utils; import android.view.animation.AccelerateInterpolator; import android.view.animation.Animation; import android.view.animation.TranslateAnimation; /** * Holder for animation objects. */ public final class AnimationManager { private static final int BARS_ANIMATION_DURATION = 150; private static final int ANIMATION_DURATION = 350; private Animation mTopBarShowAnimation = null; private Animation mTopBarHideAnimation = null; private Animation mBottomBarShowAnimation = null; private Animation mBottomBarHideAnimation = null; private Animation mPreviousTabViewShowAnimation = null; private Animation mPreviousTabViewHideAnimation = null; private Animation mNextTabViewShowAnimation = null; private Animation mNextTabViewHideAnimation = null; private Animation mInFromRightAnimation; private Animation mOutToLeftAnimation; private Animation mInFromLeftAnimation; private Animation mOutToRightAnimation; /** * Holder for singleton implementation. */ private static class AnimationManagerHolder { private static final AnimationManager INSTANCE = new AnimationManager(); } /** * Get the unique instance of the Controller. * @return The instance of the Controller */ public static AnimationManager getInstance() { return AnimationManagerHolder.INSTANCE; } /** * Contructor. */ private AnimationManager() { mTopBarShowAnimation = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f ); mTopBarShowAnimation.setDuration(BARS_ANIMATION_DURATION); mTopBarHideAnimation = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f ); mTopBarHideAnimation.setDuration(BARS_ANIMATION_DURATION); mBottomBarShowAnimation = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f ); mBottomBarShowAnimation.setDuration(BARS_ANIMATION_DURATION); mBottomBarHideAnimation = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f ); mBottomBarHideAnimation.setDuration(BARS_ANIMATION_DURATION); mPreviousTabViewShowAnimation = new TranslateAnimation( Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f ); mPreviousTabViewShowAnimation.setDuration(BARS_ANIMATION_DURATION); mPreviousTabViewHideAnimation = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f ); mPreviousTabViewHideAnimation.setDuration(BARS_ANIMATION_DURATION); mNextTabViewShowAnimation = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f ); mNextTabViewShowAnimation.setDuration(BARS_ANIMATION_DURATION); mNextTabViewHideAnimation = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f ); mNextTabViewHideAnimation.setDuration(BARS_ANIMATION_DURATION); mInFromRightAnimation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, +1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); mInFromRightAnimation.setDuration(ANIMATION_DURATION); mInFromRightAnimation.setInterpolator(new AccelerateInterpolator()); mOutToLeftAnimation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, -1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); mOutToLeftAnimation.setDuration(ANIMATION_DURATION); mOutToLeftAnimation.setInterpolator(new AccelerateInterpolator()); mInFromLeftAnimation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, -1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); mInFromLeftAnimation.setDuration(ANIMATION_DURATION); mInFromLeftAnimation.setInterpolator(new AccelerateInterpolator()); mOutToRightAnimation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, +1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); mOutToRightAnimation.setDuration(ANIMATION_DURATION); mOutToRightAnimation.setInterpolator(new AccelerateInterpolator()); } public Animation getTopBarShowAnimation() { return mTopBarShowAnimation; } public Animation getTopBarHideAnimation() { return mTopBarHideAnimation; } public Animation getBottomBarShowAnimation() { return mBottomBarShowAnimation; } public Animation getBottomBarHideAnimation() { return mBottomBarHideAnimation; } public Animation getPreviousTabViewShowAnimation() { return mPreviousTabViewShowAnimation; } public Animation getPreviousTabViewHideAnimation() { return mPreviousTabViewHideAnimation; } public Animation getNextTabViewShowAnimation() { return mNextTabViewShowAnimation; } public Animation getNextTabViewHideAnimation() { return mNextTabViewHideAnimation; } /** * Get the in from right animation object. * @return The animation object. */ public Animation getInFromRightAnimation() { return mInFromRightAnimation; } /** * Get the out to left animation object. * @return The animation object. */ public Animation getOutToLeftAnimation() { return mOutToLeftAnimation; } /** * Get the in from left animation object. * @return The animation object. */ public Animation getInFromLeftAnimation() { return mInFromLeftAnimation; } /** * Get the out to right animation object. * @return The animation object. */ public Animation getOutToRightAnimation() { return mOutToRightAnimation; } }