Example usage for android.transition TransitionInflater from

List of usage examples for android.transition TransitionInflater from

Introduction

In this page you can find the example usage for android.transition TransitionInflater from.

Prototype

public static TransitionInflater from(Context context) 

Source Link

Document

Obtains the TransitionInflater from the given context.

Usage

From source file:io.plaidapp.ui.FeedAdapter.java

/**
 * The shared element transition to dribbble shots & dn stories can intersect with the FAB.
 * This can cause a strange layers-passing-through-each-other effect, especially on return.
 * In this situation, hide the FAB on exit and re-show it on return.
 *//*from   w w  w.ja  v  a  2 s. co m*/
private void setGridItemContentTransitions(View gridItem) {
    if (!ViewUtils.viewsIntersect(gridItem, host.findViewById(R.id.fab)))
        return;

    final TransitionInflater ti = TransitionInflater.from(host);
    host.getWindow().setExitTransition(ti.inflateTransition(R.transition.home_content_item_exit));
    final Transition reenter = ti.inflateTransition(R.transition.home_content_item_reenter);
    // we only want this content transition in certain cases so clear it out after it's done.
    reenter.addListener(new AnimUtils.TransitionListenerAdapter() {
        @Override
        public void onTransitionEnd(Transition transition) {
            host.getWindow().setExitTransition(null);
            host.getWindow().setReenterTransition(null);
        }
    });
    host.getWindow().setReenterTransition(reenter);
}

From source file:io.plaidapp.core.ui.FeedAdapter.java

/**
 * The shared element transition to dribbble shots & dn stories can intersect with the FAB.
 * This can cause a strange layers-passing-through-each-other effect. On return hide the FAB
 * and animate it back in after the transition.
 *//*from  w  w w . j  a  v  a 2 s  .c om*/
private void setGridItemContentTransitions(View gridItem) {
    final View fab = host.findViewById(R.id.fab);
    if (!ViewUtils.viewsIntersect(gridItem, fab))
        return;

    Transition reenter = TransitionInflater.from(host).inflateTransition(R.transition.grid_overlap_fab_reenter);
    reenter.addListener(new TransitionUtils.TransitionListenerAdapter() {

        @Override
        public void onTransitionEnd(Transition transition) {
            // we only want these content transitions in certain cases so clear out when done.
            host.getWindow().setReenterTransition(null);
        }
    });
    host.getWindow().setReenterTransition(reenter);
}

From source file:bf.io.openshop.ux.MainActivity.java

/**
 * Launch {@link ProductFragment}.//w w  w .  j  a  v a  2  s .  com
 *
 * @param productId id of product for display.
 */
public void onProductSelected(long productId) {
    Fragment fragment = ProductFragment.newInstance(productId);
    if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
        fragment.setReturnTransition(
                TransitionInflater.from(this).inflateTransition(android.R.transition.fade));
    }
    replaceFragment(fragment, ProductFragment.class.getSimpleName());
}

From source file:de.tap.easy_xkcd.Activities.MainActivity.java

public void showOverview() {
    android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager();

    if (fragmentManager.findFragmentByTag(OVERVIEW_TAG) != null) {
        int pos = ((ComicFragment) fragmentManager.findFragmentByTag(BROWSER_TAG)).lastComicNumber;
        ((OverviewListFragment) fragmentManager.findFragmentByTag(OVERVIEW_TAG)).notifyAdapter(pos);
    }//from   w w  w.j  a  v  a2 s .  c o m

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        if (fragmentManager.findFragmentByTag(OVERVIEW_TAG) == null)
            fragmentManager.beginTransaction().add(R.id.flContent, new OverviewListFragment(), OVERVIEW_TAG)
                    .commitAllowingStateLoss();
        else
            fragmentManager.beginTransaction().show(fragmentManager.findFragmentByTag(OVERVIEW_TAG))
                    .commitAllowingStateLoss();
        fragmentManager.beginTransaction().hide(fragmentManager.findFragmentByTag(BROWSER_TAG))
                .commitAllowingStateLoss();
    } else {
        Transition left = TransitionInflater.from(this).inflateTransition(android.R.transition.slide_left);
        Transition right = TransitionInflater.from(this).inflateTransition(android.R.transition.fade);
        fragmentManager.findFragmentByTag(BROWSER_TAG).setExitTransition(right);

        if (fragmentManager.findFragmentByTag(OVERVIEW_TAG) == null) {
            OverviewListFragment overviewListFragment = new OverviewListFragment();
            overviewListFragment.setEnterTransition(left);
            getSupportFragmentManager().beginTransaction().hide(fragmentManager.findFragmentByTag(BROWSER_TAG))
                    .add(R.id.flContent, overviewListFragment, OVERVIEW_TAG).commit();
        } else {
            fragmentManager.findFragmentByTag(OVERVIEW_TAG).setEnterTransition(left);
            getSupportFragmentManager().beginTransaction().hide(fragmentManager.findFragmentByTag(BROWSER_TAG))
                    .show(fragmentManager.findFragmentByTag(OVERVIEW_TAG))

                    .commit();
        }
        fragmentManager.findFragmentByTag(BROWSER_TAG).setExitTransition(null);
    }
    assert getSupportActionBar() != null;
    getSupportActionBar().setSubtitle("");
}

From source file:com.zertinteractive.wallpaper.MainActivity.java

@SuppressWarnings("NewApi")
private void setupEnterAnimations() {
    Transition transition = TransitionInflater.from(this)
            .inflateTransition(R.transition.changebounds_with_arcmotion);
    getWindow().setSharedElementEnterTransition(transition);
    transition.addListener(new Transition.TransitionListener() {
        @Override/* w  w  w . j  a v a 2  s  . c o  m*/
        public void onTransitionStart(Transition transition) {
        }

        @Override
        public void onTransitionEnd(Transition transition) {
            // Removing listener here is very important because shared element transition is executed again backwards on exit. If we don't remove the listener this code will be triggered again.
            transition.removeListener(this);
            animateButtonsIn();
        }

        @Override
        public void onTransitionCancel(Transition transition) {
        }

        @Override
        public void onTransitionPause(Transition transition) {
        }

        @Override
        public void onTransitionResume(Transition transition) {
        }
    });
}

From source file:android.app.FragmentState.java

private static Transition loadTransition(Context context, TypedArray typedArray, Transition currentValue,
        Transition defaultValue, int id) {
    if (currentValue != defaultValue) {
        return currentValue;
    }//from  w w  w  .ja  v  a 2 s .  c  o m
    int transitionId = typedArray.getResourceId(id, 0);
    Transition transition = defaultValue;
    if (transitionId != 0 && transitionId != com.android.internal.R.transition.no_transition) {
        TransitionInflater inflater = TransitionInflater.from(context);
        transition = inflater.inflateTransition(transitionId);
        if (transition instanceof TransitionSet && ((TransitionSet) transition).getTransitionCount() == 0) {
            transition = null;
        }
    }
    return transition;
}