android.transition.TransitionValues Java Examples

The following examples show how to use android.transition.TransitionValues. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StartAnimatable.java    From android-proguards with Apache License 2.0 6 votes vote down vote up
@Override
public Animator createAnimator(ViewGroup sceneRoot,
                               TransitionValues startValues,
                               TransitionValues endValues) {
    if (animatable == null || endValues == null
            || !(endValues.view instanceof ImageView)) return null;

    ImageView iv = (ImageView) endValues.view;
    iv.setImageDrawable((Drawable) animatable);

    // need to return a non-null Animator even though we just want to listen for the start
    ValueAnimator transition = ValueAnimator.ofInt(0, 1);
    transition.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            animatable.start();
        }
    });
    return transition;
}
 
Example #2
Source File: ElevationTransition.java    From Cinema-App-Concept with MIT License 6 votes vote down vote up
@Override
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {
    if (startValues == null || endValues == null) {
        return null;
    }

    Float startVal = (Float) startValues.values.get(PROPNAME_ELEVATION);
    Float endVal = (Float) endValues.values.get(PROPNAME_ELEVATION);
    if (startVal == null || endVal == null || startVal.floatValue() == endVal.floatValue()) {
        return null;
    }

    final View view = endValues.view;
    ValueAnimator a = ValueAnimator.ofFloat(startVal, endVal);
    a.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            view.setElevation((float)animation.getAnimatedValue());
        }
    });

    return a;
}
 
Example #3
Source File: VerticalGateTransition.java    From PainlessMusicPlayer with Apache License 2.0 6 votes vote down vote up
@Override
public Animator createAnimator(final ViewGroup sceneRoot, final TransitionValues startValues,
        final TransitionValues endValues) {
    final Collection<Animator> animators = new ArrayList<>(2);
    final View upperView = sceneRoot.findViewById(mUpperViewId);
    if (upperView != null) {
        animators.add(ObjectAnimator.ofFloat(upperView,
                ViewProperties.TRANSLATION_Y, 0, -upperView.getHeight()));
    }

    final View bottomView = sceneRoot.findViewById(mBottomViewId);
    if (bottomView != null) {
        final View bottomViewParent = (View) bottomView.getParent();
        if (bottomView.getHeight() <= bottomViewParent.getHeight()) {
            animators.add(ObjectAnimator.ofFloat(bottomView, ViewProperties.TRANSLATION_Y,
                    0, bottomViewParent.getHeight() - bottomView.getTop()));
        } else {
            animators.add(ObjectAnimator.ofFloat(bottomView, ViewProperties.TRANSLATION_Y,
                    0, bottomView.getHeight()));
        }
    }

    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(animators);
    return animatorSet;
}
 
Example #4
Source File: AdvancedDraweeTransition.java    From YcShareElement with Apache License 2.0 5 votes vote down vote up
@Override
public void captureEndValues(TransitionValues transitionValues) {
    captureValues(transitionValues);
    if (transitionValues.view instanceof GenericDraweeView) {
        ShareElementInfo shareElementInfo = ShareElementInfo.getFromView(transitionValues.view);
        if (shareElementInfo != null && shareElementInfo.getViewStateSaver() instanceof FrescoViewStateSaver) {
            Bundle viewInfo = shareElementInfo.isEnter() ? shareElementInfo.getToViewBundle() : shareElementInfo.getFromViewBundle();
            mToScale = ((FrescoViewStateSaver) shareElementInfo.getViewStateSaver()).getScaleType(viewInfo);
        }
    }
}
 
Example #5
Source File: DeparallaxingChangeBounds.java    From android-proguards with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #6
Source File: CustomChangeBounds.java    From HHComicViewer with Apache License 2.0 5 votes vote down vote up
@Override
    public Animator createAnimator(final ViewGroup sceneRoot,
                                   TransitionValues startValues,
                                   final TransitionValues endValues) {

        Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues);
        if (startValues == null || endValues == null || changeBounds == null)
            return null;

//        if (endValues.view instanceof ViewGroup) {
//            ViewGroup vg = (ViewGroup) endValues.view;
//            float offset = vg.getHeight() / 3;
//            for (int i = 0; i < vg.getChildCount(); i++) {
//                View v = vg.getChildAt(i);
//                v.setTranslationY(offset);
//                v.setAlpha(0f);
//                v.animate()
//                        .alpha(1f)
//                        .translationY(0f)
//                        .setDuration(150)
//                        .setStartDelay(150)
//                        .setInterpolator(AnimationUtils.loadInterpolator(vg.getContext(),
//                                android.R.interpolator.fast_out_slow_in));
//                offset *= 1.8f;
//            }
//        }

        changeBounds.setDuration(500);
        changeBounds.setInterpolator(AnimationUtils.loadInterpolator(sceneRoot.getContext(),
                android.R.interpolator.fast_out_slow_in));
        return changeBounds;
    }
 
