package com.github.ggilrong.library.animationhelper;

import android.view.View;

public class AnimationHelper
{
    public enum Direction {
        LEFT,
        TOP,
        RIGHT,
        BOTTOM
    }

    private static final long DEFAULT_DURATION = 1000;
    private static final long DEFAULT_DELAY = 0;

    public static <T extends View> void move(Direction direction, T view) {
        move(direction, view, DEFAULT_DURATION, DEFAULT_DELAY);
    }

    public static <T extends View> void move(Direction direction, T view, long delay) {
        move(direction, view, DEFAULT_DURATION, delay);
    }

    public static synchronized <T extends View> void move(final Direction direction, final T view, final long duration, long delay) {

        view.postDelayed(new Runnable()
        {
            @Override
            public void run()
            {
                int width = view.getWidth();
                int height = view.getHeight();

                switch(direction)
                {
                    case LEFT:
                        view.animate().translationX(-width).setDuration(duration);
                        break;
                    case TOP:
                        view.animate().translationY(-height).setDuration(duration);
                        break;
                    case RIGHT:
                        view.animate().translationX(width).setDuration(duration);
                        break;
                    case BOTTOM:
                        view.animate().translationY(height).setDuration(duration);
                        break;
                }
            }
        }, delay);
    }
}

@@ -47,16 +47,51 @@
 elper;%0A%0A
+import android.animation.Animator;%0A
 import a
@@ -478,159 +478,641 @@
 ELAY
-);%0A    %7D%0A%0A    public static %3CT extends View%3E void move(Direction direction, T view, long delay) %7B%0A        move(direction, view, DEFAULT_DURATION, delay
+, new SimpleAnimatorListener());%0A    %7D%0A%0A    public static %3CT extends View%3E void move(Direction direction, T view, Animator.AnimatorListener animatorListener) %7B%0A        move(direction, view, DEFAULT_DURATION, DEFAULT_DELAY, animatorListener);%0A    %7D%0A%0A    public static %3CT extends View%3E void move(Direction direction, T view, long delay) %7B%0A        move(direction, view, DEFAULT_DURATION, delay, new SimpleAnimatorListener());%0A    %7D%0A%0A    public static %3CT extends View%3E void move(Direction direction, T view, long delay, Animator.AnimatorListener animatorListener) %7B%0A        move(direction, view, DEFAULT_DURATION, delay, animatorListener
 );%0A 
@@ -1243,24 +1243,74 @@
 , long delay
+, final Animator.AnimatorListener animatorListener
 ) %7B%0A%0A       
@@ -1667,32 +1667,62 @@
 ration(duration)
+.setListener(animatorListener)
 ;%0A              
@@ -1842,32 +1842,62 @@
 ration(duration)
+.setListener(animatorListener)
 ;%0A              
@@ -2017,32 +2017,62 @@
 ration(duration)
+.setListener(animatorListener)
 ;%0A              
@@ -2202,16 +2202,46 @@
 uration)
+.setListener(animatorListener)
 ;%0A      
@@ -2321,11 +2321,489 @@
 );%0A    %7D
+%0A%0A    static class SimpleAnimatorListener implements Animator.AnimatorListener%0A    %7B%0A%0A        @Override%0A        public void onAnimationStart(Animator animation)%0A        %7B%0A%0A        %7D%0A%0A        @Override%0A        public void onAnimationEnd(Animator animation)%0A        %7B%0A%0A        %7D%0A%0A        @Override%0A        public void onAnimationCancel(Animator animation)%0A        %7B%0A%0A        %7D%0A%0A        @Override%0A        public void onAnimationRepeat(Animator animation)%0A        %7B%0A%0A        %7D%0A    %7D
 %0A%7D%0A

add listener