Search in sources :

Example 26 with Transition

use of android.transition.Transition in project Shuttle by timusus.

the class MainActivity method swapFragments.

public void swapFragments(Serializable item, View transitionView) {
    String transitionName = ViewCompat.getTransitionName(transitionView);
    DetailFragment detailFragment = DetailFragment.newInstance(item, transitionName);
    if (ShuttleUtils.hasLollipop()) {
        Transition moveTransition = TransitionInflater.from(this).inflateTransition(R.transition.image_transition);
        detailFragment.setSharedElementEnterTransition(moveTransition);
        detailFragment.setEnterTransition(new Fade());
        getCurrentFragment().setExitTransition(new Fade());
    }
    getSupportFragmentManager().beginTransaction().addSharedElement(transitionView, transitionName).replace(R.id.main_container, detailFragment).addToBackStack(null).commit();
}
Also used : Transition(android.transition.Transition) DetailFragment(com.simplecity.amp_library.ui.fragments.DetailFragment) Fade(android.transition.Fade)

Example 27 with Transition

use of android.transition.Transition in project Rutgers-Course-Tracker by tevjef.

the class SubjectFragment method startCourseFragement.

private void startCourseFragement(Bundle b) {
    CourseFragment courseFragment = new CourseFragment();
    courseFragment.setArguments(b);
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Transition sfTransition = TransitionInflater.from(getParentActivity()).inflateTransition(R.transition.sf_exit);
        setExitTransition(sfTransition.excludeTarget(Toolbar.class, true));
        courseFragment.setAllowEnterTransitionOverlap(false);
    } else {
        ft.setCustomAnimations(R.anim.enter, R.anim.exit, R.anim.pop_enter, R.anim.pop_exit);
    }
    startFragment(this, courseFragment, ft);
}
Also used : FragmentTransaction(android.app.FragmentTransaction) CourseFragment(com.tevinjeffrey.rutgersct.ui.course.CourseFragment) Transition(android.transition.Transition) Toolbar(android.support.v7.widget.Toolbar)

Example 28 with Transition

use of android.transition.Transition in project Rutgers-Course-Tracker by tevjef.

the class CourseInfoFragment method startSectionInfoFragment.

private void startSectionInfoFragment(Bundle b, View clickedView) {
    SectionInfoFragment sectionInfoFragment = new SectionInfoFragment();
    FragmentTransaction ft = this.getFragmentManager().beginTransaction();
    CircleView circleView = ButterKnife.findById(clickedView, R.id.section_number_background);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        circleView.setTransitionName(getString(R.string.transition_name_circle_view));
        ft.addSharedElement(circleView, getString(R.string.transition_name_circle_view));
        mAppBarLayout.setTransitionName(null);
        Transition cifSectionEnter = TransitionInflater.from(getParentActivity()).inflateTransition(R.transition.cif_section_enter);
        Transition cifSectionReturn = TransitionInflater.from(getParentActivity()).inflateTransition(R.transition.cif_section_return);
        sectionInfoFragment.setEnterTransition(cifSectionEnter);
        sectionInfoFragment.setReturnTransition(cifSectionReturn);
        setReenterTransition(new Fade(Fade.IN).setDuration(200));
        Transition cifExit = TransitionInflater.from(getParentActivity()).inflateTransition(R.transition.cif_exit);
        setExitTransition(cifExit);
        sectionInfoFragment.setAllowReturnTransitionOverlap(false);
        sectionInfoFragment.setAllowEnterTransitionOverlap(false);
        Transition sharedElementsEnter = TransitionInflater.from(getParentActivity()).inflateTransition(R.transition.cif_shared_element_enter);
        Transition sharedElementsReturn = TransitionInflater.from(getParentActivity()).inflateTransition(R.transition.cif_shared_element_return);
        sectionInfoFragment.setSharedElementEnterTransition(sharedElementsEnter);
        sectionInfoFragment.setSharedElementReturnTransition(sharedElementsReturn);
        CircleSharedElementCallback sharedelementCallback = new CircleSharedElementCallback();
        sectionInfoFragment.setEnterSharedElementCallback(sharedelementCallback);
        sharedElementsEnter.addListener(sharedelementCallback.getTransitionCallback());
    } else {
        ft.setCustomAnimations(R.anim.enter, R.anim.exit, R.anim.pop_enter, R.anim.pop_exit);
    }
    sectionInfoFragment.setArguments(b);
    startFragment(this, sectionInfoFragment, ft);
}
Also used : CircleSharedElementCallback(com.tevinjeffrey.rutgersct.ui.utils.CircleSharedElementCallback) FragmentTransaction(android.app.FragmentTransaction) SectionInfoFragment(com.tevinjeffrey.rutgersct.ui.sectioninfo.SectionInfoFragment) Transition(android.transition.Transition) CircleView(com.tevinjeffrey.rutgersct.ui.utils.CircleView) Fade(android.transition.Fade)

Example 29 with Transition

use of android.transition.Transition in project Shuttle by timusus.

the class DetailFragment method getSharedElementEnterTransitionListenerAdapter.

