Example usage for android.view.animation ScaleAnimation setAnimationListener

List of usage examples for android.view.animation ScaleAnimation setAnimationListener

Introduction

In this page you can find the example usage for android.view.animation ScaleAnimation setAnimationListener.

Prototype

public void setAnimationListener(AnimationListener listener) 

Source Link

Document

Binds an animation listener to this animation.

Usage

From source file:Main.java

public static void animationScale(View paramView, long paramLong,
        Animation.AnimationListener paramAnimationListener) {
    ScaleAnimation localScaleAnimation = new ScaleAnimation(0.0F, 1.0F, 0.0F, 1.0F, 1, 0.5F, 1, 0.5F);
    localScaleAnimation.setAnimationListener(paramAnimationListener);
    animation(paramView, localScaleAnimation, paramLong, 0L);
}

From source file:Main.java

public static ScaleAnimation getLessenScaleAnimation(long durationMillis, AnimationListener animationListener) {
    ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, 0.0f, 1.0f, 0.0f, ScaleAnimation.RELATIVE_TO_SELF,
            ScaleAnimation.RELATIVE_TO_SELF);
    scaleAnimation.setDuration(durationMillis);
    scaleAnimation.setAnimationListener(animationListener);
    return scaleAnimation;
}

From source file:Main.java

public static ScaleAnimation getAmplificationAnimation(long durationMillis,
        AnimationListener animationListener) {
    ScaleAnimation scaleAnimation = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, ScaleAnimation.RELATIVE_TO_SELF,
            ScaleAnimation.RELATIVE_TO_SELF);
    scaleAnimation.setDuration(durationMillis);
    scaleAnimation.setAnimationListener(animationListener);
    return scaleAnimation;
}

From source file:Main.java

public static void scale(final View view, float fromScale, float toScale, long duration,
        final Runnable whenDone) {
    if (Build.VERSION.SDK_INT >= 12) {
        if (duration == 0) {
            view.setScaleX(toScale);//from   www. j av  a2s .  com
            view.setScaleY(toScale);
            if (whenDone != null)
                whenDone.run();
        } else {
            ViewPropertyAnimator animation = view.animate().scaleX(toScale).scaleY(toScale)
                    .setDuration(duration);
            if (whenDone != null) {
                animation.setListener(new AnimatorListener() {
                    @Override
                    public void onAnimationCancel(Animator animation) {
                        whenDone.run();
                    }

                    @Override
                    public void onAnimationEnd(Animator animation) {
                        whenDone.run();
                    }

                    @Override
                    public void onAnimationRepeat(Animator animation) {
                    }

                    @Override
                    public void onAnimationStart(Animator animation) {
                    }

                });
            }
            animation.start();
        }
    } else {
        ScaleAnimation scale = new ScaleAnimation(fromScale, toScale, fromScale, toScale,
                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        scale.setDuration(duration);
        scale.setFillEnabled(true);
        scale.setFillBefore(true);
        scale.setFillAfter(true);

        if (whenDone != null) {
            scale.setAnimationListener(new AnimationListener() {
                @Override
                public void onAnimationEnd(Animation animation) {
                    whenDone.run();
                }

                @Override
                public void onAnimationRepeat(Animation animation) {
                }

                @Override
                public void onAnimationStart(Animation animation) {
                }

            });
        }
        addAnimation(view, scale);
    }
}

From source file:quickbeer.android.next.views.ProgressIndicatorBar.java

private void animateToEnd() {
    Log.v(TAG, "animateToEnd()");

    if (progressBar.getAnimation() == null) {
        // Non-active progress bar doesn't need end animation
        return;//  w w  w.j a  va  2 s. c o m
    }

    ScaleAnimation animation = new ScaleAnimation(1, (getWidth() / progressBarWidth) + 1,
            progressBar.getHeight(), progressBar.getHeight());
    animation.setDuration(ANIMATION_END_SCALE_DURATION);
    animation.setFillAfter(true);
    animation.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            animateToHidden();
        }
    });

    progressBar.setVisibility(VISIBLE);
    progressBar.clearAnimation();
    progressBar.startAnimation(animation);
}

