@TargetApi(21) private void initTransitions() { Window window = getActivity().getWindow(); window.setEnterTransition( new ExplodeFadeEnterTransition(senderNameView, senderMailView, separatorLine)); window.setExitTransition(new ExcludedExplodeTransition()); window.setReenterTransition(new ExcludedExplodeTransition()); window.setReturnTransition(new ExcludedExplodeTransition()); TransitionSet textSizeSet = new TransitionSet(); textSizeSet.addTransition( TransitionInflater.from(getActivity()).inflateTransition(android.R.transition.move)); TextSizeTransition textSizeTransition = new TextSizeTransition(); textSizeTransition.addTarget(R.id.subject); textSizeTransition.addTarget(getString(R.string.shared_mail_subject)); textSizeSet.addTransition(textSizeTransition); textSizeSet.setOrdering(TransitionSet.ORDERING_TOGETHER); window.setSharedElementEnterTransition(textSizeSet); getActivity().setEnterSharedElementCallback( new TextSizeEnterSharedElementCallback(getActivity())); }
@OnClick(R.id.square2) public void onClick() { FragmentSharedElementTransitionTarget targetFragment = new FragmentSharedElementTransitionTarget(); // FIXME: 08/02/2017 the shared element transitions to the next fragment below other views while it should be on top as in Activity transitions if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { TransitionSet transitionSet = new TransitionSet(); transitionSet.addTransition(new ChangeBounds()); transitionSet.setPathMotion(new ArcMotion()); targetFragment.setSharedElementEnterTransition(transitionSet); targetFragment.setSharedElementReturnTransition(transitionSet); targetFragment.setEnterTransition(TransitionInflater.from(getActivity()).inflateTransition(R.transition.slide_bottom)); targetFragment.setExitTransition(TransitionInflater.from(getActivity()).inflateTransition(R.transition.slide_top_and_fade)); setExitTransition(new Explode()); setReenterTransition(new Explode()); setAllowReturnTransitionOverlap(false); } getActivity().getSupportFragmentManager() .beginTransaction() .addSharedElement(square2, getString(R.string.custom_element_transition_name)) .replace(R.id.fragmentContainer, targetFragment) .addToBackStack(null) .commit(); }
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) private TransitionSet constructTransitions() { int[] slideTargets = {R.id.ChatRecyclerView, R.id.chat_input, R.id.chat_input_divider}; Transition slideTransition = new Slide(Gravity.BOTTOM); Transition fadeTransition = new Fade(); for (int slideTarget : slideTargets) { slideTransition.addTarget(slideTarget); fadeTransition.excludeTarget(slideTarget, true); } TransitionSet set = new TransitionSet(); set.addTransition(slideTransition); set.addTransition(fadeTransition); return set; }
public static void removeTargets(Object transitionObject, ArrayList<View> views) { Transition transition = (Transition) transitionObject; int i; if (transition instanceof TransitionSet) { TransitionSet set = (TransitionSet) transition; int numTransitions = set.getTransitionCount(); for (i = 0; i < numTransitions; i++) { removeTargets(set.getTransitionAt(i), views); } } else if (!hasSimpleTarget(transition)) { List<View> targets = transition.getTargets(); if (targets != null && targets.size() == views.size() && targets.containsAll(views)) { for (i = views.size() - 1; i >= 0; i--) { transition.removeTarget((View) views.get(i)); } } } }
public static void addTargets(Object transitionObject, ArrayList<View> views) { Transition transition = (Transition) transitionObject; int i; if (transition instanceof TransitionSet) { TransitionSet set = (TransitionSet) transition; int numTransitions = set.getTransitionCount(); for (i = 0; i < numTransitions; i++) { addTargets(set.getTransitionAt(i), views); } } else if (!hasSimpleTarget(transition) && isNullOrEmpty(transition.getTargets())) { int numViews = views.size(); for (i = 0; i < numViews; i++) { transition.addTarget((View) views.get(i)); } } }
@Override protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_detail); postponeEnterTransition(); TransitionSet transitions = new TransitionSet(); Slide slide = new Slide(Gravity.BOTTOM); slide.setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in)); slide.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime)); transitions.addTransition(slide); transitions.addTransition(new Fade()); getWindow().setEnterTransition(transitions); Intent intent = getIntent(); sharedElementCallback = new DetailSharedElementEnterCallback(intent); setEnterSharedElementCallback(sharedElementCallback); initialItem = intent.getIntExtra(IntentUtil.SELECTED_ITEM_POSITION, 0); setUpViewPager(intent.<Photo>getParcelableArrayListExtra(IntentUtil.PHOTO)); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setNavigationOnClickListener(navigationOnClickListener); super.onCreate(savedInstanceState); }
public static void m219a(Object obj, ArrayList arrayList) { Transition transition = (Transition) obj; int transitionCount; if (transition instanceof TransitionSet) { TransitionSet transitionSet = (TransitionSet) transition; transitionCount = transitionSet.getTransitionCount(); for (int i = 0; i < transitionCount; i++) { ar.m219a(transitionSet.getTransitionAt(i), arrayList); } } else if (!ar.m223a(transition)) { List targets = transition.getTargets(); if (targets != null && targets.size() == arrayList.size() && targets.containsAll(arrayList)) { for (transitionCount = arrayList.size() - 1; transitionCount >= 0; transitionCount--) { transition.removeTarget((View) arrayList.get(transitionCount)); } } } }
public static void m228b(Object obj, ArrayList arrayList) { int i = 0; Transition transition = (Transition) obj; int transitionCount; if (transition instanceof TransitionSet) { TransitionSet transitionSet = (TransitionSet) transition; transitionCount = transitionSet.getTransitionCount(); while (i < transitionCount) { ar.m228b(transitionSet.getTransitionAt(i), arrayList); i++; } } else if (!ar.m223a(transition) && ar.m224a(transition.getTargets())) { int size = arrayList.size(); for (transitionCount = 0; transitionCount < size; transitionCount++) { transition.addTarget((View) arrayList.get(transitionCount)); } } }
/** * Finds all children of the shared elements and sets the wrapping TransitionSet * targets to point to those. It also limits transitions that have no targets to the * specific shared elements. This allows developers to target child views of the * shared elements specifically, but this doesn't happen by default. */ public static void setSharedElementTargets(Object transitionObj, View nonExistentView, Map<String, View> namedViews, ArrayList<View> sharedElementTargets) { TransitionSet transition = (TransitionSet) transitionObj; sharedElementTargets.clear(); sharedElementTargets.addAll(namedViews.values()); final List<View> views = transition.getTargets(); views.clear(); final int count = sharedElementTargets.size(); for (int i = 0; i < count; i++) { final View view = sharedElementTargets.get(i); bfsAddViewChildren(views, view); } sharedElementTargets.add(nonExistentView); addTargets(transition, sharedElementTargets); }
/** * This method removes the views from transitions that target ONLY those views. * The views list should match those added in addTargets and should contain * one view that is not in the view hierarchy (state.nonExistentView). */ public static void removeTargets(Object transitionObject, ArrayList<View> views) { Transition transition = (Transition) transitionObject; if (transition instanceof TransitionSet) { TransitionSet set = (TransitionSet) transition; int numTransitions = set.getTransitionCount(); for (int i = 0; i < numTransitions; i++) { Transition child = set.getTransitionAt(i); removeTargets(child, views); } } else if (!hasSimpleTarget(transition)) { List<View> targets = transition.getTargets(); if (targets != null && targets.size() == views.size() && targets.containsAll(views)) { // We have an exact match. We must have added these earlier in addTargets for (int i = views.size() - 1; i >= 0; i--) { transition.removeTarget(views.get(i)); } } } }
/** * This method adds views as targets to the transition, but only if the transition * doesn't already have a target. It is best for views to contain one View object * that does not exist in the view hierarchy (state.nonExistentView) so that * when they are removed later, a list match will suffice to remove the targets. * Otherwise, if you happened to have targeted the exact views for the transition, * the removeTargets call will remove them unexpectedly. */ public static void addTargets(Object transitionObject, ArrayList<View> views) { Transition transition = (Transition) transitionObject; if (transition instanceof TransitionSet) { TransitionSet set = (TransitionSet) transition; int numTransitions = set.getTransitionCount(); for (int i = 0; i < numTransitions; i++) { Transition child = set.getTransitionAt(i); addTargets(child, views); } } else if (!hasSimpleTarget(transition)) { List<View> targets = transition.getTargets(); if (isNullOrEmpty(targets)) { // We can just add the target views int numViews = views.size(); for (int i = 0; i < numViews; i++) { transition.addTarget(views.get(i)); } } } }
private void startTransition(){ lifeGridFragment = LifeGridFragment.newInstance(); FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if(Build.VERSION.SDK_INT >= 21) { TransitionSet gridTransition = new TransitionSet(); gridTransition.setDuration(600); gridTransition.addTransition(new ChangeBounds()); gridTransition.addTransition((new ChangeTransform())); lifeGridFragment.setSharedElementEnterTransition(gridTransition); } fragmentTransaction.addSharedElement(findViewById(R.id.intro_card_view), getString(R.string.card_view_transition_name)); fragmentTransaction.replace(R.id.container, lifeGridFragment); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); appBarLayout.setExpanded(false, true); }
public GalleryFragment() { final Fade fade = new Fade(); fade.addTarget(R.id.appbar); Explode explode = new Explode(); explode.excludeTarget(R.id.appbar, true); Elevation elevation = new Elevation(); elevation.addTarget(R.id.gallery_card); elevation.setStartDelay(250); // arbitrarily chosen delay TransitionSet exit = new TransitionSet(); exit.addTransition(fade); exit.addTransition(explode); exit.addTransition(elevation); setExitTransition(exit); }
public static void startToolbarAnimation( Context context, ViewGroup v ) { if (new UpdaterOptions(context).disableAnimations()) { return; } if (Build.VERSION.SDK_INT >= 21) { TransitionManager.beginDelayedTransition(v, new TransitionSet() .addTransition(new Fade(Fade.IN)) .addTransition(new Slide(Gravity.LEFT)) .addTransition(new ChangeBounds()) ); } else if (Build.VERSION.SDK_INT >= 14){ android.support.transition.TransitionManager.beginDelayedTransition(v, new AutoTransition().setDuration(250)); } { // No animation } }
@NonNull @Override protected Transition createTransition(@NonNull ViewGroup container, @NonNull View entering, @Nullable View leaving, boolean push) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { return new TransitionSet() .setOrdering(ORDERING_TOGETHER) .addTransition(new Fade(Fade.OUT)) .addTransition(new Fade(Fade.IN)); } final TransitionSet transition = new TransitionSet() .addTransition(new ChangeBounds()) .addTransition(new ChangeClipBounds()) .addTransition(new ChangeTransform()); transition.setPathMotion(new ArcMotion()); return transition; }
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) public static @Nullable Transition findTransition( @NonNull TransitionSet set, @NonNull Class<? extends Transition> clazz) { for (int i = 0; i < set.getTransitionCount(); i++) { Transition transition = set.getTransitionAt(i); if (transition.getClass() == clazz) { return transition; } if (transition instanceof TransitionSet) { Transition child = findTransition((TransitionSet) transition, clazz); if (child != null) return child; } } return null; }
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) public static @Nullable Transition findTransition( @NonNull TransitionSet set, @NonNull Class<? extends Transition> clazz, @IdRes int targetId) { for (int i = 0; i < set.getTransitionCount(); i++) { Transition transition = set.getTransitionAt(i); if (transition.getClass() == clazz) { if (transition.getTargetIds().contains(targetId)) { return transition; } } if (transition instanceof TransitionSet) { Transition child = findTransition((TransitionSet) transition, clazz, targetId); if (child != null) return child; } } return null; }
private Transition createTransition() { TransitionSet set = new TransitionSet(); set.setOrdering(TransitionSet.ORDERING_SEQUENTIAL); Transition tFab = new Scale(); tFab.setDuration(150); tFab.addTarget(fab); Transition tTitle = new Fold(); tTitle.setDuration(150); tTitle.addTarget(titlePanel); Transition tTrack = new Fold(); tTrack.setDuration(150); tTrack.addTarget(trackPanel); set.addTransition(tTrack); set.addTransition(tTitle); set.addTransition(tFab); return set; }
private void setupTransitions() { // grab the position that the search icon transitions in *from* // & use it to configure the return transition setEnterSharedElementCallback(new SharedElementCallback() { @Override public void onSharedElementStart( List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) { if (sharedElements != null && !sharedElements.isEmpty()) { View searchIcon = sharedElements.get(0); if (searchIcon.getId() != R.id.searchback) return; int centerX = (searchIcon.getLeft() + searchIcon.getRight()) / 2; CircularReveal hideResults = (CircularReveal) TransitionUtils.findTransition( (TransitionSet) getWindow().getReturnTransition(), CircularReveal.class, R.id.results_container); if (hideResults != null) { hideResults.setCenter(new Point(centerX, 0)); } } } }); }
public static @Nullable Transition findTransition( @NonNull TransitionSet set, @NonNull Class<? extends Transition> clazz, @IdRes int targetId) { for (int i = 0; i < set.getTransitionCount(); i++) { Transition transition = set.getTransitionAt(i); if (transition.getClass() == clazz) { if (transition.getTargetIds().contains(targetId)) { return transition; } } if (transition instanceof TransitionSet) { Transition child = findTransition((TransitionSet) transition, clazz, targetId); if (child != null) return child; } } return null; }
private void changeFabMode(boolean transformed, boolean animate) { if (animate) { final TransitionSet transition = new FabTransformation(transformed, fab.getHeight() / 2f); TransitionManager.beginDelayedTransition(sceneRoot, transition); } final float baseMargin = getResources().getDimension(R.dimen.fab_margin); final FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) fab.getLayoutParams(); params.bottomMargin = (int) (baseMargin - (transformed ? diff : 0)); params.setMarginEnd((int) (baseMargin + (transformed ? diff * HORIZONTAL_FACTOR : 0))); fab.setLayoutParams(params); toolsContainer.setVisibility(transformed ? View.VISIBLE : View.INVISIBLE); tools.setVisibility(transformed ? View.VISIBLE : View.INVISIBLE); tools.setScaleX(transformed ? 1f : 0.8f); fab.setVisibility(transformed ? View.INVISIBLE : View.VISIBLE); }
public static void addTargets(Object paramObject, ArrayList<View> paramArrayList) { Transition localTransition = (Transition)paramObject; if ((localTransition instanceof TransitionSet)) { TransitionSet localTransitionSet = (TransitionSet)localTransition; int k = localTransitionSet.getTransitionCount(); for (int m = 0; m < k; m++) { addTargets(localTransitionSet.getTransitionAt(m), paramArrayList); } } if ((!hasSimpleTarget(localTransition)) && (isNullOrEmpty(localTransition.getTargets()))) { int i = paramArrayList.size(); for (int j = 0; j < i; j++) { localTransition.addTarget((View)paramArrayList.get(j)); } } }
public static void removeTargets(Object paramObject, ArrayList<View> paramArrayList) { Transition localTransition = (Transition)paramObject; if ((localTransition instanceof TransitionSet)) { TransitionSet localTransitionSet = (TransitionSet)localTransition; int j = localTransitionSet.getTransitionCount(); for (int k = 0; k < j; k++) { removeTargets(localTransitionSet.getTransitionAt(k), paramArrayList); } } if (!hasSimpleTarget(localTransition)) { List localList = localTransition.getTargets(); if ((localList != null) && (localList.size() == paramArrayList.size()) && (localList.containsAll(paramArrayList))) { for (int i = -1 + paramArrayList.size(); i >= 0; i--) { localTransition.removeTarget((View)paramArrayList.get(i)); } } } }
public static void a(Object paramObject, ArrayList<View> paramArrayList) { Transition localTransition = (Transition)paramObject; if ((localTransition instanceof TransitionSet)) { TransitionSet localTransitionSet = (TransitionSet)localTransition; int i2 = localTransitionSet.getTransitionCount(); for (int i3 = 0; i3 < i2; i3++) { a(localTransitionSet.getTransitionAt(i3), paramArrayList); } } if (!a(localTransition)) { List localList = localTransition.getTargets(); if ((localList != null) && (localList.size() == paramArrayList.size()) && (localList.containsAll(paramArrayList))) { for (int i1 = -1 + paramArrayList.size(); i1 >= 0; i1--) { localTransition.removeTarget((View)paramArrayList.get(i1)); } } } }
public static void b(Object paramObject, ArrayList<View> paramArrayList) { int i1 = 0; Transition localTransition = (Transition)paramObject; if ((localTransition instanceof TransitionSet)) { TransitionSet localTransitionSet = (TransitionSet)localTransition; int i4 = localTransitionSet.getTransitionCount(); while (i1 < i4) { b(localTransitionSet.getTransitionAt(i1), paramArrayList); i1++; } } if ((!a(localTransition)) && (a(localTransition.getTargets()))) { int i2 = paramArrayList.size(); for (int i3 = 0; i3 < i2; i3++) { localTransition.addTarget((View)paramArrayList.get(i3)); } } }
@Override public void onCheckedChanged(final RadioGroup group, int checkedId) { switch (checkedId) { case R.id.select_scene_1: { // You can start an automatic transition with TransitionManager.go(). TransitionManager.go(mScene1); break; } case R.id.select_scene_2: { TransitionSet set = new TransitionSet(); Slide slide = new Slide(Gravity.LEFT); slide.addTarget(R.id.transition_title); set.addTransition(slide); set.addTransition(new ChangeBounds()); set.setOrdering(TransitionSet.ORDERING_TOGETHER); set.setDuration(350); TransitionManager.go(mScene2, set); break; } case R.id.select_scene_3: { // You can also start a transition with a custom TransitionManager. mTransitionManagerForScene3.transitionTo(mScene3); break; } } }
public static Transition mergeTransitions(Transition... transitions) { int count = 0; int nonNullIndex = -1; for (int i = 0; i < transitions.length; i++) { if (transitions[i] != null) { count++; nonNullIndex = i; } } if (count == 0) { return null; } if (count == 1) { return transitions[nonNullIndex]; } TransitionSet transitionSet = new TransitionSet(); for (int i = 0; i < transitions.length; i++) { if (transitions[i] != null) { transitionSet.addTransition(transitions[i]); } } return transitionSet; }
public static Transition makeSharedElementEnterTransition(List<String> textTransitionNames) { TransitionSet set = new TransitionSet(); set.setOrdering(TransitionSet.ORDERING_TOGETHER); Transition recolor = new Recolor(); Transition changeBounds = new ChangeBounds(); Transition textSize = new TextSizeTransition(); for (String textTName : textTransitionNames) { changeBounds.addTarget(textTName); textSize.addTarget(textTName); recolor.addTarget(textTName); } set.addTransition(recolor); set.addTransition(changeBounds); set.addTransition(textSize); ///set.setDuration(3000); return set; }
@OnClick({ R.id.text1 }) public void onTextClick() { // Create a TransitionSet that will animated ChangeBounds and Fade TransitionSet transitionSet = new TransitionSet(); transitionSet.addTransition(new ChangeBounds()); transitionSet.addTransition(new Fade()); TransitionManager.beginDelayedTransition(mLayout, transitionSet); // Remove text1 from the Layout mLayout.removeView(mText1); // Increase the height of Text1 and set a top margin LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mText1.getLayoutParams(); params.height *= 2; params.topMargin = 100; mText1.setLayoutParams(params); // Add text1 back to the layout // TransitionManager will automagically apply animations mLayout.addView(mText1, 1); }
public static TransitionSet createTransitionSet( ScalingUtils.ScaleType fromScale, ScalingUtils.ScaleType toScale) { TransitionSet transitionSet = new TransitionSet(); transitionSet.addTransition(new ChangeBounds()); transitionSet.addTransition(new DraweeTransition(fromScale, toScale)); return transitionSet; }
public void setupTransitions() { // Add shared element transition animation if on Lollipop or later if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // Enter transitions TransitionSet setEnter = new TransitionSet(); Transition slideDown = new Explode(); slideDown.addTarget(headerView); slideDown.excludeTarget(scrollView, true); slideDown.setDuration(500); setEnter.addTransition(slideDown); Transition fadeOut = new Slide(Gravity.BOTTOM); fadeOut.addTarget(scrollView); fadeOut.setDuration(500); setEnter.addTransition(fadeOut); // Exit transitions TransitionSet setExit = new TransitionSet(); Transition slideDown2 = new Explode(); slideDown2.addTarget(headerView); slideDown2.setDuration(570); setExit.addTransition(slideDown2); Transition fadeOut2 = new Slide(Gravity.BOTTOM); fadeOut2.addTarget(scrollView); fadeOut2.setDuration(280); setExit.addTransition(fadeOut2); getWindow().setEnterTransition(setEnter); getWindow().setReturnTransition(setExit); } }
private void performTransition() { if (isDestroyed()) { return; } Fragment previousFragment = mFragmentManager.findFragmentById(R.id.fragment_container); Fragment nextFragment = Fragment2.newInstance(); FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction(); // 1. Exit for Previous Fragment Fade exitFade = new Fade(); exitFade.setDuration(FADE_DEFAULT_TIME); previousFragment.setExitTransition(exitFade); // 2. Shared Elements Transition TransitionSet enterTransitionSet = new TransitionSet(); enterTransitionSet.addTransition(TransitionInflater.from(this).inflateTransition(android.R.transition.move)); enterTransitionSet.setDuration(MOVE_DEFAULT_TIME); enterTransitionSet.setStartDelay(FADE_DEFAULT_TIME); nextFragment.setSharedElementEnterTransition(enterTransitionSet); // 3. Enter Transition for New Fragment Fade enterFade = new Fade(); enterFade.setStartDelay(MOVE_DEFAULT_TIME + FADE_DEFAULT_TIME); enterFade.setDuration(FADE_DEFAULT_TIME); nextFragment.setEnterTransition(enterFade); View logo = ButterKnife.findById(this, R.id.fragment1_logo); fragmentTransaction.addSharedElement(logo, logo.getTransitionName()); fragmentTransaction.replace(R.id.fragment_container, nextFragment); fragmentTransaction.commitAllowingStateLoss(); }
BottomNavigationAnimationHelperKitkat() { mSet = new AutoTransition(); mSet.setOrdering(TransitionSet.ORDERING_TOGETHER); mSet.setDuration(ACTIVE_ANIMATION_DURATION_MS); mSet.setInterpolator(new FastOutSlowInInterpolator()); TextScale textScale = new TextScale(); mSet.addTransition(textScale); }
@Override @NonNull protected Transition getTransition(@NonNull ViewGroup container, View from, View to, boolean isPush) { TransitionSet transition = new TransitionSet() .setOrdering(TransitionSet.ORDERING_SEQUENTIAL) .addTransition(new Fade(Fade.OUT)) .addTransition(new TransitionSet().addTransition(new ChangeBounds()).addTransition(new ChangeClipBounds()).addTransition(new ChangeTransform())) .addTransition(new Fade(Fade.IN)); transition.setPathMotion(new ArcMotion()); return transition; }