Search in sources :

Example 56 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project actor-platform by actorapp.

the class ExplorerFragment method onCreateAnimator.

@Override
public Animator onCreateAnimator(int transit, boolean enter, int nextAnim) {
    Log.d("Explorer animation", "CreateAnimator: " + transit + " " + enter + " " + nextAnim);
    int animationLength = 0;
    if (nextAnim == R.animator.picker_fragment_explorer_welcome_enter) {
        list.setAlpha(0);
        list.post(new Runnable() {

            @Override
            public void run() {
                list.setAlpha(1);
                int offsetIncreaseOffset = 0;
                for (int i = 0; i < list.getChildCount(); i++) {
                    View searchItemView = list.getChildAt(i);
                    AnimationSet slideInAnimation = new AnimationSet(true);
                    slideInAnimation.setInterpolator(new MaterialInterpolator());
                    slideInAnimation.setDuration(180);
                    if (items.get(i) instanceof HeaderItem) {
                        offsetIncreaseOffset += 150;
                        slideInAnimation.setStartOffset(i * 50 + offsetIncreaseOffset);
                        offsetIncreaseOffset += 200;
                    } else
                        slideInAnimation.setStartOffset(i * 50 + offsetIncreaseOffset);
                    AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1);
                    slideInAnimation.addAnimation(alphaAnimation);
                    TranslateAnimation translateAnimation = new TranslateAnimation(0, 0, 150, 0);
                    slideInAnimation.addAnimation(translateAnimation);
                    searchItemView.startAnimation(slideInAnimation);
                }
            }
        });
        animationLength = list.getChildCount() * 100 + 50;
        Log.d("Explorer animation", "CreateAnimator: enter");
    } else if (nextAnim == R.animator.picker_fragment_explorer_enter) {
        list.setAlpha(0);
        list.post(new Runnable() {

            @Override
            public void run() {
                list.setAlpha(1);
                int offsetIncreaseOffset = 0;
                for (int i = 0; i < list.getChildCount(); i++) {
                    View searchItemView = list.getChildAt(i);
                    AnimationSet slideInAnimation = new AnimationSet(true);
                    slideInAnimation.setInterpolator(new MaterialInterpolator());
                    slideInAnimation.setDuration(100);
                    slideInAnimation.setStartOffset(i * 50 + offsetIncreaseOffset);
                    AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1);
                    slideInAnimation.addAnimation(alphaAnimation);
                    TranslateAnimation translateAnimation = new TranslateAnimation(100, 0, 0, 0);
                    slideInAnimation.addAnimation(translateAnimation);
                    searchItemView.startAnimation(slideInAnimation);
                }
            }
        });
        animationLength = list.getChildCount() * 100 + 50;
        Log.d("Explorer animation", "CreateAnimator: enter");
    } else if (nextAnim == R.animator.picker_fragment_explorer_welcome_exit || nextAnim == R.animator.picker_fragment_explorer_exit) {
        for (int i = 0; i < list.getChildCount(); i++) {
            View searchItemView = list.getChildAt(i);
            AnimationSet slideInAnimation = new AnimationSet(true);
            slideInAnimation.setInterpolator(new MaterialInterpolator());
            slideInAnimation.setDuration(100);
            slideInAnimation.setStartOffset(i * 50);
            slideInAnimation.setFillAfter(true);
            AlphaAnimation alphaAnimation = new AlphaAnimation(1, 0);
            alphaAnimation.setFillAfter(true);
            slideInAnimation.addAnimation(alphaAnimation);
            TranslateAnimation translateAnimation = new TranslateAnimation(0, -100, 0, 0);
            slideInAnimation.addAnimation(translateAnimation);
            searchItemView.startAnimation(slideInAnimation);
        }
        // list.getChildCount() * 100 + 50;
        animationLength = 0;
        Log.d("Explorer animation", "CreateAnimator: exit");
    } else if (nextAnim == R.animator.picker_fragment_explorer_return) {
        list.setAlpha(0);
        list.post(new Runnable() {

            @Override
            public void run() {
                list.setAlpha(1);
                for (int i = 0; i < list.getChildCount(); i++) {
                    View searchItemView = list.getChildAt(i);
                    AnimationSet slideInAnimation = new AnimationSet(true);
                    slideInAnimation.setInterpolator(new MaterialInterpolator());
                    slideInAnimation.setDuration(100);
                    slideInAnimation.setStartOffset(i * 50);
                    AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1);
                    slideInAnimation.addAnimation(alphaAnimation);
                    TranslateAnimation translateAnimation = new TranslateAnimation(-100, 0, 0, 0);
                    slideInAnimation.addAnimation(translateAnimation);
                    searchItemView.startAnimation(slideInAnimation);
                }
            }
        });
        animationLength = list.getChildCount() * 100 + 50;
        Log.d("Explorer animation", "CreateAnimator: return");
    } else if (nextAnim == R.animator.picker_fragment_explorer_out) {
        for (int i = 0; i < list.getChildCount(); i++) {
            View searchItemView = list.getChildAt(i);
            AnimationSet slideInAnimation = new AnimationSet(true);
            slideInAnimation.setInterpolator(new MaterialInterpolator());
            slideInAnimation.setDuration(100);
            slideInAnimation.setStartOffset(i * 50);
            slideInAnimation.setFillAfter(true);
            AlphaAnimation alphaAnimation = new AlphaAnimation(1, 0);
            alphaAnimation.setFillAfter(true);
            slideInAnimation.addAnimation(alphaAnimation);
            TranslateAnimation translateAnimation = new TranslateAnimation(0, 100, 0, 0);
            slideInAnimation.addAnimation(translateAnimation);
            searchItemView.startAnimation(slideInAnimation);
        }
        if (items.size() == 1) {
            AlphaAnimation alphaAnimation = new AlphaAnimation(1, 0);
            alphaAnimation.setInterpolator(new MaterialInterpolator());
            alphaAnimation.setDuration(100);
            alphaAnimation.setFillAfter(true);
            emptyView.startAnimation(alphaAnimation);
            statusView.startAnimation(alphaAnimation);
            animationLength = 250;
        }
        // else
        // list.getChildCount() * 100 + 50;
        animationLength = 0;
        Log.d("Explorer animation", "CreateAnimator: out");
    }
    AnimatorSet animator = (AnimatorSet) AnimatorInflater.loadAnimator(pickerActivity, R.animator.picker_fragment_explorer_enter);
    animator.setDuration(animationLength);
    return animator;
}
Also used : MaterialInterpolator(im.actor.sdk.controllers.pickers.file.view.MaterialInterpolator) TranslateAnimation(android.view.animation.TranslateAnimation) AnimatorSet(android.animation.AnimatorSet) HeaderItem(im.actor.sdk.controllers.pickers.file.items.HeaderItem) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) AnimationSet(android.view.animation.AnimationSet) AlphaAnimation(android.view.animation.AlphaAnimation)

