Example usage for android.animation AnimatorSet AnimatorSet

List of usage examples for android.animation AnimatorSet AnimatorSet

Introduction

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

Prototype

public AnimatorSet() 

Source Link

Usage

From source file:io.plaidapp.core.ui.transitions.ReflowText.java

@Override
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {

    if (startValues == null || endValues == null)
        return null;

    final View view = endValues.view;
    AnimatorSet transition = new AnimatorSet();
    ReflowData startData = (ReflowData) startValues.values.get(PROPNAME_DATA);
    ReflowData endData = (ReflowData) endValues.values.get(PROPNAME_DATA);
    duration = calculateDuration(startData.bounds, endData.bounds);

    // create layouts & capture a bitmaps of the text in both states
    // (with max lines variants where needed)
    Layout startLayout = createLayout(startData, sceneRoot.getContext(), false);
    Layout endLayout = createLayout(endData, sceneRoot.getContext(), false);
    Layout startLayoutMaxLines = null;/*  w  w  w.  ja  va2s  .c  o m*/
    Layout endLayoutMaxLines = null;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // StaticLayout maxLines support
        if (startData.maxLines != -1) {
            startLayoutMaxLines = createLayout(startData, sceneRoot.getContext(), true);
        }
        if (endData.maxLines != -1) {
            endLayoutMaxLines = createLayout(endData, sceneRoot.getContext(), true);
        }
    }
    final Bitmap startText = createBitmap(startData,
            startLayoutMaxLines != null ? startLayoutMaxLines : startLayout);
    final Bitmap endText = createBitmap(endData, endLayoutMaxLines != null ? endLayoutMaxLines : endLayout);

    // temporarily turn off clipping so we can draw outside of our bounds don't draw
    view.setWillNotDraw(true);
    ((ViewGroup) view.getParent()).setClipChildren(false);

    // calculate the runs of text to move together
    List<Run> runs = getRuns(startData, startLayout, startLayoutMaxLines, endData, endLayout,
            endLayoutMaxLines);

    // create animators for moving, scaling and fading each run of text
    transition.playTogether(createRunAnimators(view, startData, endData, startText, endText, runs));

    if (!freezeFrame) {
        transition.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                // clean up
                view.setWillNotDraw(false);
                view.getOverlay().clear();
                ((ViewGroup) view.getParent()).setClipChildren(true);
                startText.recycle();
                endText.recycle();
            }
        });
    }
    return transition;
}

From source file:com.myhexaville.iconanimations.gooey_fab.GooeyFab.java

void onElevationsChanged(final float elevation, final float pressedTranslationZ) {
    final StateListAnimator stateListAnimator = new StateListAnimator();

    // Animate elevation and translationZ to our values when pressed
    AnimatorSet set = new AnimatorSet();
    set.play(ObjectAnimator.ofFloat(this, "elevation", elevation).setDuration(0)).with(ObjectAnimator
            .ofFloat(this, View.TRANSLATION_Z, pressedTranslationZ).setDuration(PRESSED_ANIM_DURATION));
    set.setInterpolator(ANIM_INTERPOLATOR);
    stateListAnimator.addState(PRESSED_ENABLED_STATE_SET, set);

    // Same deal for when we're focused
    set = new AnimatorSet();
    set.play(ObjectAnimator.ofFloat(this, "elevation", elevation).setDuration(0)).with(ObjectAnimator
            .ofFloat(this, View.TRANSLATION_Z, pressedTranslationZ).setDuration(PRESSED_ANIM_DURATION));
    set.setInterpolator(ANIM_INTERPOLATOR);
    stateListAnimator.addState(FOCUSED_ENABLED_STATE_SET, set);

    // Animate translationZ to 0 if not pressed
    set = new AnimatorSet();
    // Use an AnimatorSet to set a start delay since there is a bug with ValueAnimator that
    // prevents it from being cancelled properly when used with a StateListAnimator.
    AnimatorSet anim = new AnimatorSet();
    anim.play(ObjectAnimator.ofFloat(this, View.TRANSLATION_Z, 0f).setDuration(PRESSED_ANIM_DURATION))
            .after(PRESSED_ANIM_DURATION);
    set.play(ObjectAnimator.ofFloat(this, "elevation", elevation).setDuration(0)).with(anim);
    set.setInterpolator(ANIM_INTERPOLATOR);
    stateListAnimator.addState(ENABLED_STATE_SET, set);

    // Animate everything to 0 when disabled
    set = new AnimatorSet();
    set.play(ObjectAnimator.ofFloat(this, "elevation", 0f).setDuration(0))
            .with(ObjectAnimator.ofFloat(this, View.TRANSLATION_Z, 0f).setDuration(0));
    set.setInterpolator(ANIM_INTERPOLATOR);
    stateListAnimator.addState(EMPTY_STATE_SET, set);

    setStateListAnimator(stateListAnimator);
}

