use of com.transitionseverywhere.Transition in project Transitions-Everywhere by andkulikov.
the class Scale method createAnimation.
@Nullable
private Animator createAnimation(final View view, float startScale, float endScale, TransitionValues values) {
final float initialScaleX = view.getScaleX();
final float initialScaleY = view.getScaleY();
float startScaleX = initialScaleX * startScale;
float endScaleX = initialScaleX * endScale;
float startScaleY = initialScaleY * startScale;
float endScaleY = initialScaleY * endScale;
if (values != null) {
Float savedScaleX = (Float) values.values.get(PROPNAME_SCALE_X);
Float savedScaleY = (Float) values.values.get(PROPNAME_SCALE_Y);
// continue animation from the interrupted state
if (savedScaleX != null && savedScaleX != initialScaleX) {
startScaleX = savedScaleX;
}
if (savedScaleY != null && savedScaleY != initialScaleY) {
startScaleY = savedScaleY;
}
}
view.setScaleX(startScaleX);
view.setScaleY(startScaleY);
Animator animator = TransitionUtils.mergeAnimators(ObjectAnimator.ofFloat(view, View.SCALE_X, startScaleX, endScaleX), ObjectAnimator.ofFloat(view, View.SCALE_Y, startScaleY, endScaleY));
addListener(new TransitionListenerAdapter() {
@Override
public void onTransitionEnd(Transition transition) {
view.setScaleX(initialScaleX);
view.setScaleY(initialScaleY);
}
});
return animator;
}
use of com.transitionseverywhere.Transition in project Transitions-Everywhere by andkulikov.
the class ExplodeAndEpicenterExample method letsExplodeIt.
private void letsExplodeIt(View clickedView) {
// save rect of view in screen coordinated
final Rect viewRect = new Rect();
clickedView.getGlobalVisibleRect(viewRect);
TransitionSet set = new TransitionSet().addTransition(new Explode().setEpicenterCallback(new Transition.EpicenterCallback() {
@Override
public Rect onGetEpicenter(Transition transition) {
return viewRect;
}
}).excludeTarget(clickedView, true)).addTransition(new Fade().addTarget(clickedView)).addListener(new Transition.TransitionListenerAdapter() {
@Override
public void onTransitionEnd(Transition transition) {
getActivity().onBackPressed();
}
});
TransitionManager.beginDelayedTransition(mRecyclerView, set);
// remove all views from Recycler View
mRecyclerView.setAdapter(null);
}
use of com.transitionseverywhere.Transition in project Transitions-Everywhere by andkulikov.
the class InterpolatorDurationStartDelaySample method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_interpolator, container, false);
final ViewGroup transitionsContainer = (ViewGroup) view.findViewById(R.id.transitions_container);
final View button = transitionsContainer.findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
boolean mToRightAnimation;
@Override
public void onClick(View v) {
mToRightAnimation = !mToRightAnimation;
Transition transition = new ChangeBounds();
transition.setDuration(mToRightAnimation ? 700 : 300);
transition.setInterpolator(mToRightAnimation ? new FastOutSlowInInterpolator() : new AccelerateInterpolator());
transition.setStartDelay(mToRightAnimation ? 0 : 500);
TransitionManager.beginDelayedTransition(transitionsContainer, transition);
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) button.getLayoutParams();
params.gravity = mToRightAnimation ? (Gravity.RIGHT | Gravity.TOP) : (Gravity.LEFT | Gravity.TOP);
button.setLayoutParams(params);
}
});
return view;
}
use of com.transitionseverywhere.Transition in project Douya by DreaminginCodeZH.
the class NavigationHeaderLayout method beginAvatarTransition.
private void beginAvatarTransition(ImageView moveAvatarOneImage, ImageView moveAvatarTwoImage, ImageView moveAvatarThreeImage) {
ImageView appearAvatarImage = moveAvatarOneImage;
ImageView disappearAvatarImage = moveAvatarThreeImage != null ? moveAvatarThreeImage : moveAvatarTwoImage;
ImageView fadeOutDisappearAvatarImage = disappearAvatarImage == mAvatarImage ? mFadeOutAvatarImage : disappearAvatarImage == mRecentOneAvatarImage ? mFadeOutRecentOneAvatarImage : mFadeOutRecentTwoAvatarImage;
TransitionSet transitionSet = new TransitionSet();
int duration = ViewUtils.getLongAnimTime(getContext());
// Will be set on already added and newly added transitions.
transitionSet.setDuration(duration);
// NOTE: TransitionSet.setInterpolator() won't have any effect on platform versions.
// https://code.google.com/p/android/issues/detail?id=195495
transitionSet.setInterpolator(new FastOutSlowInInterpolator());
Fade fadeOutAvatar = new Fade(Fade.OUT);
setAvatarImageFrom(fadeOutDisappearAvatarImage, disappearAvatarImage);
fadeOutDisappearAvatarImage.setVisibility(VISIBLE);
fadeOutAvatar.addTarget(fadeOutDisappearAvatarImage);
transitionSet.addTransition(fadeOutAvatar);
// Make it finish before new avatar arrives.
fadeOutAvatar.setDuration(duration / 2);
Fade fadeInAvatar = new Fade(Fade.IN);
appearAvatarImage.setVisibility(INVISIBLE);
fadeInAvatar.addTarget(appearAvatarImage);
transitionSet.addTransition(fadeInAvatar);
ChangeTransform changeAppearAvatarTransform = new ChangeTransform();
appearAvatarImage.setScaleX(0.8f);
appearAvatarImage.setScaleY(0.8f);
changeAppearAvatarTransform.addTarget(appearAvatarImage);
transitionSet.addTransition(changeAppearAvatarTransform);
addChangeMoveToAvatarTransformToTransitionSet(moveAvatarOneImage, moveAvatarTwoImage, transitionSet);
if (moveAvatarThreeImage != null) {
addChangeMoveToAvatarTransformToTransitionSet(moveAvatarTwoImage, moveAvatarThreeImage, transitionSet);
}
CrossfadeText crossfadeText = new CrossfadeText();
crossfadeText.addTarget(mNameText);
crossfadeText.addTarget(mDescriptionText);
transitionSet.addTransition(crossfadeText);
transitionSet.addListener(new Transition.TransitionListenerAdapter() {
@Override
public void onTransitionEnd(Transition transition) {
mAccountTransitionRunning = false;
mInfoLayout.setEnabled(true);
if (mListener != null) {
mListener.onAccountTransitionEnd();
}
}
});
mInfoLayout.setEnabled(false);
TransitionManager.beginDelayedTransition(this, transitionSet);
mAccountTransitionRunning = true;
if (mListener != null) {
mListener.onAccountTransitionStart();
}
fadeOutDisappearAvatarImage.setVisibility(INVISIBLE);
appearAvatarImage.setVisibility(VISIBLE);
appearAvatarImage.setScaleX(1);
appearAvatarImage.setScaleY(1);
resetMoveToAvatarTransform(moveAvatarTwoImage);
if (moveAvatarThreeImage != null) {
resetMoveToAvatarTransform(moveAvatarThreeImage);
}
}
Aggregations