Example usage for android.animation AnimatorSet start

List of usage examples for android.animation AnimatorSet start

Introduction

In this page you can find the example usage for android.animation AnimatorSet start.

Prototype

@SuppressWarnings("unchecked")
@Override
public void start() 

Source Link

Document

Starting this AnimatorSet will, in turn, start the animations for which it is responsible.

Usage

From source file:arun.com.chromer.webheads.WebHeadService.java

private void updateWebHeadColors(@ColorInt int webHeadColor) {
    final AnimatorSet animatorSet = new AnimatorSet();
    final List<Animator> animators = new LinkedList<>();
    for (WebHead webhead : webHeads.values()) {
        animators.add(webhead.getRevealAnimator(webHeadColor));
    }/*from w  w w .  j a  va2  s.com*/
    animatorSet.playTogether(animators);
    animatorSet.start();
}

From source file:com.androidinspain.deskclock.timer.TimerFragment.java

/**
 * @param timerToRemove the timer to be removed during the animation
 *//*  www  .j  av a2 s .  c  o  m*/
private void animateTimerRemove(final Timer timerToRemove) {
    final long duration = UiDataModel.getUiDataModel().getShortAnimationDuration();

    final Animator fadeOut = ObjectAnimator.ofFloat(mViewPager, ALPHA, 1, 0);
    fadeOut.setDuration(duration);
    fadeOut.setInterpolator(new DecelerateInterpolator());
    fadeOut.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            DataModel.getDataModel().removeTimer(timerToRemove);
            Events.sendTimerEvent(com.androidinspain.deskclock.R.string.action_delete,
                    com.androidinspain.deskclock.R.string.label_deskclock);
        }
    });

    final Animator fadeIn = ObjectAnimator.ofFloat(mViewPager, ALPHA, 0, 1);
    fadeIn.setDuration(duration);
    fadeIn.setInterpolator(new AccelerateInterpolator());

    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(fadeOut).before(fadeIn);
    animatorSet.start();
}

From source file:me.hammarstrom.imagerecognition.activities.MainActivity.java

private void convertResponseToString(BatchAnnotateImagesResponse response) {
    Log.d(TAG, ":: " + response.getResponses().toString());
    List<FaceAnnotation> faces = response.getResponses().get(0).getFaceAnnotations();
    List<EntityAnnotation> labels = response.getResponses().get(0).getLabelAnnotations();

    // Label string to be populated with data for TextToSpeech
    String label = "";
    if (labels != null && labels.size() > 0) {
        label = "The image may contain ";
        List<Animator> scoreViewAnimations = new ArrayList<>();
        List<Animator> scoreAlphaAnimations = new ArrayList<>();
        List<Animator> showScoreAnimations = new ArrayList<>();

        for (EntityAnnotation l : labels) {
            if (l.getScore() < 0.6f) {
                continue;
            }/* ww w  . ja v  a 2  s . c om*/

            // Add label description (ex. laptop, desk, person, etc.)
            label += l.getDescription() + ", ";

            /**
             * Create a new {@link ScoreView} and populate it with label description and score
             */
            ScoreView scoreView = new ScoreView(MainActivity.this);
            int padding = (int) DeviceDimensionsHelper.convertDpToPixel(8, this);
            scoreView.setPadding(padding, padding, padding, padding);
            scoreView.setScore(l.getScore());
            scoreView.setLabelPosition(ScoreView.LABEL_POSITION_RIGHT);
            scoreView.setLabelText(l.getDescription());
            scoreView.setAlpha(0f);
            scoreView.setTranslationX((DeviceDimensionsHelper.getDisplayWidth(this) / 2) * -1);

            // Add ScoreView to result layout
            mScoreResultLayout.addView(scoreView);

            // Create animations to used to show the ScoreView in a nice way
            ObjectAnimator animator = ObjectAnimator.ofFloat(scoreView, "translationX",
                    (DeviceDimensionsHelper.getDisplayWidth(this) / 2) * -1, 0f);
            animator.setInterpolator(new OvershootInterpolator());
            scoreViewAnimations.add(animator);

            ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(scoreView, "alpha", 0f, 1f);
            scoreAlphaAnimations.add(alphaAnimator);

            // Get the animation to show the actual score from ScoreView object
            showScoreAnimations.addAll(scoreView.getShowScoreAnimationsList());
        }

        // Set reset button visibility to visible
        mButtonReset.setVisibility(View.VISIBLE);

        // Setup and play the animations
        AnimatorSet translationSet = new AnimatorSet();
        translationSet.playSequentially(scoreViewAnimations);
        translationSet.setDuration(300);

        AnimatorSet alphaSet = new AnimatorSet();
        alphaSet.playSequentially(scoreAlphaAnimations);
        alphaSet.setDuration(300);

        AnimatorSet showScoreSet = new AnimatorSet();
        showScoreSet.playTogether(showScoreAnimations);

        showLoading(false);

        AnimatorSet set = new AnimatorSet();
        set.play(translationSet).with(alphaSet).before(showScoreSet);
        set.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                mButtonReset.animate().alpha(1f).start();
            }
        });
        set.start();
    } else {
        // Set reset button visibility to visible
        mButtonReset.setVisibility(View.VISIBLE);
        mButtonReset.setAlpha(1f);
    }

    // Handle detected faces
    String facesFound = "";
    if (faces != null && faces.size() > 0) {
        FaceGraphicOverlay faceGraphicOverlay = new FaceGraphicOverlay(MainActivity.this);
        faceGraphicOverlay.addFaces(faces);
        faceGraphicOverlay.setTag("faceOverlay");
        mCameraPreviewLayout.addView(faceGraphicOverlay);

        facesFound = FaceFoundHelper.getFacesFoundString(this, faces);
    }

    // Add the detected image data to TTS engine
    mTts.speak(label, TextToSpeech.QUEUE_FLUSH, null);
    mTts.speak(facesFound, TextToSpeech.QUEUE_ADD, null);
}