Example #7
Source File: ShotSharedEnter.java    From materialup with Apache License 2.0 5 votes vote down vote up
@Override
public void captureEndValues(TransitionValues transitionValues) {
    super.captureEndValues(transitionValues);
    int width = ((View) transitionValues.values.get(PROPNAME_PARENT)).getWidth();
    Rect bounds = (Rect) transitionValues.values.get(PROPNAME_BOUNDS);
    bounds.right = width;
    bounds.bottom = width * 3 / 4;
    transitionValues.values.put(PROPNAME_BOUNDS, bounds);
}
 
Example #8
Source File: StoryTitleSharedEnter.java    From materialup with Apache License 2.0 5 votes vote down vote up
@Override
public void captureEndValues(TransitionValues transitionValues) {
    super.captureEndValues(transitionValues);
    Rect bounds = (Rect) transitionValues.values.get(PROPNAME_BOUNDS);
    bounds.right = ((View) transitionValues.values.get(PROPNAME_PARENT)).getWidth();
    bounds.bottom = ((View) transitionValues.values.get(PROPNAME_PARENT)).getHeight();
    transitionValues.values.put(PROPNAME_BOUNDS, bounds);
}
 
Example #9
Source File: Recolor.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void captureValues(TransitionValues transitionValues) {
    if (isStart(transitionValues.view)) {
        int initColor = getBackgroundColor(transitionValues.view);
        Bundle b = getExtraPropertiesFromView(transitionValues.view);
        if (b != null && b.containsKey(PROPNAME_COLOR)) {
            initColor = b.getInt(PROPNAME_COLOR);
        }
        transitionValues.values.put(PROPNAME_COLOR, initColor);
    } else {
        transitionValues.values.put(PROPNAME_COLOR, getBackgroundColor(transitionValues.view));
    }
}
 
Example #10
Source File: CoverTransition2.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void captureEndValues(TransitionValues transitionValues) {
    super.captureEndValues(transitionValues);
    int[] size = DisplayUtils.getScreenSize(context);
    Rect bounds = (Rect) transitionValues.values.get(PROPNAME_BOUNDS);
    if (bounds != null) {
        bounds.left = 0;
        bounds.top = 0;
        bounds.right = size[0];
        bounds.bottom = size[1];
        transitionValues.values.put(PROPNAME_BOUNDS, bounds);
    }
}
 
Example #11
Source File: AdvancedDraweeTransition.java    From YcShareElement with Apache License 2.0 5 votes vote down vote up
@Override
public void captureStartValues(TransitionValues transitionValues) {
    captureValues(transitionValues);
    if (transitionValues.view instanceof GenericDraweeView) {
        ShareElementInfo shareElementInfo = ShareElementInfo.getFromView(transitionValues.view);
        if (shareElementInfo != null && shareElementInfo.getViewStateSaver() instanceof FrescoViewStateSaver) {
            Bundle viewInfo = shareElementInfo.isEnter() ? shareElementInfo.getFromViewBundle() : shareElementInfo.getToViewBundle();
            mFromScale = ((FrescoViewStateSaver) shareElementInfo.getViewStateSaver()).getScaleType(viewInfo);
        }
    }
}
 
Example #12
Source File: DeparallaxingChangeBounds.java    From android-proguards with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #13
Source File: FabTransform.java    From android-proguards with Apache License 2.0 5 votes vote down vote up
private void captureValues(TransitionValues transitionValues) {
    final View view = transitionValues.view;
    if (view == null || view.getWidth() <= 0 || view.getHeight() <= 0) return;

    transitionValues.values.put(PROP_BOUNDS, new Rect(view.getLeft(), view.getTop(),
            view.getRight(), view.getBottom()));
}
 
Example #14
Source File: CustomChangeBounds.java    From CloudReader with Apache License 2.0 5 votes vote down vote up
@Override
    public Animator createAnimator(final ViewGroup sceneRoot,
                                   TransitionValues startValues,
                                   final TransitionValues endValues) {

        Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues);
        if (startValues == null || endValues == null || changeBounds == null) {
            return null;
        }

//        if (endValues.view instanceof ViewGroup) {
//            ViewGroup vg = (ViewGroup) endValues.view;
//            float offset = vg.getHeight() / 3;
//            for (int i = 0; i < vg.getChildCount(); i++) {
//                View v = vg.getChildAt(i);
//                v.setTranslationY(offset);
//                v.setAlpha(0f);
//                v.animate()
//                        .alpha(1f)
//                        .translationY(0f)
//                        .setDuration(150)
//                        .setStartDelay(150)
//                        .setInterpolator(AnimationUtils.loadInterpolator(vg.getContext(),
//                                android.R.interpolator.fast_out_slow_in));
//                offset *= 1.8f;
//            }
//        }

        changeBounds.setDuration(500);
        changeBounds.setInterpolator(AnimationUtils.loadInterpolator(sceneRoot.getContext(),
                android.R.interpolator.fast_out_slow_in));
        return changeBounds;
    }
 
