@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.HONEYCOMB) private void handleTransitions() { useSysTransition = getIntent().getBooleanExtra(KEY_USE_SYS_TRANSITION, false); if(useSysTransition) { ivDetail.setVisibility(View.VISIBLE); Fade fade = new Fade(); fade.setDuration(500); getWindow().setEnterTransition(fade); getWindow().setExitTransition(fade); ChangeBounds changeBounds = new ChangeBounds(); getWindow().setSharedElementEnterTransition(changeBounds); } entity = (TransitionsEntity) getIntent().getSerializableExtra(KEY_ENTITY); KLog.d(entity); GlideUtils.displayImage(this, ivDetail, entity.getUrl(), R.drawable.def_placeholder); }
private void addNextFragment(Sample sample, ImageView squareBlue, boolean overlap) { SharedElementFragment2 sharedElementFragment2 = SharedElementFragment2.newInstance(sample); Slide slideTransition = new Slide(Gravity.RIGHT); slideTransition.setDuration(getResources().getInteger(R.integer.anim_duration_medium)); ChangeBounds changeBoundsTransition = new ChangeBounds(); changeBoundsTransition.setDuration(getResources().getInteger(R.integer.anim_duration_medium)); sharedElementFragment2.setEnterTransition(slideTransition); sharedElementFragment2.setAllowEnterTransitionOverlap(overlap); sharedElementFragment2.setAllowReturnTransitionOverlap(overlap); sharedElementFragment2.setSharedElementEnterTransition(changeBoundsTransition); getFragmentManager().beginTransaction() .replace(R.id.sample2_content, sharedElementFragment2) .addToBackStack(null) .addSharedElement(squareBlue, getString(R.string.square_blue_name)) .commit(); }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private ChangeBounds getNextButtonTransition() { ChangeBounds arcMoveTransition = new ChangeBounds(); //create "zorro" like path arcMoveTransition.setPathMotion(new PathMotion() { @Override public Path getPath(float startX, float startY, float endX, float endY) { Path p = new Path(); p.moveTo(startX, startY); p.lineTo(endX, startY); p.lineTo(startX, endY); p.lineTo(endX, endY); return p; } }); arcMoveTransition.setDuration(500); arcMoveTransition.setInterpolator(new AccelerateDecelerateInterpolator()); return arcMoveTransition; }
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 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; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); mSceneRoot = (ViewGroup) findViewById(R.id.scene_root); mScene1 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene1, this); mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.scene2, this); mTransition = new ChangeBounds(); mTransition.setDuration(DateUtils.SECOND_IN_MILLIS); mTransition.setInterpolator(new AccelerateDecelerateInterpolator()); TransitionManager.go(mScene1); mCurrentScene = mScene1; findViewById(R.id.button).setOnClickListener(this); }
@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 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; }
private void setPitchBarPosition(double frequency) { View pitchBar = (View)findViewById(R.id.tune_view_current_pitch); int margin = 20; double leftDP = NoteCalculator.getPitchBarPosition(frequency, 560); Transition moveTransition = new ChangeBounds(); moveTransition.setDuration(300); moveTransition.setInterpolator(new LinearInterpolator()); TransitionManager.beginDelayedTransition((ViewGroup) pitchBar.getRootView(), moveTransition); ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams)(pitchBar.getLayoutParams()); Log.d(TAG, String.format("Current: %d New: %f", params.leftMargin, leftDP)); params.setMargins((int)leftDP,0,0,0); pitchBar.setLayoutParams(params); }
@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 prepare(Fragment toFragment) { final Bundle transitionBundle = TransitionBundleFactory.createTransitionBundle(context, fromView, bitmap); if (Build.VERSION.SDK_INT >= 21) { toFragment.setSharedElementEnterTransition(new ChangeBounds()); toFragment.setSharedElementReturnTransition(new ChangeBounds()); } toFragment.setArguments(transitionBundle); }
public void prepare(android.support.v4.app.Fragment toFragment) { final Bundle transitionBundle = TransitionBundleFactory.createTransitionBundle(context, fromView, bitmap); if (Build.VERSION.SDK_INT >= 21) { toFragment.setSharedElementEnterTransition(new ChangeBounds()); toFragment.setSharedElementReturnTransition(new ChangeBounds()); } toFragment.setArguments(transitionBundle); }
@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; }
public DailyButtonTransition(int mode) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setOrdering(ORDERING_TOGETHER); addTransition(new ChangeBounds()); if (mode == MODE_ENTER) { setInterpolator(new DecelerateInterpolator()); setDuration(400); }else{ setInterpolator(new AccelerateInterpolator()); setDuration(240); } } }
private void setupLayout(Sample sample) { // Transition for fragment1 Slide slideTransition = new Slide(Gravity.LEFT); slideTransition.setDuration(getResources().getInteger(R.integer.anim_duration_long)); // Create fragment and define some of it transitions SharedElementFragment1 sharedElementFragment1 = SharedElementFragment1.newInstance(sample); sharedElementFragment1.setReenterTransition(slideTransition); sharedElementFragment1.setExitTransition(slideTransition); sharedElementFragment1.setSharedElementEnterTransition(new ChangeBounds()); getSupportFragmentManager().beginTransaction() .replace(R.id.sample2_content, sharedElementFragment1) .commit(); }
public FragmentSharedElementTransition() { addTransition(new ChangeBounds()); addTransition(new Fade()); addTransition(new ChangeImageTransform()); addTransition(new ChangeTransform()); setInterpolator(new FastOutSlowInInterpolator()); }
@TargetApi(TARGET_API) private Transition getDefaultTransition() { TransitionSet set = new TransitionSet(); set.addTransition(new ChangeBounds()); set.addTransition(new Fade()); set.addTransition(new ChangeImageTransform()); set.setInterpolator(new FastOutSlowInInterpolator()); return set; }
public ImageTransition() { setOrdering(ORDERING_TOGETHER); addTransition(new ChangeBounds()); addTransition(new ChangeTransform()); addTransition(new ChangeImageTransform()); setPathMotion(new ArcMotion()); }
static public LinkStoryFragment getInstance(Story story, boolean isExpanded) { LinkStoryFragment f = new LinkStoryFragment(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { f.setSharedElementEnterTransition(new ChangeTransform()); } f.setSharedElementEnterTransition(new ChangeBounds()); } Bundle bundle = new Bundle(); bundle.putBoolean("isExpanded", isExpanded); bundle.putParcelable("story", Parcels.wrap(story)); f.setArguments(bundle); return f; }
static public FileStoryFragment getInstance(Story story, boolean isExpanded) { FileStoryFragment f = new FileStoryFragment(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { f.setSharedElementEnterTransition(new ChangeTransform()); } f.setSharedElementEnterTransition(new ChangeBounds()); } Bundle bundle = new Bundle(); bundle.putBoolean("isExpanded", isExpanded); bundle.putParcelable("story", Parcels.wrap(story)); f.setArguments(bundle); return f; }
static public TopicStoryFragment getInstance(Story story, boolean isExpanded) { TopicStoryFragment f = new TopicStoryFragment(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { f.setSharedElementEnterTransition(new ChangeTransform()); } f.setSharedElementEnterTransition(new ChangeBounds()); } Bundle bundle = new Bundle(); bundle.putBoolean("isExpanded", isExpanded); bundle.putParcelable("story", Parcels.wrap(story)); f.setArguments(bundle); return f; }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void init() { setOrdering(ORDERING_TOGETHER); addTransition(new ChangeBounds()). addTransition(new ChangeTransform()). addTransition(new ChangeImageTransform()); super.addListener(this); }
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) public DetailsTransition() { setOrdering(ORDERING_TOGETHER); addTransition(new ChangeBounds()) .addTransition(new ChangeTransform()) .addTransition(new ChangeImageTransform()); }
/*********************************************************************************************** * * Lifecycle Methods * */ @Override @SuppressLint("NewApi") public void onCreate(Bundle savedInstanceState) { // Set window transition elements if(BuildUtils.isLollipop()) { getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS); TransitionSet transitions = new TransitionSet() .addTransition(new ChangeBounds()) .addTransition(new Fade()); getWindow().setEnterTransition(new Explode()); getWindow().setExitTransition(new Explode()); getWindow().setSharedElementEnterTransition(transitions); getWindow().setSharedElementExitTransition(transitions); } super.onCreate(savedInstanceState); setContentView(R.layout.activity_license); // Load UI mToolbar = ButterKnife.findById(this, R.id.appbar); mRecyler = ButterKnife.findById(this, R.id.recycler); // Set the toolbar as the support actionbar setSupportActionBar(mToolbar); parseExtras(savedInstanceState); // Set listeners getSupportActionBar().setDisplayHomeAsUpEnabled(true); mToolbar.setNavigationOnClickListener(this); mRecyler.setAdapter(mAdapter); mRecyler.setLayoutManager(new LinearLayoutManager(this)); mRecyler.setItemAnimator(new DefaultItemAnimator()); mRecyler.addItemDecoration(new StickyRecyclerHeadersElevationDecoration(mAdapter)); mAdapter.setOnItemClickListener(this); }
/*********************************************************************************************** * * Lifecycle Methods * */ @SuppressLint("NewApi") @Override protected void onCreate(Bundle savedInstanceState) { // Set window transition elements if(BuildUtils.isLollipop()) { getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS); TransitionSet transitions = new TransitionSet() .addTransition(new ChangeBounds()) .addTransition(new Fade()); getWindow().setEnterTransition(new Explode()); getWindow().setExitTransition(new Explode()); getWindow().setSharedElementEnterTransition(transitions); getWindow().setSharedElementExitTransition(transitions); } super.onCreate(savedInstanceState); overridePendingTransition(0, 0); setContentView(R.layout.activity_license_detail); // Inflate components mAppbar = ButterKnife.findById(this, R.id.appbar); mName = ButterKnife.findById(this, R.id.name); mAuthor = ButterKnife.findById(this, R.id.author); mLicense = ButterKnife.findById(this, R.id.license); // Apply components setSupportActionBar(mAppbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowTitleEnabled(false); mAppbar.setNavigationOnClickListener(this); // Parse extras parseExtras(savedInstanceState); }
private void addSharedElementTranstion(Fragment fragment) { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ChangeBounds changeBoundsTransition = new ChangeBounds(); changeBoundsTransition.setDuration(300); fragment.setSharedElementEnterTransition(changeBoundsTransition); } }
@Override public Object getAudioTransition() { final ChangeText tc = new ChangeText(); tc.setChangeBehavior(ChangeText.CHANGE_BEHAVIOR_OUT_IN); final TransitionSet inner = new TransitionSet(); inner.addTransition(tc).addTransition(new ChangeBounds()); final TransitionSet tg = new TransitionSet(); tg.addTransition(new Fade(Fade.OUT)).addTransition(inner). addTransition(new Fade(Fade.IN)); tg.setOrdering(TransitionSet.ORDERING_SEQUENTIAL); tg.setDuration(TRANSITION_DURATION); return tg; }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public static Transition makeSharedElementEnterTransition(Context context) { Transition changeBounds = new ChangeBounds(); changeBounds.addTarget(R.id.item_movie_cover); return changeBounds; }
public SharedElementTransition(Context context, AttributeSet attrs) { super(context, attrs); fabTransition = new CircleTransition(context, attrs); imageTransition = new ChangeImageTransform(context, attrs); defaultTransition = new ChangeBounds(context, attrs); fabTransitionName = context.getString(R.string.transition_fab); transitionProperties = initTransProps(); if (BuildConfig.DEBUG && TextUtils.isEmpty(fabTransitionName)) { throw new AssertionError("Transition name should not be empty"); } }
@Override protected Transition createTransition() { Transition transition = new ChangeBounds(); transition.setDuration(isOrigin ? 700 : 300); transition.setInterpolator(isOrigin ? new FastOutSlowInInterpolator() : new AccelerateDecelerateInterpolator()); transition.setStartDelay(isOrigin ? 0 : 500); return transition; }