Example 57 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project mapbox-navigation-android by mapbox.

the class RecenterButton method initAnimation.

/**
 * Creates the custom animation used to show this button.
 */
private void initAnimation() {
    slideUpBottom = new TranslateAnimation(0f, 0f, 125f, 0f);
    slideUpBottom.setDuration(300);
    slideUpBottom.setInterpolator(new OvershootInterpolator(2.0f));
}
Also used : OvershootInterpolator(android.view.animation.OvershootInterpolator) TranslateAnimation(android.view.animation.TranslateAnimation)

Example 58 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project android by lucadln.

the class ConjugationCenter method slideUp.

// slide the view from below itself to the current position
public void slideUp(View view) {
    view.setVisibility(View.VISIBLE);
    TranslateAnimation animate = new TranslateAnimation(// fromXDelta
    0, // toXDelta
    0, // fromYDelta
    300, // toYDelta
    0);
    animate.setDuration(400);
    animate.setFillAfter(true);
    view.startAnimation(animate);
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation)

Example 59 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project android by lucadln.

the class ConjugationCenter method slideDown.

// slide the view from its current position to below itself
public void slideDown(View view) {
    TranslateAnimation animate = new TranslateAnimation(// fromXDelta
    0, // toXDelta
    0, // fromYDelta
    0, // toYDelta
    view.getHeight());
    animate.setDuration(250);
    animate.setFillAfter(false);
    view.startAnimation(animate);
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation)

Example 60 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project Thesis by bajnax.

the class LeConnectedDeviceActivity method slideFromRight.

public void slideFromRight(View view) {
    TranslateAnimation animate = new TranslateAnimation(view.getWidth(), 0, 0, 0);
    animate.setDuration(500);
    animate.setFillAfter(true);
    view.startAnimation(animate);
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation)

Aggregations

TranslateAnimation (android.view.animation.TranslateAnimation)229 Animation (android.view.animation.Animation)109 AlphaAnimation (android.view.animation.AlphaAnimation)90 AnimationSet (android.view.animation.AnimationSet)69 ScaleAnimation (android.view.animation.ScaleAnimation)44 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)30 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)27 View (android.view.View)22 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)22 TextView (android.widget.TextView)18 AnimationListener (android.view.animation.Animation.AnimationListener)17 LinearInterpolator (android.view.animation.LinearInterpolator)13 RotateAnimation (android.view.animation.RotateAnimation)13 ClipRectAnimation (android.view.animation.ClipRectAnimation)12 ListView (android.widget.ListView)12 CurvedTranslateAnimation (com.android.server.wm.animation.CurvedTranslateAnimation)12 ImageView (android.widget.ImageView)11 LayoutAnimationController (android.view.animation.LayoutAnimationController)8 WindowAnimation_activityCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation)8 WindowAnimation_activityCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation)8