@Override public boolean onTransition(Context context, FragmentTransaction transaction, Fragment exit, Fragment enter) { if (mThumb == null || !(enter instanceof GalleryDetailScene)) { return false; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { exit.setSharedElementReturnTransition( TransitionInflater.from(context).inflateTransition(R.transition.trans_move)); exit.setExitTransition( TransitionInflater.from(context).inflateTransition(android.R.transition.fade)); enter.setSharedElementEnterTransition( TransitionInflater.from(context).inflateTransition(R.transition.trans_move)); enter.setEnterTransition( TransitionInflater.from(context).inflateTransition(android.R.transition.fade)); transaction.addSharedElement(mThumb, mThumb.getTransitionName()); } return true; } }
if (Build.VERSION.SDK_INT >= 21) { TransitionInflater inflater = TransitionInflater.from(this); Transition transition = inflater.inflateTransition(R.transition.transition_a); getWindow().setExitTransition(transition); }
/** * Ensures that the transition inflater is initialized. * * @param context Context used for initialization of the inflater if necessary. */ @SuppressLint("NewApi") private void ensureTransitionInflater(Context context) { if (mTransitionInflater == null) mTransitionInflater = TransitionInflater.from(context); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.transition); mSceneRoot = (ViewGroup) findViewById(R.id.sceneRoot); TransitionInflater inflater = TransitionInflater.from(this); // Note that this is not the only way to create a Scene object, but that // loading them from layout resources cooperates with the // TransitionManager that we are also loading from resources, and which // uses the same layout resource files to determine the scenes to transition // from/to. mScene1 = Scene.getSceneForLayout(mSceneRoot, R.layout.transition_scene1, this); mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.transition_scene2, this); mScene3 = Scene.getSceneForLayout(mSceneRoot, R.layout.transition_scene3, this); mTransitionManager = inflater.inflateTransitionManager(R.transition.transitions_mgr, mSceneRoot); }
/** * Inflates a new transition manager from the specified Xml <var>resource</var>. * * @param resource Resource id of the desired transition manager to be inflated. * @param sceneRoot Scene root with which to create the requested manager. * @return Inflated transition manager or {@code null} if the current Android version does not * support inflating of transitions from the Xml. */ @Nullable @SuppressLint("NewApi") protected TransitionManager inflateTransitionManager(int resource, @NonNull ViewGroup sceneRoot) { if (!FragmentsConfig.TRANSITIONS_SUPPORTED) return null; this.ensureTransitionInflater(); return mTransitionInflater.inflateTransitionManager(resource, sceneRoot); }
/** * Inflates a new transition from the specified Xml <var>resource</var>. * * @param resource Resource id of the desired transition to be inflated. * @return Inflated transition or {@code null} if the current Android version does not support * inflating of transitions from the Xml or this factory was not instantiated with valid context. */ @Nullable @SuppressLint("NewApi") public Transition inflateTransition(int resource) { if (!FragmentsConfig.TRANSITIONS_SUPPORTED || mTransitionInflater == null) return null; return mTransitionInflater.inflateTransition(resource); }
/** * Ensures that the transition inflater is initialized. * * @param context Context used for initialization of the inflater if necessary. */ @SuppressLint("NewApi") private void ensureTransitionInflater(Context context) { if (mTransitionInflater == null) mTransitionInflater = TransitionInflater.from(context); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.transition); mSceneRoot = (ViewGroup) findViewById(R.id.sceneRoot); TransitionInflater inflater = TransitionInflater.from(this); // Note that this is not the only way to create a Scene object, but that // loading them from layout resources cooperates with the // TransitionManager that we are also loading from resources, and which // uses the same layout resource files to determine the scenes to transition // from/to. mScene1 = Scene.getSceneForLayout(mSceneRoot, R.layout.transition_scene1, this); mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.transition_scene2, this); mScene3 = Scene.getSceneForLayout(mSceneRoot, R.layout.transition_scene3, this); mTransitionManager = inflater.inflateTransitionManager(R.transition.transitions_mgr, mSceneRoot); }
/** * Inflates a new transition manager from the specified Xml <var>resource</var>. * * @param resource Resource id of the desired transition manager to be inflated. * @param sceneRoot Scene root with which to create the requested manager. * @return Inflated transition manager or {@code null} if the current Android version does not * support inflating of transitions from the Xml. */ @Nullable @SuppressLint("NewApi") protected TransitionManager inflateTransitionManager(int resource, @NonNull ViewGroup sceneRoot) { if (!FragmentsConfig.TRANSITIONS_SUPPORTED) return null; this.ensureTransitionInflater(); return mTransitionInflater.inflateTransitionManager(resource, sceneRoot); }
@Override public boolean onTransition(Context context, FragmentTransaction transaction, Fragment exit, Fragment enter) { if (!(enter instanceof GalleryListScene) && !(enter instanceof DownloadsScene) && !(enter instanceof FavoritesScene) && !(enter instanceof HistoryScene)) { return false; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { exit.setSharedElementReturnTransition( TransitionInflater.from(context).inflateTransition(R.transition.trans_move)); exit.setExitTransition( TransitionInflater.from(context).inflateTransition(android.R.transition.fade)); enter.setSharedElementEnterTransition( TransitionInflater.from(context).inflateTransition(R.transition.trans_move)); enter.setEnterTransition( TransitionInflater.from(context).inflateTransition(android.R.transition.fade)); transaction.addSharedElement(mThumb, mThumb.getTransitionName()); } return true; } }
/** * Inflates a new transition from the specified Xml <var>resource</var>. * * @param resource Resource id of the desired transition to be inflated. * @return Inflated transition or {@code null} if the current Android version does not support * inflating of transitions from the Xml or this factory was not instantiated with valid context. */ @Nullable @SuppressLint("NewApi") public Transition inflateTransition(int resource) { if (!FragmentsConfig.TRANSITIONS_SUPPORTED || mTransitionInflater == null) return null; return mTransitionInflater.inflateTransition(resource); }
/** * Ensures that the transition inflater is initialized. */ @SuppressLint("NewApi") private void ensureTransitionInflater() { if (mTransitionInflater == null) mTransitionInflater = TransitionInflater.from(getActivity()); }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_basic_transition, container, false); assert view != null; RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.select_scene); radioGroup.setOnCheckedChangeListener(this); mSceneRoot = (ViewGroup) view.findViewById(R.id.scene_root); // BEGIN_INCLUDE(instantiation_from_view) // A Scene can be instantiated from a live view hierarchy. mScene1 = new Scene(mSceneRoot, (ViewGroup) mSceneRoot.findViewById(R.id.container)); // END_INCLUDE(instantiation_from_view) // BEGIN_INCLUDE(instantiation_from_resource) // You can also inflate a generate a Scene from a layout resource file. mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene2, getActivity()); // END_INCLUDE(instantiation_from_resource) // Another scene from a layout resource file. mScene3 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene3, getActivity()); // BEGIN_INCLUDE(custom_transition_manager) // We create a custom TransitionManager for Scene 3, in which ChangeBounds and Fade // take place at the same time. mTransitionManagerForScene3 = TransitionInflater.from(getActivity()) .inflateTransitionManager(R.transition.scene3_transition_manager, mSceneRoot); // END_INCLUDE(custom_transition_manager) return view; }
/** * Inflates a new instance of TransitionManager from the specified <var>resource</var>. * <p> * <b>Note</b>, that for pre {@link Build.VERSION_CODES#LOLLIPOP LOLLIPOP} Android * versions this method does nothing and returns {@code null}. * * @param resource Resource id of the desired transition manager to inflater. * @param sceneRoot Root view for the scene with which will the manager operate. * @return Inflated transition manager. */ @Nullable @SuppressLint("NewApi") public TransitionManager inflateTransitionManager(int resource, @NonNull ViewGroup sceneRoot) { if (!UiConfig.MATERIALIZED) return null; this.ensureTransitionInflater(sceneRoot.getContext()); return mTransitionInflater.inflateTransitionManager(resource, sceneRoot); }
/** * 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. */ 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); }
if (Build.VERSION.SDK_INT >= 21) { TransitionInflater inflater = TransitionInflater.from(LoginActivity.this); Transition transition = inflater.inflateTransition(R.transition.fade_transition); TransisitonTime = transition.getDuration()*2; getWindow().setExitTransition(transition); } ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(LoginActivity.this);
/** * Ensures that the transition inflater is initialized. */ @SuppressLint("NewApi") private void ensureTransitionInflater() { if (mTransitionInflater == null) mTransitionInflater = TransitionInflater.from(getActivity()); }
/** * Inflates a new instance of TransitionManager from the specified <var>resource</var>. * <p> * <b>Note</b>, that for pre {@link Build.VERSION_CODES#LOLLIPOP LOLLIPOP} Android * versions this method does nothing and returns {@code null}. * * @param resource Resource id of the desired transition manager to inflater. * @param sceneRoot Root view for the scene with which will the manager operate. * @return Inflated transition manager. */ @Nullable @SuppressLint("NewApi") public TransitionManager inflateTransitionManager(int resource, @NonNull ViewGroup sceneRoot) { if (!UiConfig.MATERIALIZED) return null; this.ensureTransitionInflater(sceneRoot.getContext()); return mTransitionInflater.inflateTransitionManager(resource, sceneRoot); }
private void ShowEnterAnimation() { Transition transition = TransitionInflater.from(this).inflateTransition(R.transition.fabtransition); getWindow().setSharedElementEnterTransition(transition); transition.addListener(new Transition.TransitionListener() { @Override public void onTransitionStart(Transition transition) { cvAdd.setVisibility(View.GONE); } @Override public void onTransitionEnd(Transition transition) { transition.removeListener(this); animateRevealShow(); } @Override public void onTransitionCancel(Transition transition) { } @Override public void onTransitionPause(Transition transition) { } @Override public void onTransitionResume(Transition transition) { } }); }
/** * Inflates a new transition from the specified Xml <var>resource</var>. * * @param resource Resource id of the desired transition to be inflated. * @return Inflated transition or {@code null} if the current Android version does not support * inflating of transitions from the Xml. */ @Nullable @SuppressLint("NewApi") protected Transition inflateTransition(int resource) { if (!FragmentsConfig.TRANSITIONS_SUPPORTED) return null; this.ensureTransitionInflater(); return mTransitionInflater.inflateTransition(resource); }