Search in sources :

Example 1 with TransitionSet

use of com.transitionseverywhere.TransitionSet in project Transitions-Everywhere by andkulikov.

the class ExplodeAndEpicenterExample method letsExplodeIt.

private void letsExplodeIt(View clickedView) {
    // save rect of view in screen coordinated
    final Rect viewRect = new Rect();
    clickedView.getGlobalVisibleRect(viewRect);
    TransitionSet set = new TransitionSet().addTransition(new Explode().setEpicenterCallback(new Transition.EpicenterCallback() {

        @Override
        public Rect onGetEpicenter(Transition transition) {
            return viewRect;
        }
    }).excludeTarget(clickedView, true)).addTransition(new Fade().addTarget(clickedView)).addListener(new Transition.TransitionListenerAdapter() {

        @Override
        public void onTransitionEnd(Transition transition) {
            getActivity().onBackPressed();
        }
    });
    TransitionManager.beginDelayedTransition(mRecyclerView, set);
    // remove all views from Recycler View
    mRecyclerView.setAdapter(null);
}
Also used : Explode(com.transitionseverywhere.Explode) Rect(android.graphics.Rect) TransitionSet(com.transitionseverywhere.TransitionSet) Transition(com.transitionseverywhere.Transition) Fade(com.transitionseverywhere.Fade)

Example 2 with TransitionSet

use of com.transitionseverywhere.TransitionSet in project Transitions-Everywhere by andkulikov.

the class ImageTransformSample method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_image_transform, container, false);
    final ViewGroup transitionsContainer = (ViewGroup) view.findViewById(R.id.transitions_container);
    final ImageView imageView = (ImageView) transitionsContainer.findViewById(R.id.image);
    imageView.setOnClickListener(new View.OnClickListener() {

        boolean mExpanded;

        @Override
        public void onClick(View v) {
            mExpanded = !mExpanded;
            TransitionManager.beginDelayedTransition(transitionsContainer, new TransitionSet().addTransition(new ChangeBounds()).addTransition(new ChangeImageTransform()));
            ViewGroup.LayoutParams params = imageView.getLayoutParams();
            params.height = mExpanded ? ViewGroup.LayoutParams.MATCH_PARENT : ViewGroup.LayoutParams.WRAP_CONTENT;
            imageView.setLayoutParams(params);
            imageView.setScaleType(mExpanded ? ImageView.ScaleType.CENTER_CROP : ImageView.ScaleType.FIT_CENTER);
        }
    });
    return view;
}
Also used : TransitionSet(com.transitionseverywhere.TransitionSet) ViewGroup(android.view.ViewGroup) ChangeBounds(com.transitionseverywhere.ChangeBounds) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) ChangeImageTransform(com.transitionseverywhere.ChangeImageTransform) Nullable(android.support.annotation.Nullable)

Example 3 with TransitionSet

use of com.transitionseverywhere.TransitionSet in project Transitions-Everywhere by andkulikov.

the class ScaleSample method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_scale, container, false);
    final ViewGroup transitionsContainer = (ViewGroup) view.findViewById(R.id.transitions_container);
    final TextView text1 = (TextView) transitionsContainer.findViewById(R.id.text1);
    transitionsContainer.findViewById(R.id.button1).setOnClickListener(new VisibleToggleClickListener() {

        @Override
        protected void changeVisibility(boolean visible) {
            TransitionManager.beginDelayedTransition(transitionsContainer, new Scale());
            text1.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
        }
    });
    final TextView text2 = (TextView) transitionsContainer.findViewById(R.id.text2);
    transitionsContainer.findViewById(R.id.button2).setOnClickListener(new VisibleToggleClickListener() {

        @Override
        protected void changeVisibility(boolean visible) {
            TransitionSet set = new TransitionSet().addTransition(new Scale(0.7f)).addTransition(new Fade()).setInterpolator(visible ? new LinearOutSlowInInterpolator() : new FastOutLinearInInterpolator());
            TransitionManager.beginDelayedTransition(transitionsContainer, set);
            text2.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
        }
    });
    return view;
}
Also used : LinearOutSlowInInterpolator(android.support.v4.view.animation.LinearOutSlowInInterpolator) TransitionSet(com.transitionseverywhere.TransitionSet) ViewGroup(android.view.ViewGroup) FastOutLinearInInterpolator(android.support.v4.view.animation.FastOutLinearInInterpolator) TextView(android.widget.TextView) Scale(com.transitionseverywhere.extra.Scale) TextView(android.widget.TextView) View(android.view.View) Fade(com.transitionseverywhere.Fade) Nullable(android.support.annotation.Nullable)

Example 4 with TransitionSet

use of com.transitionseverywhere.TransitionSet in project Douya by DreaminginCodeZH.

the class NavigationHeaderLayout method beginAvatarTransition.