Example #15
Source File: ChangeTextTransition.java    From YcShareElement with Apache License 2.0 5 votes vote down vote up
@Override
public void captureEndValues(TransitionValues transitionValues) {
    ShareElementInfo info = ShareElementInfo.getFromView(transitionValues.view);
    if (info == null || !(info.getViewStateSaver() instanceof TextViewStateSaver)) {
        return;
    }
    captureValues(transitionValues, (TextViewStateSaver) info.getViewStateSaver(), info.isEnter() ? info.getToViewBundle() : info.getFromViewBundle());
}
 
Example #16
Source File: CoverChangeBound.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void captureEndValues(TransitionValues transitionValues) {
    super.captureEndValues(transitionValues);
    int[] size = DisplayUtils.getScreenSize(context);
    Rect bounds = (Rect) transitionValues.values.get(PROPNAME_BOUNDS);
    if (bounds != null) {
        bounds.left = 0;
        bounds.top = 0;
        bounds.right = size[0];
        bounds.bottom = size[1];
        transitionValues.values.put(PROPNAME_BOUNDS, bounds);
    }
}
 
Example #17
Source File: ReflowText.java    From android-proguards with Apache License 2.0 5 votes vote down vote up
private void captureValues(TransitionValues transitionValues) {
    ReflowData reflowData = getReflowData(transitionValues.view);
    transitionValues.values.put(PROPNAME_DATA, reflowData);
    if (reflowData != null) {
        // add these props to the map separately (even though they are captured in the reflow
        // data) to use only them to determine whether to create an animation i.e. only
        // animate if text size or bounds have changed (see #getTransitionProperties())
        transitionValues.values.put(PROPNAME_TEXT_SIZE, reflowData.textSize);
        transitionValues.values.put(PROPNAME_BOUNDS, reflowData.bounds);
    }
}
 
Example #18
Source File: Pop.java    From Interessant with Apache License 2.0 5 votes vote down vote up
@Override
public Animator onAppear(ViewGroup sceneRoot, View view, TransitionValues startValues,
                         TransitionValues endValues) {
    view.setAlpha(0f);
    view.setScaleX(0f);
    view.setScaleY(0f);
    return ObjectAnimator.ofPropertyValuesHolder(
            view,
            PropertyValuesHolder.ofFloat(View.ALPHA, 1f),
            PropertyValuesHolder.ofFloat(View.SCALE_X, 1f),
            PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f));
}
 
Example #19
Source File: LiftOff.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues,
                               TransitionValues endValues) {
    if (startValues == null || endValues == null) {
        return null;
    }

    return ObjectAnimator.ofFloat(
            endValues.view,
            View.TRANSLATION_Z,
            (Float) startValues.values.get(PROPNAME_ELEVATION),
            (Float) endValues.values.get(PROPNAME_ELEVATION)
    );
}
 
Example #20
Source File: Pop.java    From android-proguards with Apache License 2.0 5 votes vote down vote up
@Override
public Animator onAppear(ViewGroup sceneRoot, View view, TransitionValues startValues,
                         TransitionValues endValues) {
    view.setAlpha(0f);
    view.setScaleX(0f);
    view.setScaleY(0f);
    return ObjectAnimator.ofPropertyValuesHolder(
            view,
            PropertyValuesHolder.ofFloat(View.ALPHA, 1f),
            PropertyValuesHolder.ofFloat(View.SCALE_X, 1f),
            PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f));
}
 
Example #21
Source File: CircularRevealTransition.java    From CrazyDaily with Apache License 2.0 5 votes vote down vote up
@Override
public void captureStartValues(TransitionValues transitionValues) {
    super.captureStartValues(transitionValues);
    transitionValues.values.put(PROPNAME_ALPHA, 0.2f);
    final View view = transitionValues.view;
    transitionValues.values.put(PROPNAME_RADIUS, 0);
    transitionValues.values.put(PROPNAME_TRANSLATION_Y, -view.getBottom());
}
 
Example #22
Source File: TextResizeTransition.java    From android-topeka with Apache License 2.0 5 votes vote down vote up
@Override
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues,
                               TransitionValues endValues) {
    if (startValues == null || endValues == null) {
        return null;
    }

    float initialTextSize = (float) startValues.values.get(PROPERTY_NAME_TEXT_RESIZE);
    float targetTextSize = (float) endValues.values.get(PROPERTY_NAME_TEXT_RESIZE);
    TextView targetView = (TextView) endValues.view;
    targetView.setTextSize(TypedValue.COMPLEX_UNIT_PX, initialTextSize);

    int initialPaddingStart = (int) startValues.values.get(PROPERTY_NAME_PADDING_RESIZE);
    int targetPaddingStart = (int) endValues.values.get(PROPERTY_NAME_PADDING_RESIZE);

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(
            ObjectAnimator.ofFloat(targetView,
                    ViewUtils.PROPERTY_TEXT_SIZE,
                    initialTextSize,
                    targetTextSize),
            ObjectAnimator.ofInt(targetView,
                    ViewUtils.PROPERTY_TEXT_PADDING_START,
                    initialPaddingStart,
                    targetPaddingStart));
    return animatorSet;
}
 
