Search in sources :

Example 91 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project Fairphone by Kwamecorp.

the class PeaceOfMindActivity method scrollEnded.

@Override
public synchronized void scrollEnded(float percentage) {
    if (mTotalTimeText.getVisibility() == View.VISIBLE) {
        Animation fadeOut = AnimationUtils.loadAnimation(this, R.anim.fade_out_fast);
        mTotalTimeText.startAnimation(fadeOut);
        fadeOut.setAnimationListener(new AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                mTotalTimeText.setVisibility(View.INVISIBLE);
                updateScreenTexts();
            }
        });
    }
    long targetTime = roundToInterval((long) (percentage * PeaceOfMindStats.MAX_TIME));
    Intent intent = new Intent(getApplicationContext(), PeaceOfMindBroadCastReceiver.class);
    intent.setAction(PeaceOfMindActivity.UPDATE_PEACE_OF_MIND);
    intent.putExtra(PeaceOfMindActivity.BROADCAST_TARGET_PEACE_OF_MIND, targetTime);
    FlurryAgent.logEvent(FlurryHelper.PEACE_OF_MIND_SET_TIME, FlurryHelper.getInstance().setFlurryParams("Target Time", "" + targetTime, true));
    sendBroadcast(intent);
}
Also used : Animation(android.view.animation.Animation) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) AnimationListener(android.view.animation.Animation.AnimationListener)

Example 92 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project Fairphone by Kwamecorp.

the class PeaceOfMindActivity method stopPeaceOfMindVideo.

private void stopPeaceOfMindVideo() {
    mVideo.removeCallbacks(null);
    if (mVideo.getVisibility() != View.VISIBLE) {
        mVideo.setVisibility(View.VISIBLE);
    }
    Animation fadeOut = AnimationUtils.loadAnimation(this, R.anim.fade_out_fast);
    mVideo.startAnimation(fadeOut);
    updateBackground(false);
    fadeOut.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mVideo.setVisibility(View.INVISIBLE);
            mVideo.stopPlayback();
        }
    });
}
Also used : Animation(android.view.animation.Animation) AnimationListener(android.view.animation.Animation.AnimationListener)

Example 93 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project Fairphone by Kwamecorp.

the class PeaceOfMindActivity method peaceOfMindEnded.

@Override
public synchronized void peaceOfMindEnded() {
    try {
        mSemaphore.tryAcquire(1, TimeUnit.SECONDS);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    Animation fadeIn = AnimationUtils.loadAnimation(this, R.anim.fade_in_fast);
    mSeekbarBackgroundOff.startAnimation(fadeIn);
    Animation fadeOut = AnimationUtils.loadAnimation(this, R.anim.fade_out_fast);
    mSeekbarBackgroundOn.startAnimation(fadeOut);
    fadeIn.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mSeekbarBackgroundOff.setVisibility(View.VISIBLE);
            mSeekbarBackgroundOn.setVisibility(View.GONE);
            updateScreenTexts();
            stopPeaceOfMindVideo();
            mSemaphore.release();
        }
    });
    updateScreenTexts();
    mVerticalSeekBar.setThumb(getResources().getDrawable(R.drawable.seekbar_thumb_off));
    mVerticalSeekBar.setThumbOffset(0);
    mVerticalSeekBar.setInvertedProgress(0);
    updateTextForNewTime(0, 0);
    updateTimeTextLabel(0);
    mTotalTimeText.setVisibility(View.INVISIBLE);
}
Also used : Animation(android.view.animation.Animation) AnimationListener(android.view.animation.Animation.AnimationListener)

Example 94 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project KeepScore by nolanlawson.

the class PlayerView method fadeOutBadge.