From source file:org.chromium.chrome.browser.widget.animation.FocusAnimator.java

private void startAnimator(final Runnable callback) {
    // Don't animate anything if the number of children changed.
    if (mInitialNumberOfChildren != mLayout.getChildCount()) {
        finishAnimation(callback);// w w w .j a va 2 s.c om
        return;
    }

    // Don't animate if children are already all in the correct places.
    boolean isAnimationNecessary = false;
    ArrayList<Integer> finalChildTops = calculateChildTops();
    for (int i = 0; i < finalChildTops.size() && !isAnimationNecessary; i++) {
        isAnimationNecessary |= finalChildTops.get(i).compareTo(mInitialTops.get(i)) != 0;
    }
    if (!isAnimationNecessary) {
        finishAnimation(callback);
        return;
    }

    // Animate each child moving and changing size to match their final locations.
    ArrayList<Animator> animators = new ArrayList<Animator>();
    ValueAnimator childAnimator = ValueAnimator.ofFloat(0f, 1f);
    animators.add(childAnimator);
    for (int i = 0; i < mLayout.getChildCount(); i++) {
        // The child is already where it should be.
        if (mInitialTops.get(i).compareTo(finalChildTops.get(i)) == 0
                && mInitialTops.get(i + 1).compareTo(finalChildTops.get(i + 1)) == 0) {
            continue;
        }

        final View child = mLayout.getChildAt(i);
        final int translationDifference = mInitialTops.get(i) - finalChildTops.get(i);
        final int oldHeight = mInitialTops.get(i + 1) - mInitialTops.get(i);
        final int newHeight = finalChildTops.get(i + 1) - finalChildTops.get(i);

        // Translate the child to its new place while changing where its bottom is drawn to
        // animate the child changing height without causing another layout.
        childAnimator.addUpdateListener(new AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float progress = (Float) animation.getAnimatedValue();
                child.setTranslationY(translationDifference * (1f - progress));

                if (oldHeight != newHeight) {
                    float animatedHeight = oldHeight * (1f - progress) + newHeight * progress;
                    child.setBottom(child.getTop() + (int) animatedHeight);
                }
            }
        });

        // Explicitly place the child in its final position in the end.
        childAnimator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animator) {
                child.setTranslationY(0);
                child.setBottom(child.getTop() + newHeight);
            }
        });
    }

    // Animate the height of the container itself changing.
    int oldContainerHeight = mInitialTops.get(mInitialTops.size() - 1);
    int newContainerHeight = finalChildTops.get(finalChildTops.size() - 1);
    ValueAnimator layoutAnimator = ValueAnimator.ofInt(oldContainerHeight, newContainerHeight);
    layoutAnimator.addUpdateListener(new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mLayout.setBottom(((Integer) animation.getAnimatedValue()));
            requestChildFocus();
        }
    });
    animators.add(layoutAnimator);

    // Set up and kick off the animation.
    AnimatorSet animator = new AnimatorSet();
    animator.setDuration(ANIMATION_LENGTH_MS);
    animator.setInterpolator(new LinearOutSlowInInterpolator());
    animator.playTogether(animators);
    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animator) {
            finishAnimation(callback);

            // Request a layout to put everything in the right final place.
            mLayout.requestLayout();
        }
    });
    animator.start();
}