private TransitionListenerAdapter getSharedElementEnterTransitionListenerAdapter() {
    if (ShuttleUtils.hasLollipop()) {
        return new TransitionListenerAdapter() {

            @Override
            public void onTransitionEnd(Transition transition) {
                if (ShuttleUtils.hasLollipop()) {
                    //Todo:
                    //This is a partial fix for an issue where the initial artwork load tricks Glide into thinking the final
                    //image in the transition has the dimensions of the initial image.
                    //The idea is we would call this to force Glide to load a full res image, and we wouldn't need to use the
                    //override call in our initial Glide load in onCreateView.
                    //Unfortunately, because the initial image is square, but our header image is not, the transition isn't very nice..
                    //So for now, we'll stick with overriding the initial image dimensions..
                    //                        if (isAdded()) {
                    //                            requestManager
                    //                                    .load(albumArtist == null ? album : albumArtist)
                    //                                    .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                    //                                    .priority(Priority.HIGH)
                    //                                    .centerCrop()
                    //                                    .thumbnail(Glide
                    //                                            .with(DetailFragment.this)
                    //                                            .load(albumArtist == null ? album : albumArtist)
                    //                                            .override(headerImageView.getDrawable().getIntrinsicWidth(), headerImageView.getDrawable().getIntrinsicHeight())
                    //                                            .centerCrop())
                    //                                    .animate(new AlwaysCrossFade(false))
                    //                                    .into(headerImageView);
                    //                        }
                    transition.removeListener(this);
                    //Fade in the text protection scrim
                    textProtectionScrim.setAlpha(0f);
                    textProtectionScrim.setVisibility(View.VISIBLE);
                    ObjectAnimator fadeAnimator = ObjectAnimator.ofFloat(textProtectionScrim, View.ALPHA, 0f, 1f);
                    fadeAnimator.setDuration(800);
                    fadeAnimator.start();
                    //Fade & grow the FAB
                    fab.setAlpha(0f);
                    fab.setVisibility(View.VISIBLE);
                    fadeAnimator = ObjectAnimator.ofFloat(fab, View.ALPHA, 0.5f, 1f);
                    ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(fab, View.SCALE_X, 0f, 1f);
                    ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(fab, View.SCALE_Y, 0f, 1f);
                    AnimatorSet animatorSet = new AnimatorSet();
                    animatorSet.setInterpolator(new OvershootInterpolator(2f));
                    animatorSet.playTogether(fadeAnimator, scaleXAnimator, scaleYAnimator);
                    animatorSet.setDuration(250);
                    animatorSet.start();
                }
            }
        };
    }
    return null;
}
Also used : OvershootInterpolator(android.view.animation.OvershootInterpolator) ObjectAnimator(android.animation.ObjectAnimator) Transition(android.transition.Transition) AnimatorSet(android.animation.AnimatorSet)

Example 30 with Transition

use of android.transition.Transition in project Conductor by bluelinelabs.

the class FabToDialogTransitionChangeHandler method executePropertyChanges.

@Override
public void executePropertyChanges(@NonNull ViewGroup container, @Nullable View from, @Nullable View to, @NonNull Transition transition, boolean isPush) {
    if (isPush) {
        fabParent.removeView(fab);
        container.addView(to);
        /*
             * After the transition is finished we have to add the fab back to the original container.
             * Because otherwise we will be lost when trying to transition back.
             * Set it to invisible because we don't want it to jump back after the transition
             */
        transition.addListener(new AnimUtils.TransitionEndListener() {

            @Override
            public void onTransitionCompleted(Transition transition) {
                fab.setVisibility(View.GONE);
                fabParent.addView(fab);
                fab = null;
                fabParent = null;
            }
        });
    } else {
        dialogBackground.setVisibility(View.INVISIBLE);
        fabParent.addView(fab);
        container.removeView(from);
        transition.addListener(new TransitionEndListener() {

            @Override
            public void onTransitionCompleted(Transition transition) {
                fabParent.removeView(dialogBackground);
                dialogBackground = null;
            }
        });
    }
}
Also used : TransitionEndListener(com.bluelinelabs.conductor.demo.util.AnimUtils.TransitionEndListener) AnimUtils(com.bluelinelabs.conductor.demo.util.AnimUtils) Transition(android.transition.Transition) TransitionEndListener(com.bluelinelabs.conductor.demo.util.AnimUtils.TransitionEndListener)

Aggregations

Transition (android.transition.Transition)160 TransitionSet (android.transition.TransitionSet)57 View (android.view.View)51 ViewGroup (android.view.ViewGroup)36 ArrayList (java.util.ArrayList)20 TransitionInflater (android.transition.TransitionInflater)19 ViewTreeObserver (android.view.ViewTreeObserver)18 Fade (android.transition.Fade)17 ChangeBounds (android.transition.ChangeBounds)14 TextView (android.widget.TextView)11 TargetApi (android.annotation.TargetApi)10 Rect (android.graphics.Rect)10 List (java.util.List)10 AutoTransition (android.transition.AutoTransition)9 Scene (android.transition.Scene)8 ObjectAnimator (android.animation.ObjectAnimator)7 AdapterView (android.widget.AdapterView)6 ImageView (android.widget.ImageView)6 Animator (android.animation.Animator)5 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)5