private void fadeOutBadge(final Runnable onAnimationComplete) {
    synchronized (lock) {
        if (// animation is already running, so shouldn't
        !animationRunning.get() && // start a new one
        lastIncremented.get() != // counter was reset, in which
        0 && // to fade
        badgeTextView.getVisibility() == View.VISIBLE) {
            // animation isn't already showing, and the badge is visible
            animationRunning.set(true);
            animationWasCanceled.set(false);
            badgeLinearLayout.setVisibility(View.VISIBLE);
            // show an animation for the badge with the textview and the
            // background linearlayout fading out
            Animation fadeOutAnimation = AnimationUtils.loadAnimation(context, android.R.anim.fade_out);
            fadeOutAnimation.setDuration(ANIMATION_TIME);
            fadeOutAnimation.setAnimationListener(new AnimationListener() {

                @Override
                public void onAnimationStart(Animation animation) {
                }

                @Override
                public void onAnimationRepeat(Animation animation) {
                }

                @Override
                public void onAnimationEnd(Animation animation) {
                    synchronized (lock) {
                        log.d("onAnimationEnd, setting visiblity to invisible");
                        if (!animationWasCanceled.get()) {
                            badgeTextView.setVisibility(View.INVISIBLE);
                        }
                        // necessary to update again to set the history text
                        // view correctly
                        onAnimationComplete.run();
                        animationRunning.set(false);
                    }
                }
            });
            badgeTextView.setAnimation(fadeOutAnimation);
            fadeOutAnimation.start();
            TransitionDrawable transitionDrawable = (TransitionDrawable) badgeLinearLayout.getBackground();
            transitionDrawable.setCrossFadeEnabled(true);
            transitionDrawable.startTransition(ANIMATION_TIME);
        } else {
            // just don't show it - the animation might already be showing,
            // or maybe the badge is
            // already invisible
            badgeLinearLayout.setVisibility(View.INVISIBLE);
            badgeTextView.setVisibility(View.INVISIBLE);
            // this ensures that the history text view gets updated
            // properly, even if the user
            // exits the activity while the animation is in progress (e.g.
            // by going to the Settings)
            onAnimationComplete.run();
        }
    }
}
Also used : TransitionDrawable(android.graphics.drawable.TransitionDrawable) Animation(android.view.animation.Animation) AnimationListener(android.view.animation.Animation.AnimationListener)

Example 95 with AnimationListener

use of android.view.animation.Animation.AnimationListener in project KeepScore by nolanlawson.

the class MainActivity method startShowButtonRowAnimation.

private void startShowButtonRowAnimation() {
    Animation animation = AnimationUtils.loadAnimation(this, R.anim.slide_bottom_to_top);
    animation.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            // propertly shrink the scroll view
            spacerView.setVisibility(View.VISIBLE);
        }
    });
    buttonRow.setAnimation(animation);
    buttonRow.setVisibility(View.VISIBLE);
    buttonRow.startAnimation(animation);
}
Also used : Animation(android.view.animation.Animation) AnimationListener(android.view.animation.Animation.AnimationListener)

Aggregations

Animation (android.view.animation.Animation)97 AnimationListener (android.view.animation.Animation.AnimationListener)97 AlphaAnimation (android.view.animation.AlphaAnimation)32 TranslateAnimation (android.view.animation.TranslateAnimation)27 View (android.view.View)15 LinearInterpolator (android.view.animation.LinearInterpolator)12 ScaleAnimation (android.view.animation.ScaleAnimation)11 RotateAnimation (android.view.animation.RotateAnimation)10 ImageView (android.widget.ImageView)10 Rect (android.graphics.Rect)7 ViewGroup (android.view.ViewGroup)6 PopupWindow (android.widget.PopupWindow)6 Window (wei.mark.standout.ui.Window)6 SuppressLint (android.annotation.SuppressLint)5 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)5 AnimationSet (android.view.animation.AnimationSet)4 Interpolator (android.view.animation.Interpolator)4 OvershootInterpolator (android.view.animation.OvershootInterpolator)4 Transformation (android.view.animation.Transformation)4 InputMethodManager (android.view.inputmethod.InputMethodManager)4