List of usage examples for android.transition TransitionManager go
public static void go(Scene scene, Transition transition)
From source file:com.example.android.customtransition.CustomTransitionFragment.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.show_next_scene: { mCurrentScene = (mCurrentScene + 1) % mScenes.length; Log.i(TAG, "Transitioning to scene #" + mCurrentScene); // Pass the custom Transition as second argument for TransitionManager.go TransitionManager.go(mScenes[mCurrentScene], mTransition); break;/*ww w . j av a 2s .co m*/ } } }
From source file:com.kai.uGuide.ui.fragment.AdapterTransitionFragment.java
/** * Toggle the UI between ListView and GridView. */// ww w . j av a2 s.c o m public void toggle() { // We use mCover as the overlay on which we carry out the transition. mCover.setVisibility(View.VISIBLE); // This FrameLayout holds all the visible views in the current list or grid. We use this as // the starting Scene of the Transition later. FrameLayout before = copyVisibleViews(); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT); mCover.addView(before, params); // Swap the actual list. swapAbsListView(); // We also swap the icon for the toggle button. ActivityCompat.invalidateOptionsMenu(getActivity()); // It is now ready to start the transition. mAbsListView.post(new Runnable() { @Override public void run() { // BEGIN_INCLUDE(transition_with_listener) Scene scene = new Scene(mCover, copyVisibleViews()); Transition transition = new AutoTransition(); transition.addListener(AdapterTransitionFragment.this); TransitionManager.go(scene, transition); // END_INCLUDE(transition_with_listener) } }); }
From source file:com.example.kent_zheng.sdk_adaptertransition.AdapterTransitionFragment.java
/** * Toggle the UI between ListView and GridView. *///from ww w.ja v a 2s. com private void toggle() { // We use mCover as the overlay on which we carry out the transition. mCover.setVisibility(View.VISIBLE); // This FrameLayout holds all the visible views in the current list or grid. We use this as // the starting Scene of the Transition later. FrameLayout before = copyVisibleViews(); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT); mCover.addView(before, params); // Swap the actual list. swapAbsListView(); // We also swap the icon for the toggle button. ActivityCompat.invalidateOptionsMenu(getActivity()); // It is now ready to start the transition. mAbsListView.post(new Runnable() { @Override public void run() { Scene scene = new Scene(mCover, copyVisibleViews()); Transition transition = new AutoTransition(); transition.addListener(AdapterTransitionFragment.this); TransitionManager.go(scene, transition); } }); }
From source file:com.example.android.adaptertransition.AdapterTransitionFragment.java
/** * Toggle the UI between ListView and GridView. *///from w w w . j a v a 2s . com private void toggle() { // We use mCover as the overlay on which we carry out the transition. mCover.setVisibility(View.VISIBLE); // This FrameLayout holds all the visible views in the current list or grid. We use this as // the starting Scene of the Transition later. FrameLayout before = copyVisibleViews(); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT); mCover.addView(before, params); // Swap the actual list. swapAbsListView(); // We also swap the icon for the toggle button. ActivityCompat.invalidateOptionsMenu(getActivity()); // It is now ready to start the transition. mAbsListView.post(new Runnable() { @Override public void run() { // BEGIN_INCLUDE(transition_with_listener) Scene scene = new Scene(mCover, copyVisibleViews()); Transition transition = new AutoTransition(); transition.addListener(AdapterTransitionFragment.this); TransitionManager.go(scene, transition); // END_INCLUDE(transition_with_listener) } }); }
From source file:com.saulmm.cui.OrderDialogFragment.java
private void changeToConfirmScene() { final LayoutOrderConfirmationBinding confBinding = prepareConfirmationBinding(); final Scene scene = new Scene(binding.content, ((ViewGroup) confBinding.getRoot())); scene.setEnterAction(onEnterConfirmScene(confBinding)); final Transition transition = TransitionInflater.from(getContext()) .inflateTransition(R.transition.transition_confirmation_view); TransitionManager.go(scene, transition); }
From source file:com.achep.acdisplay.ui.fragments.AcDisplayFragment.java
/** * Changes current scene to given one./* www . j a va2 s . co m*/ * * @see #showWidget(com.achep.acdisplay.ui.components.Widget) */ @SuppressLint("NewApi") protected synchronized final void goScene(@NonNull SceneCompat sceneCompat, boolean animate) { if (mCurrentScene == sceneCompat) return; mCurrentScene = sceneCompat; if (DEBUG) Log.d(TAG, "Going to " + sceneCompat); if (Device.hasKitKatApi()) animate &= mSceneContainer.isLaidOut(); if (!animate) { sceneCompat.enter(); return; } if (Device.hasKitKatApi()) { final Scene scene = sceneCompat.getScene(); try { // This must be a synchronization problem with Android's Scene or TransitionManager, // but those were declared as final classes, so I have no idea how to fix it. TransitionManager.go(scene, mTransitionSwitchScene); } catch (IllegalStateException e) { Log.w(TAG, "TransitionManager has failed switching scenes!"); ViewGroup viewGroup = (ViewGroup) getSceneView().getParent(); viewGroup.removeView(getSceneView()); try { // Reset internal scene's tag to make it work again. int id = Resources.getSystem().getIdentifier("current_scene", "id", "android"); Method method = View.class.getMethod("setTagInternal", int.class, Object.class); method.setAccessible(true); method.invoke(viewGroup, id, null); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e2) { throw new RuntimeException("An attempt to fix the TransitionManager has failed."); } TransitionManager.go(scene, mTransitionSwitchScene); } } else { sceneCompat.enter(); if (getActivity() != null) { // TODO: Better animation for Jelly Bean users. float density = getResources().getDisplayMetrics().density; getSceneView().setAlpha(0.6f); getSceneView().setRotationX(6f); getSceneView().setTranslationY(6f * density); getSceneView().animate().alpha(1).rotationX(0).translationY(0); } } }