Search in sources :

Example 1 with TransitionSet

use of androidx.transition.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);
    final Explode explode = new Explode();
    explode.setEpicenterCallback(new Transition.EpicenterCallback() {

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

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

Example 2 with TransitionSet

use of androidx.transition.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 = view.findViewById(R.id.transitions_container);
    final 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(androidx.transition.TransitionSet) ViewGroup(android.view.ViewGroup) ChangeBounds(androidx.transition.ChangeBounds) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) ChangeImageTransform(androidx.transition.ChangeImageTransform) Nullable(androidx.annotation.Nullable)

Example 3 with TransitionSet

use of androidx.transition.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 = view.findViewById(R.id.transitions_container);
    final TextView text1 = 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 = 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(androidx.interpolator.view.animation.LinearOutSlowInInterpolator) TransitionSet(androidx.transition.TransitionSet) ViewGroup(android.view.ViewGroup) FastOutLinearInInterpolator(androidx.interpolator.view.animation.FastOutLinearInInterpolator) TextView(android.widget.TextView) Scale(com.transitionseverywhere.extra.Scale) TextView(android.widget.TextView) View(android.view.View) Fade(androidx.transition.Fade) Nullable(androidx.annotation.Nullable)

Aggregations

TransitionSet (androidx.transition.TransitionSet)3 View (android.view.View)2 ViewGroup (android.view.ViewGroup)2 Nullable (androidx.annotation.Nullable)2 Fade (androidx.transition.Fade)2 Rect (android.graphics.Rect)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 FastOutLinearInInterpolator (androidx.interpolator.view.animation.FastOutLinearInInterpolator)1 LinearOutSlowInInterpolator (androidx.interpolator.view.animation.LinearOutSlowInInterpolator)1 ChangeBounds (androidx.transition.ChangeBounds)1 ChangeImageTransform (androidx.transition.ChangeImageTransform)1 Explode (androidx.transition.Explode)1 Transition (androidx.transition.Transition)1 TransitionListenerAdapter (androidx.transition.TransitionListenerAdapter)1 Scale (com.transitionseverywhere.extra.Scale)1