From source file:com.grepsound.activities.MainActivity.java

/**
 * This method animates the image fragment into the foreground by both
 * scaling and rotating the fragment's view, while also removing the
 * previously added translucent dark hover view. Upon the completion of
 * this animation, the image fragment regains focus since this method is
 * called from the onBackStackChanged method.
 *//*ww w  . j  a va2 s .  com*/
public void slideForward(Animator.AnimatorListener listener) {
    View movingFragmentView = mMainFrag.getView();

    PropertyValuesHolder rotateX = PropertyValuesHolder.ofFloat("rotationX", 40f);
    PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f);
    PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f);
    ObjectAnimator movingFragmentAnimator = ObjectAnimator.ofPropertyValuesHolder(movingFragmentView, rotateX,
            scaleX, scaleY);

    ObjectAnimator darkHoverViewAnimator = ObjectAnimator.ofFloat(mDarkHoverView, "alpha", 0.5f, 0.0f);

    ObjectAnimator movingFragmentRotator = ObjectAnimator.ofFloat(movingFragmentView, "rotationX", 0);
    movingFragmentRotator.setStartDelay(getResources().getInteger(R.integer.half_slide_up_down_duration));

    AnimatorSet s = new AnimatorSet();
    s.playTogether(movingFragmentAnimator, movingFragmentRotator, darkHoverViewAnimator);
    s.setStartDelay(getResources().getInteger(R.integer.slide_up_down_duration));
    s.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mIsAnimating = false;
        }
    });
    s.start();
}

From source file:com.luanthanhthai.android.liteworkouttimer.TimerFragment.java

/**
 * Property Animation//from   ww  w  .  ja v  a2 s . c  o  m
 * Animation for timer text slide to center
 */
public void animSlideClockToCenter() {
    timerClockView.animate().setDuration(animTimerDuration);

    if (getOrientation() == Configuration.ORIENTATION_PORTRAIT) {
        timerClockView.animate().y(yCenterValue);
    } else {
        ObjectAnimator scaleUpY = ObjectAnimator.ofFloat(timerClockView, "scaleY", 1.5f);
        ObjectAnimator scaleUpX = ObjectAnimator.ofFloat(timerClockView, "scaleX", 1.5f);
        scaleUpY.setDuration(animTimerDuration);
        scaleUpX.setDuration(animTimerDuration);
        AnimatorSet scaleUp = new AnimatorSet();
        scaleUp.play(scaleUpX).with(scaleUpY);

        timerClockView.animate().y(yCenterValue);
        scaleUp.start();
    }

}

From source file:com.artemchep.horario.ui.widgets.ContainersLayout.java

private void animateOutFrameDetails() {
    ViewUtils.onLaidOut(frameDetails, new Runnable() {
        @Override//from ww w. j  a  v a 2s  .com
        public void run() {
            if (!frameDetails.isShown()) {
                return;
            }
            ObjectAnimator alpha = ObjectAnimator.ofFloat(frameDetails, View.ALPHA, 1f, 0f);
            ObjectAnimator translate = ofFloat(frameDetails, View.TRANSLATION_Y, 0f,
                    frameDetails.getHeight() * 0.3f);

            AnimatorSet set = new AnimatorSet();
            set.playTogether(alpha, translate);
            set.setDuration(ANIM_DURATION);
            set.setInterpolator(new FastOutLinearInInterpolator());
            set.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    frameDetails.setAlpha(1f);
                    frameDetails.setTranslationY(0);
                    frameDetails.setVisibility(View.GONE);
                }
            });
            set.start();
        }
    });
}

From source file:kr.wdream.storyshop.AndroidUtilities.java

