use of android.transition.Transition in project Shuttle by timusus.
the class MainActivity method swapFragments.
public void swapFragments(Serializable item, View transitionView) {
String transitionName = ViewCompat.getTransitionName(transitionView);
DetailFragment detailFragment = DetailFragment.newInstance(item, transitionName);
if (ShuttleUtils.hasLollipop()) {
Transition moveTransition = TransitionInflater.from(this).inflateTransition(R.transition.image_transition);
detailFragment.setSharedElementEnterTransition(moveTransition);
detailFragment.setEnterTransition(new Fade());
getCurrentFragment().setExitTransition(new Fade());
}
getSupportFragmentManager().beginTransaction().addSharedElement(transitionView, transitionName).replace(R.id.main_container, detailFragment).addToBackStack(null).commit();
}
use of android.transition.Transition in project Rutgers-Course-Tracker by tevjef.
the class SubjectFragment method startCourseFragement.
private void startCourseFragement(Bundle b) {
CourseFragment courseFragment = new CourseFragment();
courseFragment.setArguments(b);
FragmentTransaction ft = getFragmentManager().beginTransaction();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Transition sfTransition = TransitionInflater.from(getParentActivity()).inflateTransition(R.transition.sf_exit);
setExitTransition(sfTransition.excludeTarget(Toolbar.class, true));
courseFragment.setAllowEnterTransitionOverlap(false);
} else {
ft.setCustomAnimations(R.anim.enter, R.anim.exit, R.anim.pop_enter, R.anim.pop_exit);
}
startFragment(this, courseFragment, ft);
}
use of android.transition.Transition in project Rutgers-Course-Tracker by tevjef.
the class CourseInfoFragment method startSectionInfoFragment.
private void startSectionInfoFragment(Bundle b, View clickedView) {
SectionInfoFragment sectionInfoFragment = new SectionInfoFragment();
FragmentTransaction ft = this.getFragmentManager().beginTransaction();
CircleView circleView = ButterKnife.findById(clickedView, R.id.section_number_background);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
circleView.setTransitionName(getString(R.string.transition_name_circle_view));
ft.addSharedElement(circleView, getString(R.string.transition_name_circle_view));
mAppBarLayout.setTransitionName(null);
Transition cifSectionEnter = TransitionInflater.from(getParentActivity()).inflateTransition(R.transition.cif_section_enter);
Transition cifSectionReturn = TransitionInflater.from(getParentActivity()).inflateTransition(R.transition.cif_section_return);
sectionInfoFragment.setEnterTransition(cifSectionEnter);
sectionInfoFragment.setReturnTransition(cifSectionReturn);
setReenterTransition(new Fade(Fade.IN).setDuration(200));
Transition cifExit = TransitionInflater.from(getParentActivity()).inflateTransition(R.transition.cif_exit);
setExitTransition(cifExit);
sectionInfoFragment.setAllowReturnTransitionOverlap(false);
sectionInfoFragment.setAllowEnterTransitionOverlap(false);
Transition sharedElementsEnter = TransitionInflater.from(getParentActivity()).inflateTransition(R.transition.cif_shared_element_enter);
Transition sharedElementsReturn = TransitionInflater.from(getParentActivity()).inflateTransition(R.transition.cif_shared_element_return);
sectionInfoFragment.setSharedElementEnterTransition(sharedElementsEnter);
sectionInfoFragment.setSharedElementReturnTransition(sharedElementsReturn);
CircleSharedElementCallback sharedelementCallback = new CircleSharedElementCallback();
sectionInfoFragment.setEnterSharedElementCallback(sharedelementCallback);
sharedElementsEnter.addListener(sharedelementCallback.getTransitionCallback());
} else {
ft.setCustomAnimations(R.anim.enter, R.anim.exit, R.anim.pop_enter, R.anim.pop_exit);
}
sectionInfoFragment.setArguments(b);
startFragment(this, sectionInfoFragment, ft);
}
use of android.transition.Transition in project Shuttle by timusus.
the class DetailFragment method getSharedElementEnterTransitionListenerAdapter.
private TransitionListenerAdapter getSharedElementEnterTransitionListenerAdapter() {
if (ShuttleUtils.hasLollipop()) {
return new TransitionListenerAdapter() {
@Override
public void onTransitionEnd(Transition transition) {
if (ShuttleUtils.hasLollipop()) {
//Todo:
//This is a partial fix for an issue where the initial artwork load tricks Glide into thinking the final
//image in the transition has the dimensions of the initial image.
//The idea is we would call this to force Glide to load a full res image, and we wouldn't need to use the
//override call in our initial Glide load in onCreateView.
//Unfortunately, because the initial image is square, but our header image is not, the transition isn't very nice..
//So for now, we'll stick with overriding the initial image dimensions..
// if (isAdded()) {
// requestManager
// .load(albumArtist == null ? album : albumArtist)
// .diskCacheStrategy(DiskCacheStrategy.SOURCE)
// .priority(Priority.HIGH)
// .centerCrop()
// .thumbnail(Glide
// .with(DetailFragment.this)
// .load(albumArtist == null ? album : albumArtist)
// .override(headerImageView.getDrawable().getIntrinsicWidth(), headerImageView.getDrawable().getIntrinsicHeight())
// .centerCrop())
// .animate(new AlwaysCrossFade(false))
// .into(headerImageView);
// }
transition.removeListener(this);
//Fade in the text protection scrim
textProtectionScrim.setAlpha(0f);
textProtectionScrim.setVisibility(View.VISIBLE);
ObjectAnimator fadeAnimator = ObjectAnimator.ofFloat(textProtectionScrim, View.ALPHA, 0f, 1f);
fadeAnimator.setDuration(800);
fadeAnimator.start();
//Fade & grow the FAB
fab.setAlpha(0f);
fab.setVisibility(View.VISIBLE);
fadeAnimator = ObjectAnimator.ofFloat(fab, View.ALPHA, 0.5f, 1f);
ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(fab, View.SCALE_X, 0f, 1f);
ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(fab, View.SCALE_Y, 0f, 1f);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.setInterpolator(new OvershootInterpolator(2f));
animatorSet.playTogether(fadeAnimator, scaleXAnimator, scaleYAnimator);
animatorSet.setDuration(250);
animatorSet.start();
}
}
};
}
return null;
}
use of android.transition.Transition in project Conductor by bluelinelabs.
the class FabToDialogTransitionChangeHandler method executePropertyChanges.
@Override
public void executePropertyChanges(@NonNull ViewGroup container, @Nullable View from, @Nullable View to, @NonNull Transition transition, boolean isPush) {
if (isPush) {
fabParent.removeView(fab);
container.addView(to);
/*
* After the transition is finished we have to add the fab back to the original container.
* Because otherwise we will be lost when trying to transition back.
* Set it to invisible because we don't want it to jump back after the transition
*/
transition.addListener(new AnimUtils.TransitionEndListener() {
@Override
public void onTransitionCompleted(Transition transition) {
fab.setVisibility(View.GONE);
fabParent.addView(fab);
fab = null;
fabParent = null;
}
});
} else {
dialogBackground.setVisibility(View.INVISIBLE);
fabParent.addView(fab);
container.removeView(from);
transition.addListener(new TransitionEndListener() {
@Override
public void onTransitionCompleted(Transition transition) {
fabParent.removeView(dialogBackground);
dialogBackground = null;
}
});
}
}
Aggregations