use of android.transitions.everywhere.Transition in project TransitionPlayer by linfaxin.
the class ChromeHomeDemo method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.demo_chrome_home);
swipeLayout = (SwipeLayout) findViewById(R.id.swipeLayout);
swipeLayout.getDragEdgeMap().clear();
swipeLayout.addDrag(SwipeLayout.DragEdge.Top, swipeLayout.getChildAt(0));
swipeLayout.addRevealListener(R.id.placeHolder, new SwipeLayout.OnRevealListener() {
@Override
public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int distance) {
transitionPlayer.setCurrentFraction(fraction);
}
});
swipeLayout.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
swipeLayout.getViewTreeObserver().removeOnPreDrawListener(this);
ViewGroup mSceneRoot = (ViewGroup) findViewById(R.id.sceneRootView);
Scene scene = Scene.getSceneForLayout(mSceneRoot, R.layout.chrome_home_head_state_expand, ChromeHomeDemo.this);
transitionPlayer.setPlayControl(new ModifyAnimatorsPlayControl() {
@Override
protected Animator onModifyAnimator(Transition transition, ValueAnimator animator) {
if (!(animator instanceof ObjectAnimator))
return animator;
Object target = ((ObjectAnimator) animator).getTarget();
if (!(target instanceof View))
return animator;
View targetView = (View) target;
// input view
if (targetView.getId() == R.id.editText) {
if (transition instanceof ChangeBounds) {
AnimatorSet animatorSet = new AnimatorSet();
for (ValueAnimator subAnimator : AnimatorUtils.splitAnimatorByValues(animator)) {
animatorSet.playTogether(subAnimator);
// let input view fast animate to right edge
if (subAnimator instanceof ObjectAnimator && "right".equals(((ObjectAnimator) subAnimator).getPropertyName())) {
MultiTimeInterpolator multi = new MultiTimeInterpolator();
TimeInterpolator i = animator.getInterpolator();
multi.addInterpolator(i, 6);
LockEndTimeInterpolator end = new LockEndTimeInterpolator(i);
multi.addInterpolator(end, 4);
subAnimator.setInterpolator(multi);
}
}
return animatorSet;
} else if (transition instanceof ChangeTextColor) {
TimeInterpolator i = animator.getInterpolator();
LockEndTimeInterpolator end = new LockEndTimeInterpolator(i);
ReverseTimeInterpolator r = new ReverseTimeInterpolator(i);
animator.setInterpolator(new MultiTimeInterpolator(i, end, r));
}
}
// logo view
if (targetView.getId() == R.id.imageView && transition instanceof ChangeAlpha) {
MultiTimeInterpolator multi = new MultiTimeInterpolator();
TimeInterpolator i = new DecelerateInterpolator(1.6f);
TimeInterpolator start = new LockStartTimeInterpolator(i);
multi.addInterpolator(start, 4);
multi.addInterpolator(i, 6);
animator.setInterpolator(multi);
}
return animator;
}
});
TransitionManager.go(scene, transitionPlayer);
// after start transition, then init click.
mSceneRoot.findViewById(R.id.editText).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
swipeLayout.close();
}
});
return false;
}
});
}
use of android.transitions.everywhere.Transition in project TransitionPlayer by linfaxin.
the class TransitionPlayer method runAnimators.
@Override
protected void runAnimators() {
reflectSetupStartEndListeners();
animMap.clear();
for (int i = 0, count = getTransitionCount(); i < count; i++) {
Transition transition = getTransitionAt(i);
ArrayList<ValueAnimator> valueAnimators = new ArrayList<>();
for (Animator animator : AnimatorUtils.collectAnimators(transition)) {
valueAnimators.addAll(AnimatorUtils.collectValueAnimators(animator));
}
// insure animator's duration, startDelay, Interpolator same as this transition
long duration = (long) (getDuration() / AnimatorUtils.getAnimatorDurationScale());
long startDelay = getStartDelay();
TimeInterpolator interpolator = getInterpolator();
for (ValueAnimator animator : valueAnimators) {
if (duration >= 0)
animator.setDuration(duration);
if (startDelay >= 0)
animator.setStartDelay(startDelay + animator.getStartDelay());
if (interpolator != null)
animator.setInterpolator(interpolator);
}
animMap.put(transition, valueAnimators);
// you can change transition's duration, startDelay and Interpolator at here
if (playControl != null)
playControl.onPreRunAnimator(transition, valueAnimators);
}
}
Aggregations