public static void shakeView(final View view, final float x, final int num) {
    if (num == 6) {
        view.setTranslationX(0);/*from   ww w  .j av a  2 s .  c o  m*/
        return;
    }
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(ObjectAnimator.ofFloat(view, "translationX", AndroidUtilities.dp(x)));
    animatorSet.setDuration(50);
    animatorSet.addListener(new AnimatorListenerAdapterProxy() {
        @Override
        public void onAnimationEnd(Animator animation) {
            shakeView(view, num == 5 ? 0 : -x, num + 1);
        }
    });
    animatorSet.start();
}

From source file:ch.gianulli.flashcards.ui.Flashcard.java

private void expandButtonBar() {
    mButtonBarShowing = true;/*  w  ww . ja  va 2s . c  o  m*/

    mButtonBar.setVisibility(View.VISIBLE);
    mButtonBar.setAlpha(0.0f);

    final int startingHeight = mCardView.getHeight();

    final ViewTreeObserver observer = mCardView.getViewTreeObserver();
    observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
        @Override
        public boolean onPreDraw() {
            // We don't want to continue getting called for every listview drawing.
            if (observer.isAlive()) {
                observer.removeOnPreDrawListener(this);
            }

            final int endingHeight = mCardView.getHeight();
            final int distance = endingHeight - startingHeight;

            mCardView.getLayoutParams().height = startingHeight;

            mCardView.requestLayout();

            ValueAnimator heightAnimator = ValueAnimator.ofFloat(0f, 1f).setDuration(300);

            heightAnimator.setInterpolator(new DecelerateInterpolator());
            heightAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator animator) {
                    Float value = (Float) animator.getAnimatedValue();
                    mCardView.getLayoutParams().height = (int) (value * distance + startingHeight);
                    mCardView.requestLayout();
                }
            });
            heightAnimator.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    mCardView.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT;
                }
            });

            mButtonBar.setLayerType(View.LAYER_TYPE_HARDWARE, null);
            ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(mButtonBar, "alpha", 0.0f, 1.0f);
            alphaAnimator.setInterpolator(new DecelerateInterpolator());
            alphaAnimator.setDuration(300);
            alphaAnimator.setStartDelay(100);

            AnimatorSet set = new AnimatorSet();
            set.playTogether(heightAnimator, alphaAnimator);
            set.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    mButtonBar.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
                }
            });

            set.start();

            return false;
        }
    });
}

From source file:com.luanthanhthai.android.liteworkouttimer.TimerFragment.java

/**
 * Property Animation//  ww w .j av  a2 s.c  o  m
 * Animation for timer clock slide up to original position
 */
public void animSlideClockUp() {
    timerClockView.animate().setDuration(animTimerDuration);

    if (getOrientation() == Configuration.ORIENTATION_PORTRAIT) {
        timerClockView.animate().y(yOriginalValue);
    } else {
        ObjectAnimator scaleDownY = ObjectAnimator.ofFloat(timerClockView, "scaleY", 1f);
        ObjectAnimator scaleDownX = ObjectAnimator.ofFloat(timerClockView, "scaleX", 1f);
        scaleDownY.setDuration(animTimerDuration);
        scaleDownX.setDuration(animTimerDuration);
        AnimatorSet scaleDown = new AnimatorSet();
        scaleDown.play(scaleDownX).with(scaleDownY);

        timerClockView.animate().y(yOriginalValue);
        scaleDown.start();
    }

}

From source file:com.hamzahrmalik.calculator2.Calculator.java

private void reveal(View sourceView, int colorRes, AnimatorListener listener) {
    final ViewGroupOverlay groupOverlay = (ViewGroupOverlay) getWindow().getDecorView().getOverlay();

    final Rect displayRect = new Rect();
    mDisplayView.getGlobalVisibleRect(displayRect);

    // Make reveal cover the display and status bar.
    final View revealView = new View(this);
    revealView.setBottom(displayRect.bottom);
    revealView.setLeft(displayRect.left);
    revealView.setRight(displayRect.right);
    revealView.setBackgroundColor(getResources().getColor(colorRes));
    groupOverlay.add(revealView);//from  w  w w.  j  a va  2  s . com

    final int[] clearLocation = new int[2];
    sourceView.getLocationInWindow(clearLocation);
    clearLocation[0] += sourceView.getWidth() / 2;
    clearLocation[1] += sourceView.getHeight() / 2;

    final int revealCenterX = clearLocation[0] - revealView.getLeft();
    final int revealCenterY = clearLocation[1] - revealView.getTop();

    final double x1_2 = Math.pow(revealView.getLeft() - revealCenterX, 2);
    final double x2_2 = Math.pow(revealView.getRight() - revealCenterX, 2);
    final double y_2 = Math.pow(revealView.getTop() - revealCenterY, 2);
    final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2));

    final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f);
    alphaAnimator.setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime));

    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
    animatorSet.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animator) {
            groupOverlay.remove(revealView);
            mCurrentAnimator = null;
        }
    });

    mResultEditText.setText("");
    mFormulaEditText.setText("");
    mCurrentAnimator = animatorSet;
    animatorSet.start();

}