Example #23
Source File: CircularReveal.java    From android-proguards with Apache License 2.0 5 votes vote down vote up
@Override
public Animator onDisappear(ViewGroup sceneRoot, View view,
                            TransitionValues startValues,
                            TransitionValues endValues) {
    if (view == null || view.getHeight() == 0 || view.getWidth() == 0) return null;
    ensureCenterPoint(sceneRoot, view);
    return new AnimUtils.NoPauseAnimator(ViewAnimationUtils.createCircularReveal(
            view,
            center.x,
            center.y,
            getFullyRevealedRadius(view),
            endRadius));
}
 
Example #24
Source File: MorphDialogToFab.java    From android-proguards with Apache License 2.0 5 votes vote down vote up
@Override
public void captureEndValues(TransitionValues transitionValues) {
    super.captureEndValues(transitionValues);
    final View view = transitionValues.view;
    if (view.getWidth() <= 0 || view.getHeight() <= 0) {
        return;
    }
    transitionValues.values.put(PROPERTY_COLOR, endColor);
    transitionValues.values.put(PROPERTY_CORNER_RADIUS,
            endCornerRadius >= 0 ? endCornerRadius : view.getHeight() / 2);
}
 
Example #25
Source File: BackgroundFade.java    From android-proguards with Apache License 2.0 5 votes vote down vote up
@Override
public Animator onAppear(ViewGroup sceneRoot, View view,
                         TransitionValues startValues, TransitionValues endValues) {
    if (view == null || view.getBackground() == null) return null;
    Drawable background = view.getBackground();
    background.setAlpha(0);
    return ObjectAnimator.ofInt(background, ViewUtils.DRAWABLE_ALPHA, 0, 255);
}
 
Example #26
Source File: RoundCornerTransition.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void captureValues(TransitionValues transitionValues) {
    if (isStart(transitionValues.view)) {
        float actualInitRadius = getRadius(transitionValues.view);
        Bundle b = getExtraPropertiesFromView(transitionValues.view);
        if (b != null && b.containsKey(PROPNAME_RADIUS)) {
            actualInitRadius = b.getFloat(PROPNAME_RADIUS);
        }
        transitionValues.values.put(PROPNAME_RADIUS, actualInitRadius);
    } else {
        transitionValues.values.put(PROPNAME_RADIUS, getRadius(transitionValues.view));
    }
}
 
Example #27
Source File: CircularReveal.java    From Melophile with Apache License 2.0 5 votes vote down vote up
@Override
public Animator onAppear(ViewGroup sceneRoot, View view,
                         TransitionValues startValues,
                         TransitionValues endValues) {
  if (view == null || view.getHeight() == 0 || view.getWidth() == 0) return null;
  ensureCenterPoint(sceneRoot, view);
  return new PauseLessAnimator(ViewAnimationUtils.createCircularReveal(
          view,
          center.x,
          center.y,
          startRadius,
          getFullyRevealedRadius(view)));
}
 
Example #28
Source File: Hold.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
public Animator onDisappear(
    @NonNull ViewGroup sceneRoot,
    @NonNull View view,
    @Nullable TransitionValues startValues,
    @Nullable TransitionValues endValues) {
  return ValueAnimator.ofFloat(0);
}
 
Example #29
Source File: Pop.java    From Melophile with Apache License 2.0 5 votes vote down vote up
@Override
public Animator onAppear(ViewGroup sceneRoot, View view, TransitionValues startValues,
                         TransitionValues endValues) {
  view.setAlpha(0f);
  view.setScaleX(0f);
  view.setScaleY(0f);
  return ObjectAnimator.ofPropertyValuesHolder(
          view,
          PropertyValuesHolder.ofFloat(View.ALPHA, 1f),
          PropertyValuesHolder.ofFloat(View.SCALE_X, 1f),
          PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f));
}
 
Example #30
Source File: DeparallaxingChangeBounds.java    From Melophile with Apache License 2.0 5 votes vote down vote up
@Override
public void captureEndValues(TransitionValues transitionValues) {
  super.captureEndValues(transitionValues);
  if (!(transitionValues.view instanceof ParallaxRatioImageView)) return;
  ParallaxRatioImageView psv = ((ParallaxRatioImageView) 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);
}