From source file:com.devilyang.musicstation.swinginadapters.AnimationAdapter.java

private void animateView(int position, ViewGroup parent, View view) {
    if (mAnimationStartMillis == -1) {
        mAnimationStartMillis = System.currentTimeMillis();
    }//from  ww  w . ja v a  2 s. c  om

    //      ViewDragHelper.setAlpha(view, 0);
    view.setAlpha(0);

    Animator[] childAnimators;
    if (mDecoratedBaseAdapter instanceof AnimationAdapter) {
        childAnimators = ((AnimationAdapter) mDecoratedBaseAdapter).getAnimators(parent, view);
    } else {
        childAnimators = new Animator[0];
    }
    Animator[] animators = getAnimators(parent, view);
    Animator alphaAnimator = ObjectAnimator.ofFloat(view, "alpha", 0, 1);

    AnimatorSet set = new AnimatorSet();
    set.playTogether(concatAnimators(childAnimators, animators, alphaAnimator));
    set.setStartDelay(calculateAnimationDelay());
    set.setDuration(getAnimationDurationMillis());
    set.start();

    mAnimators.put(view.hashCode(), set);
}

From source file:com.sysdata.widget.accordion.ExpandedViewHolder.java

private Animator createCollapsingAnimator(ArrowItemViewHolder newHolder, long duration) {
    if (arrow != null) {
        arrow.setVisibility(View.INVISIBLE);
    }// ww  w  .jav a  2 s. co  m

    final View oldView = itemView;
    final View newView = newHolder.itemView;

    final Animator backgroundAnimator = ObjectAnimator.ofPropertyValuesHolder(oldView,
            PropertyValuesHolder.ofInt(AnimatorUtils.BACKGROUND_ALPHA, 255, 0));
    backgroundAnimator.setDuration(duration);

    final Animator boundsAnimator = AnimatorUtils.getBoundsAnimator(oldView, oldView, newView);
    boundsAnimator.setDuration(duration);
    boundsAnimator.setInterpolator(AnimatorUtils.INTERPOLATOR_FAST_OUT_SLOW_IN);

    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(backgroundAnimator, boundsAnimator);
    return animatorSet;
}

From source file:org.amahi.anywhere.tv.fragment.IntroFragment.java

@Override
protected void onPageChanged(final int newPage, int previousPage) {
    if (mContentAnimator != null) {
        mContentAnimator.end();/*w ww .  j a v a 2 s  .  c  o  m*/
    }

    ArrayList<Animator> animators = new ArrayList<>();

    Animator fadeOut = createFadeOutAnimator(mContentView);

    fadeOut.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            Log.d(getClass().getName(), String.valueOf(newPage));
            mContentView.setImageResource(CONTENT_IMAGES[newPage]);
            switch (newPage) {
            case 0:
                mBackgroundView.setBackground(new ColorDrawable(mColors.get(newPage)));
                break;
            case 1:
                mBackgroundView.setBackground(new ColorDrawable(mColors.get(newPage)));
                break;
            case 2:
                mBackgroundView.setBackground(new ColorDrawable(mColors.get(newPage)));
                break;
            case 3:
                mBackgroundView.setBackground(new ColorDrawable(mColors.get(newPage)));
                break;
            case 4:
                mBackgroundView.setBackground(new ColorDrawable(mColors.get(newPage)));
                break;
            case 5:
                mBackgroundView.setBackground(new ColorDrawable(mColors.get(newPage)));
                break;
            }
        }
    });

    animators.add(fadeOut);

    animators.add(createFadeInAnimator(mContentView));

    AnimatorSet set = new AnimatorSet();

    set.playSequentially(animators);

    set.start();

    mContentAnimator = set;
}

From source file:com.ofalvai.bpinfo.ui.alert.AlertDetailFragment.java

