Search in sources :

Example 1 with Fade

use of androidx.transition.Fade 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 Fade

use of androidx.transition.Fade in project IITB-App by wncc.

the class Utils method updateSharedElementFragment.

public static void updateSharedElementFragment(final Fragment fragment, final Fragment currentFragment, Map<View, String> sharedElements) {
    FragmentTransaction ft = currentFragment.getActivity().getSupportFragmentManager().beginTransaction();
    Transition transition = new DetailsTransition();
    /* Set up transitions */
    fragment.setSharedElementEnterTransition(transition);
    fragment.setEnterTransition(new Slide());
    currentFragment.setExitTransition(new Fade());
    fragment.setSharedElementReturnTransition(transition);
    /* Set transition for parent in case it is a child */
    if (currentFragment instanceof TransitionTargetChild) {
        ((TransitionTargetChild) currentFragment).getParent().setExitTransition(new Fade());
    }
    transition.addListener(new Transition.TransitionListener() {

        @Override
        public void onTransitionStart(Transition transition) {
        }

        @Override
        public void onTransitionEnd(Transition transition) {
            if (fragment instanceof TransitionTargetFragment) {
                ((TransitionTargetFragment) fragment).transitionEnd();
            }
            if (currentFragment instanceof TransitionTargetFragment) {
                ((TransitionTargetFragment) currentFragment).transitionEnd();
            }
        }

        @Override
        public void onTransitionCancel(Transition transition) {
        }

        @Override
        public void onTransitionPause(Transition transition) {
        }

        @Override
        public void onTransitionResume(Transition transition) {
        }
    });
    /* Add all shared elements */
    for (Map.Entry<View, String> entry : sharedElements.entrySet()) {
        ft.addSharedElement(entry.getKey(), entry.getValue());
    }
    /* Update the fragment */
    ft.replace(R.id.framelayout_for_fragment, fragment, getTag(fragment)).addToBackStack(getTag(fragment)).commit();
}
Also used : NavigationView(com.google.android.material.navigation.NavigationView) ImageView(android.widget.ImageView) View(android.view.View) FragmentTransaction(androidx.fragment.app.FragmentTransaction) TransitionTargetChild(app.insti.fragment.TransitionTargetChild) TransitionTargetFragment(app.insti.fragment.TransitionTargetFragment) Slide(androidx.transition.Slide) Transition(androidx.transition.Transition) Fade(androidx.transition.Fade) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with Fade

use of androidx.transition.Fade 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

Fade (androidx.transition.Fade)3 View (android.view.View)2 Transition (androidx.transition.Transition)2 TransitionSet (androidx.transition.TransitionSet)2 Rect (android.graphics.Rect)1 ViewGroup (android.view.ViewGroup)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 Nullable (androidx.annotation.Nullable)1 FragmentTransaction (androidx.fragment.app.FragmentTransaction)1 FastOutLinearInInterpolator (androidx.interpolator.view.animation.FastOutLinearInInterpolator)1 LinearOutSlowInInterpolator (androidx.interpolator.view.animation.LinearOutSlowInInterpolator)1 Explode (androidx.transition.Explode)1 Slide (androidx.transition.Slide)1 TransitionListenerAdapter (androidx.transition.TransitionListenerAdapter)1 TransitionTargetChild (app.insti.fragment.TransitionTargetChild)1 TransitionTargetFragment (app.insti.fragment.TransitionTargetFragment)1 NavigationView (com.google.android.material.navigation.NavigationView)1 Scale (com.transitionseverywhere.extra.Scale)1 HashMap (java.util.HashMap)1