AnimationManager.java :  » Web » sett-browser » org » zirco » utils » Android Open Source

Android Open Source » Web » sett browser 
sett browser » org » zirco » utils » AnimationManager.java
/*
 * Zirco Browser for Android
 * 
 * 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 ANIMATION_DURATION = 350;

  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() {
    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());
  }

  /**
   * 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;
  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.