public void updateAlert(final Alert alert) {
    mAlert = alert;//from w  w  w .ja v a 2s . co  m
    mDisplayedRoutes.clear();
    mRouteIconsLayout.removeAllViews();

    // Updating views
    displayAlert(alert);

    // View animations
    // For some reason, ObjectAnimator doesn't work here (skips animation states, just shows the
    // last frame), we need to use ValueAnimators.
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.setDuration(300);
    animatorSet.setInterpolator(new FastOutSlowInInterpolator());

    // We can't measure the TextView's height before a layout happens because of the setText() call
    // Note: even though displayAlert() was called earlier, the TextView's height is still 0.
    int heightEstimate = mDescriptionTextView.getLineHeight() * mDescriptionTextView.getLineCount() + 10;

    ValueAnimator descriptionHeight = ValueAnimator.ofInt(mDescriptionTextView.getHeight(), heightEstimate);
    descriptionHeight.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mDescriptionTextView.getLayoutParams().height = (int) animation.getAnimatedValue();
            mDescriptionTextView.requestLayout();
        }
    });
    descriptionHeight.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mDescriptionTextView.setAlpha(1.0f);
            mDescriptionTextView.setVisibility(View.VISIBLE);
        }
    });

    ValueAnimator descriptionAlpha = ValueAnimator.ofFloat(0, 1.0f);
    descriptionAlpha.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mDescriptionTextView.setAlpha((float) animation.getAnimatedValue());
        }
    });

    ValueAnimator progressHeight = ValueAnimator.ofInt(mProgressBar.getHeight(), 0);
    progressHeight.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mProgressBar.getLayoutParams().height = (int) animation.getAnimatedValue();
            mProgressBar.requestLayout();
        }
    });
    progressHeight.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mProgressBar.hide();
        }
    });

    animatorSet.playTogether(progressHeight, descriptionHeight, descriptionAlpha);
    animatorSet.start();
}