From source file:quickbeer.android.views.ProgressIndicatorBar.java

private void animateToProgress(float progress) {
    Timber.v("animateToProgress(%s)", progress);
    checkNotNull(progressBar);/*from   w w w.  j  av a 2s. c  o  m*/

    float newScale = (getWidth() * progress / progressBarWidth) + 1;

    Timber.v("animate scale %s -> %s", barScale, newScale);

    ScaleAnimation animation = new ScaleAnimation(barScale, newScale, progressBar.getHeight(),
            progressBar.getHeight());
    animation.setDuration(ANIMATION_PROGRESS_DURATION);
    animation.setFillAfter(true);
    animation.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            barScale = newScale;
            applyNextStatus();
        }
    });

    progressBar.setVisibility(VISIBLE);
    progressBar.clearAnimation();
    progressBar.startAnimation(animation);
}

From source file:quickbeer.android.views.ProgressIndicatorBar.java

private void animateToEnd() {
    Timber.v("animateToEnd()");
    checkNotNull(progressBar);/*from ww w.j a  v a2 s  . c  o  m*/

    if (progressBar.getAnimation() == null) {
        // Non-active progress bar doesn't need end animation
        return;
    }

    ScaleAnimation animation = new ScaleAnimation(barScale, (getWidth() / (float) progressBarWidth) + 1,
            progressBar.getHeight(), progressBar.getHeight());
    animation.setDuration(ANIMATION_END_SCALE_DURATION);
    animation.setFillAfter(true);
    animation.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            barScale = 1.0f;
            animateToHidden();
        }
    });

    progressBar.setVisibility(VISIBLE);
    progressBar.clearAnimation();
    progressBar.startAnimation(animation);
}

From source file:demo.camera.library.ui.CameraCaptureActivity.java

public void setUpUi() {
    mBlockerSpinner = (RelativeLayout) findViewById(R.id.blocker);
    mBlockerSpinner.setVisibility(View.GONE);

    mTouchIndicator = (ImageView) findViewById(R.id.touchIndicator);
    mTouchInterceptor = (RelativeLayout) findViewById(R.id.touch_interceptor);
    mTouchInterceptor.setOnTouchListener(new View.OnTouchListener() {
        @Override/*from  w  ww.j  a  va 2  s  .com*/
        public boolean onTouch(View v, MotionEvent event) {
            mTouchIndicator.setImageResource(R.drawable.white_circle);
            mTouchIndicator.setVisibility(View.VISIBLE);
            final int X = (int) event.getRawX();
            final int Y = (int) event.getRawY();

            RelativeLayout.LayoutParams lParams = (RelativeLayout.LayoutParams) mTouchIndicator
                    .getLayoutParams();
            lParams.leftMargin = X - mTouchIndicator.getWidth() / 2;
            lParams.topMargin = Y - mTouchIndicator.getHeight() / 2;
            mTouchIndicator.setLayoutParams(lParams);
            mTouchIndicator.invalidate();

            ScaleAnimation scaleUpAnimation = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF,
                    (float) 0.5, Animation.RELATIVE_TO_SELF, (float) 0.5);

            scaleUpAnimation.setDuration(350);
            scaleUpAnimation.setAnimationListener(new Animation.AnimationListener() {
                @Override
                public void onAnimationStart(Animation animation) {

                }

                @Override
                public void onAnimationEnd(Animation animation) {
                    mTouchIndicator.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            mTouchIndicator.setVisibility(View.GONE);
                        }
                    }, 100);

                }

                @Override
                public void onAnimationRepeat(Animation animation) {

                }
            });
            mTouchIndicator.startAnimation(scaleUpAnimation);
            return false;
        }
    });

    //            mTouchInterceptor.setVisibility(View.GONE);

    mRecordButton = (Button) findViewById(R.id.recordButton);

    mExtrasContainer = (LinearLayout) findViewById(R.id.settings_container);
    mMoreOptions = (ImageView) findViewById(R.id.icon_more);
    mMoreOptions.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mMoreOptions.setSelected(!mMoreOptions.isSelected());
            if (mMoreOptions.isSelected()) {
                mExtrasContainer.setVisibility(View.VISIBLE);
            } else {
                mExtrasContainer.setVisibility(View.GONE);
            }

        }
    });

    //            mRecordButton .setOnClickListener(mRecordButtonClickListener);
    setUpTouchInterceptor(mRecordButton);

    setUpHeaders();
    setUpFlashButton();
    setUpProgressIndicator();

    //        setupFilterSpinner();
    setupCameraFlipper();
}

