Android Open Source - Billy Animation Utils






From Project

Back to project page Billy.

License

The source code is released under:

GNU General Public License

If you think the Android project Billy listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.vibin.billy.swipeable;
/*from  w  w  w  .ja  va 2 s .  com*/
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.TransitionDrawable;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.widget.ImageView;

/**
 * Created by Saketme on 1/22/14.
 * Common stuff for animation:
 * <p/>
 * 1. Animate transition of images in an ImageView.
 * {@link #animateTransitionOfImage(ImageView, Drawable, boolean, int, ImageView.ScaleType)}
 */
public class AnimationUtils {

    /**
     * Interpolators
     */
    public static final Interpolator EASE_ACCELERATE_DEACELERATE_INTERPOLATOR = new Interpolator() {
        public float getInterpolation(float t) {
            t -= 1.0f;
            return t * t * t * t * t + 1.0f;
        }
    };
    public static final Interpolator DECELERATE_INTERPOLATOR = new DecelerateInterpolator();
    public static final Interpolator DECELERATE_INTERPOLATOR_FAST = new DecelerateInterpolator(2);

    /**
     * Animation durations
     */
    public static final int SUPER_QUICK_ANIM_DURATION = 100;
    public static final int QUICK_ANIM_DURATION = 200;
    public static final int SHORT_ANIM_DURATION = 300;
    public static final int MEDIUM_ANIM_DURATION = 500;
    public static final int LONG_ANIM_DURATION = 700;

    /**
     * Animates the changing of a ImageView (or its subclasses like ImageButton)'s photo.
     *
     * @param crossFadeEnabled Enables or disables the cross fade of the drawables. When cross fade
     *                         is disabled, the first drawable is always drawn opaque. With cross
     *                         fade enabled, the first drawable is drawn with the opposite alpha of
     *                         the second drawable.
     * @param animDuration     Duration for which this animation should run.
     */
    public static void animateTransitionOfImage(ImageView imageView, Drawable newDrawable,
                                                boolean crossFadeEnabled, int animDuration,
                                                final ImageView.ScaleType imageViewScaleType) {

        // TransitionDrawable doesn't accept null Drawables
        if (imageView.getDrawable() == null)
            imageView.setImageDrawable(new ColorDrawable(Color.TRANSPARENT));
        if (newDrawable == null)
            newDrawable = new ColorDrawable(Color.TRANSPARENT);

        TransitionDrawable transitionDrawable = new TransitionDrawable(new Drawable[]{
                imageView.getDrawable(),
                newDrawable
        });

        imageView.setImageDrawable(transitionDrawable);
        imageView.setScaleType(imageViewScaleType);
        transitionDrawable.setCrossFadeEnabled(crossFadeEnabled);
        transitionDrawable.startTransition(animDuration);
    }

    /**
     * Same as previous method, but uses default parameters that are good enough for general
     * cases in our app.
     *
     * @return Duration of animation for which this animation will run
     */
    public static long animateTransitionOfImage(ImageView imageView, Drawable newDrawable) {
        animateTransitionOfImage(imageView, newDrawable, true,
                AnimationUtils.QUICK_ANIM_DURATION, ImageView.ScaleType.CENTER_CROP);

        return AnimationUtils.QUICK_ANIM_DURATION;
    }

}




Java Source Code List

com.vibin.billy.BillyApplication.java
com.vibin.billy.BillyItem.java
com.vibin.billy.BitmapLruCache.java
com.vibin.billy.ChangelogDialog.java
com.vibin.billy.CustomBaseAdapter.java
com.vibin.billy.CustomDatabaseAdapter.java
com.vibin.billy.CustomFragmentAdapter.java
com.vibin.billy.CustomListPreference.java
com.vibin.billy.CustomShareActionProvider.java
com.vibin.billy.CustomStringRequest.java
com.vibin.billy.DetailView.java
com.vibin.billy.LicensesFragment.java
com.vibin.billy.MainActivity.java
com.vibin.billy.MediaControl.java
com.vibin.billy.NotifyingScrollView.java
com.vibin.billy.PPlayerService.java
com.vibin.billy.PlayerService.java
com.vibin.billy.ProcessingTask.java
com.vibin.billy.ReorderedListPreference.java
com.vibin.billy.Settings.java
com.vibin.billy.SongsFragment.java
com.vibin.billy.SwingBottomInAnimationAdapter.java
com.vibin.billy.draglistview.DynamicListView.java
com.vibin.billy.draglistview.StableArrayAdapter.java
com.vibin.billy.swipeable.ActivitySwipeDismissListener.java
com.vibin.billy.swipeable.AnimationUtils.java
com.vibin.billy.swipeable.SwipeDismissViewGroup.java
com.vibin.billy.swipeable.SwipeListener.java
com.vibin.billy.swipeable.SwipeableActivity.java
com.vibin.billy.swipeable.WindowDimens.java
com.vibin.billy.swipeable.WindowUtils.java
org.videolan.libvlc.AudioOutput.java
org.videolan.libvlc.EventHandler.java
org.videolan.libvlc.HWDecoderUtil.java
org.videolan.libvlc.IVideoPlayer.java
org.videolan.libvlc.LibVLC.java
org.videolan.libvlc.LibVlcException.java
org.videolan.libvlc.LibVlcUtil.java
org.videolan.libvlc.MediaList.java
org.videolan.libvlc.Media.java
org.videolan.libvlc.TrackInfo.java