From source file:com.example.android.tryanimationt.TryAnimationFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mCardView = (CardView) view.findViewById(R.id.cardview);

    fab1st = (android.widget.ImageButton) view.findViewById(R.id.fabBt);
    fab2nd = (android.widget.ImageButton) view.findViewById(R.id.fabBt2);
    fab3rd = (android.widget.ImageButton) view.findViewById(R.id.fab3);

    footer = view.findViewById(R.id.footer);

    animButtons(fab1st, true, 2500, 0);/*from   w  ww  .  jav a  2  s. com*/
    animButtons(fab2nd, true, 1000, 150);
    animButtons(fab3rd, true, 2000, 250);

    fab1st.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AnimatorSet animSet = new AnimatorSet();
            ObjectAnimator anim2 = ObjectAnimator.ofFloat(fab1st, "rotationX", 0, 359);
            anim2.setDuration(1500);

            ObjectAnimator anim3 = ObjectAnimator.ofFloat(fab1st, "rotationY", 0, 359);
            anim3.setDuration(1500);

            ObjectAnimator animTrx = ObjectAnimator.ofFloat(fab1st, "translationX", 0, -20);
            animTrx.setDuration(2500);
            ObjectAnimator animTry = ObjectAnimator.ofFloat(fab1st, "translationY", 0, -20);
            animTry.setDuration(2500);

            animSet.setInterpolator(new BounceInterpolator());
            animSet.playTogether(anim2, anim3, animTry, animTrx);

            animSet.start();

        }
    });

    fab1st.setOutlineProvider(new ViewOutlineProvider() {
        @Override
        public void getOutline(View view, Outline outline) {
            int size = getResources().getDimensionPixelSize(R.dimen.fab_size);
            outline.setOval(0, 0, size, size);
            outline.setRoundRect(0, 0, size, size, size / 2);
        }
    });

    fab1st.setClipToOutline(true);

    final View vImage = view.findViewById(R.id.image);
    final View vCard = view.findViewById(R.id.cardview);
    final View vCardTextPart = view.findViewById(R.id.cardview_textpart2);
    final View vCardContentContainer = view.findViewById(R.id.cardContentContainer);

    vCard.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(),

                    // Now we provide a list of Pair items which contain the view we can transitioning
                    // from, and the name of the view it is transitioning to, in the launched activity

                    android.support.v4.util.Pair.create(vImage, "photo_hero"),
                    android.support.v4.util.Pair.create(vCardTextPart, "sharedSceneTrasintionText"));

            Intent intent = new Intent(getActivity(), sceneTransitionActivity.class);
            intent.putExtra("photo_hero", R.drawable.image1);
            ActivityCompat.startActivity(getActivity(), intent, options.toBundle());
        }
    });

    fab2nd.setOutlineProvider(new ViewOutlineProvider() {
        @Override
        public void getOutline(View view, Outline outline) {
            int size = getResources().getDimensionPixelSize(R.dimen.fab_size);
            outline.setOval(0, 0, size, size);
            outline.setRoundRect(0, 0, size, size, size / 2);
        }
    });

    fab2nd.setClipToOutline(true);

    final AnimationDrawable[] animDrawables = new AnimationDrawable[2];
    animDrawables[0] = (AnimationDrawable) getResources().getDrawable(R.drawable.anim_off_to_on);
    animDrawables[1] = (AnimationDrawable) getResources().getDrawable(R.drawable.anim_on_to_off);
    animDrawables[0].setOneShot(true);
    animDrawables[1].setOneShot(true);

    fab2nd.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            final int fab2InconIndex = mAnimationStateIndex;
            mAnimationStateIndex = (mAnimationStateIndex + 1) % 2;

            /*****************************************************/
            // animate the card

            //final Animation myRotation = AnimationUtils.loadAnimation(getActivity(), R.anim.rotate_anim);
            //mCardView.startAnimation(myRotation);

            int start;
            int end;
            if (mAnimationStateIndex == 0) {
                start = Color.rgb(0x71, 0xc3, 0xde);
                end = Color.rgb(0x68, 0xe8, 0xee);
            } else {
                start = Color.rgb(0x68, 0xe8, 0xee);
                end = Color.rgb(0x71, 0xc3, 0xde);
            }

            AnimatorSet animSet = new AnimatorSet();

            ValueAnimator valueAnimator = ObjectAnimator.ofInt(vCardContentContainer, "backgroundColor", start,
                    end);
            valueAnimator.setInterpolator(new BounceInterpolator());
            valueAnimator.setDuration(2000);
            valueAnimator.setEvaluator(new ArgbEvaluator());

            valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator animation) {
                    int animProgress = (Integer) animation.getAnimatedValue();

                }
            });
            valueAnimator.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    mCardView.setRadius(8);
                    //mCardView.setElevation(0);
                }
            });

            float rotateStart, rotateEnd;
            float scaleXStart, scaleXEnd;
            float rotateXStart, rotateXEnd;
            float rotateYStart, rotateYEnd;
            float transitionXStart, transitionXEnd;
            float transitionYStart, transitionYEnd;

            if (mAnimationStateIndex == 0) {
                rotateStart = 0f;
                rotateEnd = 80f;
                scaleXStart = 1f;
                scaleXEnd = 0.66f;
                rotateXStart = 0f;
                rotateXEnd = 30f;
                rotateYStart = 0f;
                rotateYEnd = 30f;
                transitionYStart = 0f;
                transitionYEnd = -100f;
                transitionXStart = 0f;
                transitionXEnd = 100f;
            } else {
                rotateStart = 80f;
                rotateEnd = 0f;
                scaleXStart = 0.66f;
                scaleXEnd = 1;
                rotateXStart = 30;
                rotateXEnd = 0f;
                rotateYStart = 30f;
                rotateYEnd = 0f;
                transitionYStart = -100f;
                transitionYEnd = 0f;
                transitionXStart = 100f;
                transitionXEnd = 0f;
            }

            ObjectAnimator anim = ObjectAnimator.ofFloat(mCardView, "rotation", rotateStart, rotateEnd);
            anim.setDuration(2000);

            ObjectAnimator anim1 = ObjectAnimator.ofFloat(mCardView, "scaleX", scaleXStart, scaleXEnd);
            anim1.setDuration(2000);

            ObjectAnimator anim2 = ObjectAnimator.ofFloat(mCardView, "rotationX", rotateXStart, rotateXEnd);
            anim2.setDuration(2000);

            ObjectAnimator anim3 = ObjectAnimator.ofFloat(mCardView, "rotationY", rotateYStart, rotateYEnd);
            anim3.setDuration(2000);

            ObjectAnimator animTry = ObjectAnimator.ofFloat(mCardView, "translationY", transitionYStart,
                    transitionYEnd);
            animTry.setDuration(2000);
            ObjectAnimator animTrx = ObjectAnimator.ofFloat(mCardView, "translationX", transitionXStart,
                    transitionXEnd);
            animTrx.setDuration(2000);
            animSet.setInterpolator(new BounceInterpolator());
            animSet.playTogether(valueAnimator, anim, anim2, anim3, anim1, animTry, animTrx);

            float controlX1, controlY1, controlX2, controlY2;
            if (mAnimationStateIndex == 0) {
                controlX1 = 0f;
                controlY1 = 0.25f;
                controlX2 = 1;
                controlY2 = 1;
            } else {
                controlX1 = 1;
                controlY1 = 1;
                controlX2 = 0.25f;
                controlY2 = 1;
            }

            PathInterpolator pathInterpolator = new PathInterpolator(controlX1, controlY1, controlX2,
                    controlY2);
            animTrx.setInterpolator(pathInterpolator);

            animSet.start();

            /*****************************************************/
            // animate rotate white button

            RotateAnimation r = new RotateAnimation(0, 359, Animation.RELATIVE_TO_SELF, 0.5f,
                    Animation.RELATIVE_TO_SELF, 0.5f);
            r.setDuration(2000);
            r.setFillAfter(true);

            r.setInterpolator(new BounceInterpolator());

            fab2nd.startAnimation(r);

            // change 2nd button image
            fab2nd.setImageDrawable(animDrawables[fab2InconIndex]);
            animDrawables[fab2InconIndex].start();

            /*****************************************************/
            // animate changing 3rd button image
            fab3rd.setImageDrawable(animDrawables[mAnimationStateIndex]);
            animDrawables[mAnimationStateIndex].start();

            /*****************************************************/
            // using AnimatedStateListDrawable to animate the 1st button image by its state
            {
                Drawable drawable = getActivity().getResources().getDrawable(R.drawable.icon_anim);
                fab1st.setImageDrawable(drawable);

                final int[] STATE_CHECKED = new int[] { android.R.attr.state_checked };
                final int[] STATE_UNCHECKED = new int[] {};

                // set state
                fab1st.setImageState((mAnimationStateIndex != 0) ? STATE_UNCHECKED : STATE_CHECKED, false);
                drawable.jumpToCurrentState();
                // change to state
                fab1st.setImageState((mAnimationStateIndex != 0) ? STATE_CHECKED : STATE_UNCHECKED, false);
            }

        }
    });

    fab3rd.setOutlineProvider(new ViewOutlineProvider() {
        @Override
        public void getOutline(View view, Outline outline) {
            int size = getResources().getDimensionPixelSize(R.dimen.fab_size);
            outline.setOval(0, 0, size, size);
            outline.setRoundRect(0, 0, size, size, size / 2);
        }
    });

    fab3rd.setClipToOutline(true);
    final CheckBox circleFadeout = (CheckBox) view.findViewById(R.id.circleFadeout);

    circleFadeout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (((CheckBox) v).isChecked()) {
            }
        }
    });

    final ImageButton vLogoBt = fab3rd;
    vLogoBt.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            animButtons(fab1st, false, 2000, 0);
            animButtons(fab2nd, false, 600, 150);
            animButtons(fab3rd, false, 1500, 250);

            Handler delayHandler = new Handler();
            delayHandler.postDelayed(new Runnable() {

                @Override
                public void run() {

                    Intent logoIntent = new Intent(getActivity(), LogoActivity.class);

                    logoIntent.putExtra(LogoActivity.LOGO_VIEW_IMAGE_FADEOUT,
                            (circleFadeout.isChecked() ? 1 : 0));
                    logoIntent.putExtra(LogoActivity.LOGO_VIEW_TRANSTION_TYPE, logoActivityTransitionType);

                    startActivityForResult(logoIntent, mRequestCode,
                            ActivityOptions.makeSceneTransitionAnimation(getActivity()).toBundle());

                }
            }, 1000);

            // footer slide down
            slideView(footer, false);
        }
    });

    mRadioGrp = (RadioGroup) view.findViewById(R.id.radioGroup);
    mRadioGrp.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {

            int selectedId = mRadioGrp.getCheckedRadioButtonId();

            String transitionType = "using";
            switch (selectedId) {
            case R.id.radioFade:
                logoActivityTransitionType = 0;
                transitionType = transitionType + " Fade";
                break;
            case R.id.radioExplode:
                logoActivityTransitionType = 1;
                transitionType = transitionType + " Explode";
                break;
            default:
                logoActivityTransitionType = 2;
                transitionType = transitionType + " Slide";
            }
            mSwitcher.setText(transitionType + " transition");
        }
    });

    mSwitcher = (TextSwitcher) view.findViewById(R.id.textSwitcher);
    mSwitcher.setFactory(mFactory);

    Animation in = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_in_top);
    Animation out = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_out_top);
    mSwitcher.setInAnimation(in);
    mSwitcher.setOutAnimation(out);
    mSwitcher.setCurrentText("using Fade transition");

    // footer slide up
    slideView(footer, true);
}

