Search in sources :

Example 36 with ObjectAnimator

use of android.animation.ObjectAnimator in project weiciyuan by qii.

the class ContainerFragment method displayPicture.

private void displayPicture(String path, boolean animateIn) {
    GalleryAnimationActivity activity = (GalleryAnimationActivity) getActivity();
    AnimationRect rect = getArguments().getParcelable("rect");
    boolean firstOpenPage = getArguments().getBoolean("firstOpenPage");
    if (firstOpenPage) {
        if (animateIn) {
            ObjectAnimator animator = activity.showBackgroundAnimate();
            animator.start();
        } else {
            activity.showBackgroundImmediately();
        }
        getArguments().putBoolean("firstOpenPage", false);
    }
    if (!ImageUtility.isThisBitmapTooLargeToRead(path)) {
        Fragment fragment = null;
        if (ImageUtility.isThisPictureGif(path)) {
            fragment = GifPictureFragment.newInstance(path, rect, animateIn);
        } else {
            fragment = GeneralPictureFragment.newInstance(path, rect, animateIn);
        }
        getChildFragmentManager().beginTransaction().replace(R.id.child, fragment).commitAllowingStateLoss();
    } else {
        LargePictureFragment fragment = LargePictureFragment.newInstance(path, animateIn);
        getChildFragmentManager().beginTransaction().replace(R.id.child, fragment).commitAllowingStateLoss();
    }
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) AnimationRect(org.qii.weiciyuan.support.lib.AnimationRect) Fragment(android.support.v4.app.Fragment)

Example 37 with ObjectAnimator

use of android.animation.ObjectAnimator in project weiciyuan by qii.

the class GalleryAnimationActivity method onBackPressed.

@Override
public void onBackPressed() {
    ContainerFragment fragment = fragmentMap.get(pager.getCurrentItem());
    if (fragment != null && fragment.canAnimateCloseActivity()) {
        backgroundColor = new ColorDrawable(Color.BLACK);
        ObjectAnimator bgAnim = ObjectAnimator.ofInt(backgroundColor, "alpha", 0);
        bgAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                background.setBackground(backgroundColor);
            }
        });
        bgAnim.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                GalleryAnimationActivity.super.finish();
                overridePendingTransition(-1, -1);
            }
        });
        fragment.animationExit(bgAnim);
    } else {
        super.onBackPressed();
    }
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) ColorDrawable(android.graphics.drawable.ColorDrawable) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ValueAnimator(android.animation.ValueAnimator)

Example 38 with ObjectAnimator

use of android.animation.ObjectAnimator in project weiciyuan by qii.

the class AnimationUtility method translateFragmentX.

public static void translateFragmentX(Fragment fragment, int from, int to) {
    final View fragmentView = fragment.getView();
    if (fragmentView == null) {
        return;
    }
    FragmentViewXWrapper wrapper = new FragmentViewXWrapper(fragmentView);
    ObjectAnimator objectAnimator = ObjectAnimator.ofInt(wrapper, "change", from, to);
    objectAnimator.setDuration(300);
    objectAnimator.setInterpolator(new DecelerateInterpolator());
    objectAnimator.start();
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ObjectAnimator(android.animation.ObjectAnimator) ImageView(android.widget.ImageView) View(android.view.View)

Example 39 with ObjectAnimator

use of android.animation.ObjectAnimator in project platform_frameworks_base by android.

the class AnimatedVectorDrawable method inflate.

@Override
public void inflate(Resources res, XmlPullParser parser, AttributeSet attrs, Theme theme) throws XmlPullParserException, IOException {
    final AnimatedVectorDrawableState state = mAnimatedVectorState;
    int eventType = parser.getEventType();
    float pathErrorScale = 1;
    final int innerDepth = parser.getDepth() + 1;
    // Parse everything until the end of the animated-vector element.
    while (eventType != XmlPullParser.END_DOCUMENT && (parser.getDepth() >= innerDepth || eventType != XmlPullParser.END_TAG)) {
        if (eventType == XmlPullParser.START_TAG) {
            final String tagName = parser.getName();
            if (ANIMATED_VECTOR.equals(tagName)) {
                final TypedArray a = obtainAttributes(res, theme, attrs, R.styleable.AnimatedVectorDrawable);
                int drawableRes = a.getResourceId(R.styleable.AnimatedVectorDrawable_drawable, 0);
                if (drawableRes != 0) {
                    VectorDrawable vectorDrawable = (VectorDrawable) res.getDrawable(drawableRes, theme).mutate();
                    vectorDrawable.setAllowCaching(false);
                    vectorDrawable.setCallback(mCallback);
                    pathErrorScale = vectorDrawable.getPixelSize();
                    if (state.mVectorDrawable != null) {
                        state.mVectorDrawable.setCallback(null);
                    }
                    state.mVectorDrawable = vectorDrawable;
                }
                a.recycle();
            } else if (TARGET.equals(tagName)) {
                final TypedArray a = obtainAttributes(res, theme, attrs, R.styleable.AnimatedVectorDrawableTarget);
                final String target = a.getString(R.styleable.AnimatedVectorDrawableTarget_name);
                final int animResId = a.getResourceId(R.styleable.AnimatedVectorDrawableTarget_animation, 0);
                if (animResId != 0) {
                    if (theme != null) {
                        // The animator here could be ObjectAnimator or AnimatorSet.
                        final Animator animator = AnimatorInflater.loadAnimator(res, theme, animResId, pathErrorScale);
                        updateAnimatorProperty(animator, target, state.mVectorDrawable, state.mShouldIgnoreInvalidAnim);
                        state.addTargetAnimator(target, animator);
                    } else {
                        // The animation may be theme-dependent. As a
                        // workaround until Animator has full support for
                        // applyTheme(), postpone loading the animator
                        // until we have a theme in applyTheme().
                        state.addPendingAnimator(animResId, pathErrorScale, target);
                    }
                }
                a.recycle();
            }
        }
        eventType = parser.next();
    }
    // If we don't have any pending animations, we don't need to hold a
    // reference to the resources.
    mRes = state.mPendingAnims == null ? null : res;
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) TypedArray(android.content.res.TypedArray)

Example 40 with ObjectAnimator

use of android.animation.ObjectAnimator in project platform_frameworks_base by android.

the class TransformsAndAnimationsActivity method startAnimator.

private void startAnimator(View target) {
    ObjectAnimator anim1b = ObjectAnimator.ofFloat(target, View.ALPHA, 0);
    anim1b.setRepeatCount(ValueAnimator.INFINITE);
    anim1b.setRepeatMode(ValueAnimator.REVERSE);
    anim1b.setDuration(1000);
    anim1b.start();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator)

Aggregations

ObjectAnimator (android.animation.ObjectAnimator)790 Animator (android.animation.Animator)313 AnimatorSet (android.animation.AnimatorSet)214 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)208 PropertyValuesHolder (android.animation.PropertyValuesHolder)128 ValueAnimator (android.animation.ValueAnimator)111 View (android.view.View)101 Paint (android.graphics.Paint)68 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)48 TextView (android.widget.TextView)48 ViewGroup (android.view.ViewGroup)45 Rect (android.graphics.Rect)35 LinearInterpolator (android.view.animation.LinearInterpolator)35 ImageView (android.widget.ImageView)31 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)30 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)29 OvershootInterpolator (android.view.animation.OvershootInterpolator)28 ArrayList (java.util.ArrayList)22 TargetApi (android.annotation.TargetApi)21 Interpolator (android.view.animation.Interpolator)20