private void beginAvatarTransition(ImageView moveAvatarOneImage, ImageView moveAvatarTwoImage, ImageView moveAvatarThreeImage) {
    ImageView appearAvatarImage = moveAvatarOneImage;
    ImageView disappearAvatarImage = moveAvatarThreeImage != null ? moveAvatarThreeImage : moveAvatarTwoImage;
    ImageView fadeOutDisappearAvatarImage = disappearAvatarImage == mAvatarImage ? mFadeOutAvatarImage : disappearAvatarImage == mRecentOneAvatarImage ? mFadeOutRecentOneAvatarImage : mFadeOutRecentTwoAvatarImage;
    TransitionSet transitionSet = new TransitionSet();
    int duration = ViewUtils.getLongAnimTime(getContext());
    // Will be set on already added and newly added transitions.
    transitionSet.setDuration(duration);
    // NOTE: TransitionSet.setInterpolator() won't have any effect on platform versions.
    // https://code.google.com/p/android/issues/detail?id=195495
    transitionSet.setInterpolator(new FastOutSlowInInterpolator());
    Fade fadeOutAvatar = new Fade(Fade.OUT);
    setAvatarImageFrom(fadeOutDisappearAvatarImage, disappearAvatarImage);
    fadeOutDisappearAvatarImage.setVisibility(VISIBLE);
    fadeOutAvatar.addTarget(fadeOutDisappearAvatarImage);
    transitionSet.addTransition(fadeOutAvatar);
    // Make it finish before new avatar arrives.
    fadeOutAvatar.setDuration(duration / 2);
    Fade fadeInAvatar = new Fade(Fade.IN);
    appearAvatarImage.setVisibility(INVISIBLE);
    fadeInAvatar.addTarget(appearAvatarImage);
    transitionSet.addTransition(fadeInAvatar);
    ChangeTransform changeAppearAvatarTransform = new ChangeTransform();
    appearAvatarImage.setScaleX(0.8f);
    appearAvatarImage.setScaleY(0.8f);
    changeAppearAvatarTransform.addTarget(appearAvatarImage);
    transitionSet.addTransition(changeAppearAvatarTransform);
    addChangeMoveToAvatarTransformToTransitionSet(moveAvatarOneImage, moveAvatarTwoImage, transitionSet);
    if (moveAvatarThreeImage != null) {
        addChangeMoveToAvatarTransformToTransitionSet(moveAvatarTwoImage, moveAvatarThreeImage, transitionSet);
    }
    CrossfadeText crossfadeText = new CrossfadeText();
    crossfadeText.addTarget(mNameText);
    crossfadeText.addTarget(mDescriptionText);
    transitionSet.addTransition(crossfadeText);
    transitionSet.addListener(new Transition.TransitionListenerAdapter() {

        @Override
        public void onTransitionEnd(Transition transition) {
            mAccountTransitionRunning = false;
            mInfoLayout.setEnabled(true);
            if (mListener != null) {
                mListener.onAccountTransitionEnd();
            }
        }
    });
    mInfoLayout.setEnabled(false);
    TransitionManager.beginDelayedTransition(this, transitionSet);
    mAccountTransitionRunning = true;
    if (mListener != null) {
        mListener.onAccountTransitionStart();
    }
    fadeOutDisappearAvatarImage.setVisibility(INVISIBLE);
    appearAvatarImage.setVisibility(VISIBLE);
    appearAvatarImage.setScaleX(1);
    appearAvatarImage.setScaleY(1);
    resetMoveToAvatarTransform(moveAvatarTwoImage);
    if (moveAvatarThreeImage != null) {
        resetMoveToAvatarTransform(moveAvatarThreeImage);
    }
}
Also used : CrossfadeText(me.zhanghai.android.douya.ui.CrossfadeText) ChangeTransform(com.transitionseverywhere.ChangeTransform) TransitionSet(com.transitionseverywhere.TransitionSet) FastOutSlowInInterpolator(android.support.v4.view.animation.FastOutSlowInInterpolator) Transition(com.transitionseverywhere.Transition) ImageView(android.widget.ImageView) Fade(com.transitionseverywhere.Fade)

Aggregations

TransitionSet (com.transitionseverywhere.TransitionSet)4 Fade (com.transitionseverywhere.Fade)3 Nullable (android.support.annotation.Nullable)2 View (android.view.View)2 ViewGroup (android.view.ViewGroup)2 ImageView (android.widget.ImageView)2 Transition (com.transitionseverywhere.Transition)2 Rect (android.graphics.Rect)1 FastOutLinearInInterpolator (android.support.v4.view.animation.FastOutLinearInInterpolator)1 FastOutSlowInInterpolator (android.support.v4.view.animation.FastOutSlowInInterpolator)1 LinearOutSlowInInterpolator (android.support.v4.view.animation.LinearOutSlowInInterpolator)1 TextView (android.widget.TextView)1 ChangeBounds (com.transitionseverywhere.ChangeBounds)1 ChangeImageTransform (com.transitionseverywhere.ChangeImageTransform)1 ChangeTransform (com.transitionseverywhere.ChangeTransform)1 Explode (com.transitionseverywhere.Explode)1 Scale (com.transitionseverywhere.extra.Scale)1 CrossfadeText (me.zhanghai.android.douya.ui.CrossfadeText)1