From source file:com.tmall.wireless.tangram.ext.SwipeItemTouchListener.java

private void resetViews(RecyclerView recyclerView, final int swipingType, final boolean reachActionEdge,
        final int direction) {
    int contentWidth = recyclerView.getWidth();
    AnimatorSet animatorSet = new AnimatorSet();
    List<Animator> list = new ArrayList<>();
    String translation = "translationX";
    if (swipingType == SWIPING_VER) {
        translation = "translationY";
    }/*from   www .  j a v a2s  .  c om*/
    for (View view : mChildList) {
        ObjectAnimator animator;
        if (reachActionEdge) {
            animator = ObjectAnimator.ofFloat(view, translation, contentWidth * direction)
                    .setDuration(ANIMATE_DURATION);
            animator.setInterpolator(new AccelerateInterpolator());
        } else {
            animator = ObjectAnimator.ofFloat(view, translation, 0).setDuration(ANIMATE_DURATION);
            animator.setInterpolator(new DecelerateInterpolator());
        }
        list.add(animator);
    }
    animatorSet.playTogether(list);
    animatorSet.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {

        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (swipingType == SWIPING_HOR && reachActionEdge) {
                if (mSwipeCardRef != null && mSwipeCardRef.get() != null) {
                    SwipeCard swipeCard = mSwipeCardRef.get();
                    swipeCard.switchTo(swipeCard.getCurrentIndex() - direction);
                }
            }
            mChildList.clear();
        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    });
    animatorSet.start();

    if (swipingType == SWIPING_VER) {
        if (pullFromEndListener != null) {
            if (mDistanceY < 0 && (mDistanceY < -pullFromEndListener.getPullEdge())) {
                pullFromEndListener.onAction();
            } else {
                pullFromEndListener.onReset();
            }
        }
    }

    swipeType = SWIPING_NONE;
}

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

private void animateInFrameDetails() {
    frameDetails.setVisibility(View.VISIBLE);
    ViewUtils.onLaidOut(frameDetails, new Runnable() {
        @Override//from  ww  w  . j a  v  a2s . c o m
        public void run() {
            ObjectAnimator alpha = ofFloat(frameDetails, View.ALPHA, 0.4f, 1f);
            ObjectAnimator translate = ofFloat(frameDetails, View.TRANSLATION_Y,
                    frameDetails.getHeight() * 0.3f, 0f);

            AnimatorSet set = new AnimatorSet();
            set.playTogether(alpha, translate);
            set.setDuration(ANIM_DURATION);
            set.setInterpolator(new LinearOutSlowInInterpolator());
            set.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    frameMaster.setVisibility(View.GONE);
                }
            });
            set.start();
        }
    });
}