From source file:com.appolica.interactiveinfowindow.InfoWindowManager.java

private void animateWindowOpen(@NonNull final InfoWindow infoWindow, @NonNull final View container) {

    final SimpleAnimationListener animationListener = new SimpleAnimationListener() {

        @Override//from   ww w . ja  v a2  s. c  o  m
        public void onAnimationStart(Animation animation) {

            container.setVisibility(View.VISIBLE);
            propagateShowEvent(infoWindow, InfoWindow.State.SHOWING);

        }

        @Override
        public void onAnimationEnd(Animation animation) {

            propagateShowEvent(infoWindow, InfoWindow.State.SHOWN);
            setCurrentWindow(infoWindow);

        }
    };

    if (showAnimation == null) {

        container.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {

            @Override
            public boolean onPreDraw() {
                final int containerWidth = container.getWidth();
                final int containerHeight = container.getHeight();

                final float pivotX = container.getX() + containerWidth / 2;
                final float pivotY = container.getY() + containerHeight;

                final ScaleAnimation scaleAnimation = new ScaleAnimation(0f, 1f, 0f, 1f, pivotX, pivotY);

                scaleAnimation.setDuration(DURATION_WINDOW_ANIMATION);
                scaleAnimation.setInterpolator(new DecelerateInterpolator());
                scaleAnimation.setAnimationListener(animationListener);

                container.startAnimation(scaleAnimation);

                container.getViewTreeObserver().removeOnPreDrawListener(this);
                return true;
            }
        });
    } else {
        showAnimation.setAnimationListener(animationListener);
        container.startAnimation(showAnimation);
    }
}

From source file:com.aniruddhc.acemusic.player.Drawers.QueueDrawerFragment.java

/**
 * Animates the pause button to a play button.
 *///from   w  w  w .  j a  v a2  s .c o  m
private void animatePauseToPlay() {

    //Check to make sure the current icon is the pause icon.
    if (mPlayPauseButton.getId() != R.drawable.pause_light)
        return;

    //Scale out the pause button.
    final ScaleAnimation scaleOut = new ScaleAnimation(1.0f, 0.0f, 1.0f, 0.0f, mPlayPauseButton.getWidth() / 2,
            mPlayPauseButton.getHeight() / 2);
    scaleOut.setDuration(150);
    scaleOut.setInterpolator(new AccelerateInterpolator());

    //Scale in the play button.
    final ScaleAnimation scaleIn = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, mPlayPauseButton.getWidth() / 2,
            mPlayPauseButton.getHeight() / 2);
    scaleIn.setDuration(150);
    scaleIn.setInterpolator(new DecelerateInterpolator());

    scaleOut.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mPlayPauseButton.setImageResource(R.drawable.play_light);
            mPlayPauseButton.setPadding(0, 0, -5, 0);
            mPlayPauseButton.startAnimation(scaleIn);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }

    });

    scaleIn.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mPlayPauseButton.setScaleX(1.0f);
            mPlayPauseButton.setScaleY(1.0f);
            mPlayPauseButton.setId(R.drawable.play_light);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }

    });

    mPlayPauseButton.startAnimation(scaleOut);
}