Search in sources :

Example 1 with ParallaxScrimageView

use of io.plaidapp.ui.widget.ParallaxScrimageView in project plaid by nickbutcher.

the class DeparallaxingChangeBounds method captureEndValues.

@Override
public void captureEndValues(TransitionValues transitionValues) {
    super.captureEndValues(transitionValues);
    if (!(transitionValues.view instanceof ParallaxScrimageView))
        return;
    ParallaxScrimageView psv = ((ParallaxScrimageView) transitionValues.view);
    if (psv.getOffset() == 0)
        return;
    // as we're going to remove the offset (which drives the parallax) we need to
    // compensate for this by adjusting the target bounds.
    Rect bounds = (Rect) transitionValues.values.get(PROPNAME_BOUNDS);
    bounds.offset(0, psv.getOffset());
    transitionValues.values.put(PROPNAME_BOUNDS, bounds);
}
Also used : Rect(android.graphics.Rect) ParallaxScrimageView(io.plaidapp.ui.widget.ParallaxScrimageView)

Example 2 with ParallaxScrimageView

use of io.plaidapp.ui.widget.ParallaxScrimageView in project plaid by nickbutcher.

the class DeparallaxingChangeBounds method createAnimator.

@Override
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {
    Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues);
    if (startValues == null || endValues == null || !(endValues.view instanceof ParallaxScrimageView))
        return changeBounds;
    ParallaxScrimageView psv = ((ParallaxScrimageView) endValues.view);
    if (psv.getOffset() == 0)
        return changeBounds;
    Animator deparallax = ObjectAnimator.ofInt(psv, ParallaxScrimageView.OFFSET, 0);
    AnimatorSet transition = new AnimatorSet();
    transition.playTogether(changeBounds, deparallax);
    return transition;
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ParallaxScrimageView(io.plaidapp.ui.widget.ParallaxScrimageView) AnimatorSet(android.animation.AnimatorSet)

Aggregations

ParallaxScrimageView (io.plaidapp.ui.widget.ParallaxScrimageView)2 Animator (android.animation.Animator)1 AnimatorSet (android.animation.AnimatorSet)1 ObjectAnimator (android.animation.ObjectAnimator)1 Rect (android.graphics.Rect)1