Java Examples for android.animation.AnimatorListenerAdapter

The following java examples will help you to understand the usage of android.animation.AnimatorListenerAdapter. These source code samples are taken from different open source projects.

Example 1
Project: Mortar-architect-master  File: NavigatorView.java View source code
private void markReady() {
    readyCount++;
    Preconditions.checkArgument(readyCount <= presentations.size(), "Ready count cannot exceed presentations size");
    if (readyCount == presentations.size()) {
        if (!animators.isEmpty()) {
            AnimatorSet set = new AnimatorSet();
            set.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    end(callback);
                }
            });
            set.playTogether(animators);
            set.start();
        } else {
            end(callback);
        }
    }
}
Example 2
Project: MHacksAndroid-Public-master  File: PongHeaderTransformer.java View source code
@Override
public boolean hideHeaderView() {
    final boolean changeVis = mHeaderView.getVisibility() == View.VISIBLE;
    if (changeVis) {
        Animator animator = ObjectAnimator.ofFloat(mHeaderView, "alpha", 1f, 0f);
        animator.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                mHeaderView.setVisibility(View.GONE);
                mPongPlayer.stopPlaying();
            }
        });
        animator.setDuration(FADE_IN_OUT_DURATION).start();
    }
    Log.d("PongHeaderTransformer", "hideHeaderView: " + changeVis);
    return changeVis;
}
Example 3
Project: sdk-support-master  File: ViewPropertyAnimatorCompatICS.java View source code
public static void setListener(final View view, final ViewPropertyAnimatorListener listener) {
    if (listener != null) {
        view.animate().setListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationCancel(Animator animation) {
                listener.onAnimationCancel(view);
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                listener.onAnimationEnd(view);
            }

            @Override
            public void onAnimationStart(Animator animation) {
                listener.onAnimationStart(view);
            }
        });
    } else {
        view.animate().setListener(null);
    }
}
Example 4
Project: Yhb-2.0-master  File: MaterialRippleLayout.java View source code
private void startRipple(final Runnable animationEndRunnable) {
    if (eventCancelled)
        return;
    float endRadius = getEndRadius();
    cancelAnimations();
    rippleAnimator = new AnimatorSet();
    rippleAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            if (!ripplePersistent) {
                setRadius(0);
                setRippleAlpha(rippleAlpha);
            }
            if (animationEndRunnable != null && rippleDelayClick) {
                animationEndRunnable.run();
            }
            childView.setPressed(false);
        }
    });
    ObjectAnimator ripple = ObjectAnimator.ofFloat(this, radiusProperty, radius, endRadius);
    ripple.setDuration(rippleDuration);
    ripple.setInterpolator(new DecelerateInterpolator());
    ObjectAnimator fade = ObjectAnimator.ofInt(this, circleAlphaProperty, rippleAlpha, 0);
    fade.setDuration(rippleFadeDuration);
    fade.setInterpolator(new AccelerateInterpolator());
    fade.setStartDelay(rippleDuration - rippleFadeDuration - FADE_EXTRA_DELAY);
    if (ripplePersistent) {
        rippleAnimator.play(ripple);
    } else if (getRadius() > endRadius) {
        fade.setStartDelay(0);
        rippleAnimator.play(fade);
    } else {
        rippleAnimator.playTogether(ripple, fade);
    }
    rippleAnimator.start();
}
Example 5
Project: jdroid-master  File: AnimationUtils.java View source code
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void hideWithReveal(final View view) {
    // get the center for the clipping circle
    int cx = (view.getLeft() + view.getRight()) / 2;
    int cy = (view.getTop() + view.getBottom()) / 2;
    // get the initial radius for the clipping circle
    int initialRadius = view.getWidth();
    // create the animation (the final radius is zero)
    Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, initialRadius, 0);
    // make the view invisible when the animation is done
    anim.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            view.setVisibility(View.INVISIBLE);
        }
    });
    anim.setDuration(1000);
    // start the animation
    anim.start();
}
Example 6
Project: property-db-master  File: PhoneStatusBar.java View source code
protected void updateCarrierLabelVisibility(boolean force) {
    if (!mShowCarrierInPanel)
        return;
    // i.e. when there aren't enough notifications to fill the panel.
    if (DEBUG) {
        Slog.d(TAG, String.format("pileh=%d scrollh=%d carrierh=%d", mPile.getHeight(), mScrollView.getHeight(), mCarrierLabelHeight));
    }
    final boolean emergencyCallsShownElsewhere = mEmergencyCallLabel != null;
    final boolean makeVisible = !(emergencyCallsShownElsewhere && mNetworkController.isEmergencyOnly()) && mPile.getHeight() < (mNotificationPanel.getHeight() - mCarrierLabelHeight - mNotificationHeaderHeight) && mScrollView.getVisibility() == View.VISIBLE;
    if (force || mCarrierLabelVisible != makeVisible) {
        mCarrierLabelVisible = makeVisible;
        if (DEBUG) {
            Slog.d(TAG, "making carrier label " + (makeVisible ? "visible" : "invisible"));
        }
        mCarrierLabel.animate().cancel();
        if (makeVisible) {
            mCarrierLabel.setVisibility(View.VISIBLE);
        }
        mCarrierLabel.animate().alpha(makeVisible ? 1f : 0f).setDuration(//.setDuration(makeVisible ? 750 : 100)
        150).setListener(makeVisible ? null : new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                if (!mCarrierLabelVisible) {
                    // race
                    mCarrierLabel.setVisibility(View.INVISIBLE);
                    mCarrierLabel.setAlpha(0f);
                }
            }
        }).start();
    }
}
Example 7
Project: AppCompat-Extension-Library-master  File: LabelView.java View source code
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void hideIceCreamSandwich() {
    animate().cancel();
    animate().translationX(mAnimationOffset).alpha(0f).setDuration(SHOW_HIDE_ANIM_DURATION).setInterpolator(AnimationUtils.FAST_OUT_LINEAR_IN_INTERPOLATOR).setListener(new AnimatorListenerAdapter() {

        private boolean mCancelled;

        @Override
        public void onAnimationStart(Animator animation) {
            mIsHiding = true;
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            mIsHiding = false;
            mCancelled = true;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            mIsHiding = false;
            // cancelled animations don't change visibility
            if (!mCancelled) {
                setVisibility(GONE);
            }
        }
    });
}
Example 8
Project: android-sdk-sources-for-api-level-23-master  File: BaseStatusBar.java View source code
public void dismissPopups() {
    if (mNotificationGutsExposed != null) {
        final NotificationGuts v = mNotificationGutsExposed;
        mNotificationGutsExposed = null;
        if (v.getWindowToken() == null)
            return;
        final int x = (v.getLeft() + v.getRight()) / 2;
        final int y = (v.getTop() + v.getActualHeight() / 2);
        final Animator a = ViewAnimationUtils.createCircularReveal(v, x, y, x, 0);
        a.setDuration(200);
        a.setInterpolator(mFastOutLinearIn);
        a.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                v.setVisibility(View.GONE);
            }
        });
        a.start();
    }
}
Example 9
Project: WordPress-Android-master  File: PostsListAdapter.java View source code
/*
     * buttons may appear in two rows depending on display size and number of visible
     * buttons - these rows are toggled through the "more" and "back" buttons - this
     * routine is used to animate the new row in and the old row out
     */
private void animateButtonRows(final PostViewHolder holder, final PostsListPost post, final boolean showRow1) {
    // first animate out the button row, then show/hide the appropriate buttons,
    // then animate the row layout back in
    PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat(View.SCALE_X, 1f, 0f);
    PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f, 0f);
    ObjectAnimator animOut = ObjectAnimator.ofPropertyValuesHolder(holder.layoutButtons, scaleX, scaleY);
    animOut.setDuration(ROW_ANIM_DURATION);
    animOut.setInterpolator(new AccelerateInterpolator());
    animOut.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            // row 1
            holder.btnEdit.setVisibility(showRow1 ? View.VISIBLE : View.GONE);
            holder.btnView.setVisibility(showRow1 ? View.VISIBLE : View.GONE);
            holder.btnMore.setVisibility(showRow1 ? View.VISIBLE : View.GONE);
            // row 2
            holder.btnStats.setVisibility(!showRow1 && canShowStatsForPost(post) ? View.VISIBLE : View.GONE);
            holder.btnPublish.setVisibility(!showRow1 && canPublishPost(post) ? View.VISIBLE : View.GONE);
            holder.btnTrash.setVisibility(!showRow1 ? View.VISIBLE : View.GONE);
            holder.btnBack.setVisibility(!showRow1 ? View.VISIBLE : View.GONE);
            PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat(View.SCALE_X, 0f, 1f);
            PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0f, 1f);
            ObjectAnimator animIn = ObjectAnimator.ofPropertyValuesHolder(holder.layoutButtons, scaleX, scaleY);
            animIn.setDuration(ROW_ANIM_DURATION);
            animIn.setInterpolator(new DecelerateInterpolator());
            animIn.start();
        }
    });
    animOut.start();
}
Example 10
Project: andevcon-2014-jl-master  File: LayoutAnimations.java View source code
private void createCustomAnimations(LayoutTransition transition) {
    // Changing while Adding
    PropertyValuesHolder pvhLeft = PropertyValuesHolder.ofInt("left", 0, 1);
    PropertyValuesHolder pvhTop = PropertyValuesHolder.ofInt("top", 0, 1);
    PropertyValuesHolder pvhRight = PropertyValuesHolder.ofInt("right", 0, 1);
    PropertyValuesHolder pvhBottom = PropertyValuesHolder.ofInt("bottom", 0, 1);
    PropertyValuesHolder pvhScaleX = PropertyValuesHolder.ofFloat("scaleX", 1f, 0f, 1f);
    PropertyValuesHolder pvhScaleY = PropertyValuesHolder.ofFloat("scaleY", 1f, 0f, 1f);
    customChangingAppearingAnim = ObjectAnimator.ofPropertyValuesHolder(this, pvhLeft, pvhTop, pvhRight, pvhBottom, pvhScaleX, pvhScaleY).setDuration(transition.getDuration(LayoutTransition.CHANGE_APPEARING));
    customChangingAppearingAnim.addListener(new AnimatorListenerAdapter() {

        public void onAnimationEnd(Animator anim) {
            View view = (View) ((ObjectAnimator) anim).getTarget();
            view.setScaleX(1f);
            view.setScaleY(1f);
        }
    });
    // Changing while Removing
    Keyframe kf0 = Keyframe.ofFloat(0f, 0f);
    Keyframe kf1 = Keyframe.ofFloat(.9999f, 360f);
    Keyframe kf2 = Keyframe.ofFloat(1f, 0f);
    PropertyValuesHolder pvhRotation = PropertyValuesHolder.ofKeyframe("rotation", kf0, kf1, kf2);
    customChangingDisappearingAnim = ObjectAnimator.ofPropertyValuesHolder(this, pvhLeft, pvhTop, pvhRight, pvhBottom, pvhRotation).setDuration(transition.getDuration(LayoutTransition.CHANGE_DISAPPEARING));
    customChangingDisappearingAnim.addListener(new AnimatorListenerAdapter() {

        public void onAnimationEnd(Animator anim) {
            View view = (View) ((ObjectAnimator) anim).getTarget();
            view.setRotation(0f);
        }
    });
    // Adding
    customAppearingAnim = ObjectAnimator.ofFloat(null, "rotationY", 90f, 0f).setDuration(transition.getDuration(LayoutTransition.APPEARING));
    customAppearingAnim.addListener(new AnimatorListenerAdapter() {

        public void onAnimationEnd(Animator anim) {
            View view = (View) ((ObjectAnimator) anim).getTarget();
            view.setRotationY(0f);
        }
    });
    // Removing
    customDisappearingAnim = ObjectAnimator.ofFloat(null, "rotationX", 0f, 90f).setDuration(transition.getDuration(LayoutTransition.DISAPPEARING));
    customDisappearingAnim.addListener(new AnimatorListenerAdapter() {

        public void onAnimationEnd(Animator anim) {
            View view = (View) ((ObjectAnimator) anim).getTarget();
            view.setRotationX(0f);
        }
    });
}
Example 11
Project: androidtv-Leanback-master  File: OnboardingFragment.java View source code
@Override
protected void onPageChanged(final int newPage, int previousPage) {
    if (mContentAnimator != null) {
        mContentAnimator.end();
    }
    ArrayList<Animator> animators = new ArrayList<>();
    Animator fadeOut = createFadeOutAnimator(mContentView);
    fadeOut.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mContentView.setImageDrawable(getResources().getDrawable(pageImages[newPage]));
            ((AnimationDrawable) mContentView.getDrawable()).start();
        }
    });
    animators.add(fadeOut);
    animators.add(createFadeInAnimator(mContentView));
    AnimatorSet set = new AnimatorSet();
    set.playSequentially(animators);
    set.start();
    mContentAnimator = set;
}
Example 12
Project: SyncthingAndroid-master  File: ExpandCollapseHelper.java View source code
/**
     * This method expandes the view that was clicked.
     *
     * @param expandingLayout  layout to expand
     * @param cardView         cardView
     * @param recyclerView     recyclerView
     */
public static void animateCollapsing(final View expandingLayout, final ExpandableView cardView, final RecyclerView recyclerView, boolean wobble) {
    final int origHeight = expandingLayout.getHeight();
    ValueAnimator animator = createHeightAnimator(expandingLayout, origHeight, 0);
    animator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(final Animator animator) {
            expandingLayout.setVisibility(View.GONE);
            //reset height else recycled views never show
            ViewGroup.LayoutParams layoutParams = expandingLayout.getLayoutParams();
            layoutParams.height = origHeight;
            expandingLayout.setLayoutParams(layoutParams);
            cardView.getExpandable().setExpanded(false);
        //notifyAdapter(recyclerView, recyclerView.getLayoutManager().getPosition((View)cardView));
        //                Card card = cardView.getCard();
        //                if (card.getOnCollapseAnimatorEndListener()!=null)
        //                    card.getOnCollapseAnimatorEndListener().onCollapseEnd(card);
        }
    });
    if (wobble) {
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(animator, createWobbleAnimator(cardView.getView()));
        animatorSet.start();
    } else {
        animator.start();
    }
}
Example 13
Project: WhatsThat-master  File: SuperCardToast.java View source code
/**
     * Hide the SuperCardToast and animate the Layout. Post Honeycomb only. *
     */
@SuppressLint("NewApi")
private void dismissWithLayoutAnimation() {
    if (mToastView != null) {
        mToastView.setVisibility(View.INVISIBLE);
        final ViewGroup.LayoutParams layoutParams = mToastView.getLayoutParams();
        final int originalHeight = mToastView.getHeight();
        ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mActivity.getResources().getInteger(android.R.integer.config_shortAnimTime));
        animator.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                Handler mHandler = new Handler();
                mHandler.post(mHideImmediateRunnable);
            }
        });
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            @SuppressWarnings("ConstantConditions")
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                if (mToastView != null) {
                    try {
                        layoutParams.height = (Integer) valueAnimator.getAnimatedValue();
                        mToastView.setLayoutParams(layoutParams);
                    } catch (NullPointerException e) {
                    }
                }
            }
        });
        animator.start();
    } else {
        dismissImmediately();
    }
}
Example 14
Project: platform_packages_apps_settings-master  File: DotsPageIndicator.java View source code
private ValueAnimator createMoveSelectedAnimator(final float moveTo, int was, int now, int steps) {
    // create the actual move animator
    ValueAnimator moveSelected = ValueAnimator.ofFloat(selectedDotX, moveTo);
    // also set up a pending retreat anim – this starts when the move is 75% complete
    retreatAnimation = new PendingRetreatAnimator(was, now, steps, now > was ? new RightwardStartPredicate(moveTo - ((moveTo - selectedDotX) * 0.25f)) : new LeftwardStartPredicate(moveTo + ((selectedDotX - moveTo) * 0.25f)));
    moveSelected.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            // todo avoid autoboxing
            selectedDotX = (Float) valueAnimator.getAnimatedValue();
            retreatAnimation.startIfNecessary(selectedDotX);
            postInvalidateOnAnimation();
        }
    });
    moveSelected.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animation) {
            // set a flag so that we continue to draw the unselected dot in the target position
            // until the selected dot has finished moving into place
            selectedDotInPosition = false;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            // set a flag when anim finishes so that we don't draw both selected & unselected
            // page dots
            selectedDotInPosition = true;
        }
    });
    // slightly delay the start to give the joins a chance to run
    // unless dot isn't in position yet – then don't delay!
    moveSelected.setStartDelay(selectedDotInPosition ? animDuration / 4L : 0L);
    moveSelected.setDuration(animDuration * 3L / 4L);
    moveSelected.setInterpolator(interpolator);
    return moveSelected;
}
Example 15
Project: iosched4eclipse-master  File: LPreviewUtilsBase.java View source code
public void setOrAnimatePlusCheckIcon(final ImageView imageView, boolean isCheck, boolean allowAnimate) {
    final int imageResId = isCheck ? R.drawable.add_schedule_button_icon_checked : R.drawable.add_schedule_button_icon_unchecked;
    if (imageView.getTag() != null) {
        if (imageView.getTag() instanceof Animator) {
            Animator anim = (Animator) imageView.getTag();
            anim.end();
            imageView.setAlpha(1f);
        }
    }
    if (allowAnimate && isCheck) {
        int duration = mActivity.getResources().getInteger(android.R.integer.config_shortAnimTime);
        Animator outAnimator = ObjectAnimator.ofFloat(imageView, View.ALPHA, 0f);
        outAnimator.setDuration(duration / 2);
        outAnimator.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                imageView.setImageResource(imageResId);
            }
        });
        AnimatorSet inAnimator = new AnimatorSet();
        outAnimator.setDuration(duration);
        inAnimator.playTogether(ObjectAnimator.ofFloat(imageView, View.ALPHA, 1f), ObjectAnimator.ofFloat(imageView, View.SCALE_X, 0f, 1f), ObjectAnimator.ofFloat(imageView, View.SCALE_Y, 0f, 1f));
        AnimatorSet set = new AnimatorSet();
        set.playSequentially(outAnimator, inAnimator);
        set.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                imageView.setTag(null);
            }
        });
        imageView.setTag(set);
        set.start();
    } else {
        mHandler.post(new Runnable() {

            @Override
            public void run() {
                imageView.setImageResource(imageResId);
            }
        });
    }
}
Example 16
Project: kinballwc2015-master  File: TeamActivity.java View source code
private void zoomImageFromThumb(final View thumbView, String url) {
    if (thumbView == null) {
        // || TextUtils.isEmpty(url)){
        return;
    }
    lastThumbImage = thumbView;
    progressBar.setVisibility(View.VISIBLE);
    // immediately and proceed with this one.
    if (mCurrentAnimator != null) {
        mCurrentAnimator.cancel();
    }
    // Load the high-resolution "zoomed-in" image.
    Glide.with(this).load(url).placeholder(R.drawable.placeholder).diskCacheStrategy(DiskCacheStrategy.ALL).error(R.drawable.ic_error).fitCenter().listener(new RequestListener<String, GlideDrawable>() {

        @Override
        public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
            progressBar.setVisibility(View.GONE);
            return false;
        }

        @Override
        public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
            progressBar.setVisibility(View.GONE);
            expandedImageView.setImageDrawable(resource);
            return false;
        }
    }).into(expandedImageView);
    // Calculate the starting and ending bounds for the zoomed-in image.
    // This step involves lots of math. Yay, math.
    startBounds = new Rect();
    final Rect finalBounds = new Rect();
    final Point globalOffset = new Point();
    // The start bounds are the global visible rectangle of the thumbnail,
    // and the final bounds are the global visible rectangle of the container
    // view. Also set the container view's offset as the origin for the
    // bounds, since that's the origin for the positioning animation
    // properties (X, Y).
    thumbView.getGlobalVisibleRect(startBounds);
    findViewById(R.id.rootLayout).getGlobalVisibleRect(finalBounds, globalOffset);
    startBounds.offset(-globalOffset.x, -globalOffset.y);
    finalBounds.offset(-globalOffset.x, -globalOffset.y);
    // Adjust the start bounds to be the same aspect ratio as the final
    // bounds using the "center crop" technique. This prevents undesirable
    // stretching during the animation. Also calculate the start scaling
    // factor (the end scaling factor is always 1.0).
    float startScale;
    if ((float) finalBounds.width() / finalBounds.height() > (float) startBounds.width() / startBounds.height()) {
        // Extend start bounds horizontally
        startScale = (float) startBounds.height() / finalBounds.height();
        float startWidth = startScale * finalBounds.width();
        float deltaWidth = (startWidth - startBounds.width()) / 2;
        startBounds.left -= deltaWidth;
        startBounds.right += deltaWidth;
    } else {
        // Extend start bounds vertically
        startScale = (float) startBounds.width() / finalBounds.width();
        float startHeight = startScale * finalBounds.height();
        float deltaHeight = (startHeight - startBounds.height()) / 2;
        startBounds.top -= deltaHeight;
        startBounds.bottom += deltaHeight;
    }
    // Hide the thumbnail and show the zoomed-in view. When the animation
    // begins, it will position the zoomed-in view in the place of the
    // thumbnail.
    thumbView.setAlpha(0f);
    expandedImageView.setVisibility(View.VISIBLE);
    // Set the pivot point for SCALE_X and SCALE_Y transformations
    // to the top-left corner of the zoomed-in view (the default
    // is the center of the view).
    expandedImageView.setPivotX(0f);
    expandedImageView.setPivotY(0f);
    // Construct and run the parallel animation of the four translation and
    // scale properties (X, Y, SCALE_X, and SCALE_Y).
    AnimatorSet set = new AnimatorSet();
    set.play(ObjectAnimator.ofFloat(expandedImageView, View.X, startBounds.left, finalBounds.left)).with(ObjectAnimator.ofFloat(expandedImageView, View.Y, startBounds.top, finalBounds.top)).with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_X, startScale, 1f)).with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_Y, startScale, 1f));
    set.setDuration(SHORT_ANIMATION_DURATION);
    set.setInterpolator(new DecelerateInterpolator());
    set.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mCurrentAnimator = null;
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            mCurrentAnimator = null;
        }
    });
    set.start();
    mCurrentAnimator = set;
    // Upon clicking the zoomed-in image, it should zoom back down
    // to the original bounds and show the thumbnail instead of
    // the expanded image.
    startScaleFinal = startScale;
    expandedImageView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            zoomOutImage(thumbView);
        }
    });
}
Example 17
Project: Subsonic-master  File: FastScroller.java View source code
private void hideBubble() {
    if (currentAnimator != null)
        currentAnimator.cancel();
    currentAnimator = ObjectAnimator.ofFloat(bubble, "alpha", 1f, 0f).setDuration(BUBBLE_ANIMATION_DURATION);
    currentAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            bubble.setVisibility(INVISIBLE);
            currentAnimator = null;
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            super.onAnimationCancel(animation);
            bubble.setVisibility(INVISIBLE);
            currentAnimator = null;
        }
    });
    currentAnimator.start();
}
Example 18
Project: android-platform-tools-base-master  File: NotificationStudioActivity.java View source code
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
    // animate preview height changes
    if (oldBottom != bottom) {
        final View e = findViewById(R.id.editors);
        final int y = bottom + margin;
        e.animate().translationY(y - oldBottom).setListener(new AnimatorListenerAdapter() {

            public void onAnimationEnd(Animator animation) {
                FrameLayout.LayoutParams lp = (LayoutParams) e.getLayoutParams();
                lp.topMargin = y;
                e.setTranslationY(0);
                e.setLayoutParams(lp);
            }
        });
    }
}
Example 19
Project: TasksProject-master  File: SwipeDismissTouchListener.java View source code
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
    // offset because the view is translated during swipe
    motionEvent.offsetLocation(mTranslationX, 0);
    if (mViewWidth < 2) {
        mViewWidth = mView.getWidth();
    }
    switch(motionEvent.getActionMasked()) {
        case MotionEvent.ACTION_DOWN:
            {
                // TODO: ensure this is a finger, and set a flag
                mDownX = motionEvent.getRawX();
                mVelocityTracker = VelocityTracker.obtain();
                mVelocityTracker.addMovement(motionEvent);
                view.onTouchEvent(motionEvent);
                pos = (mView.getX() + mView.getWidth()) / 2;
                return false;
            }
        case MotionEvent.ACTION_UP:
            {
                if (mVelocityTracker == null) {
                    break;
                }
                float deltaX = motionEvent.getRawX() - mDownX;
                mVelocityTracker.addMovement(motionEvent);
                mVelocityTracker.computeCurrentVelocity(1000);
                float velocityX = Math.abs(mVelocityTracker.getXVelocity());
                float velocityY = Math.abs(mVelocityTracker.getYVelocity());
                boolean dismiss = false;
                boolean dismissRight = false;
                if (Math.abs(deltaX) > mViewWidth / 2) {
                    dismiss = true;
                    dismissRight = deltaX > 0;
                } else if (mMinFlingVelocity <= velocityX && velocityX <= mMaxFlingVelocity && velocityY < velocityX) {
                    dismiss = true;
                    dismissRight = mVelocityTracker.getXVelocity() > 0;
                }
                if (dismiss) {
                    // dismiss
                    mView.animate().translationX(dismissRight ? mViewWidth : -mViewWidth).alpha(0).setDuration(mAnimationTime).setListener(new AnimatorListenerAdapter() {

                        @Override
                        public void onAnimationEnd(Animator animation) {
                            performDismiss();
                        }
                    });
                } else {
                    // cancel
                    mView.animate().translationX(0).alpha(1).setDuration(mAnimationTime).setListener(null);
                }
                mVelocityTracker = null;
                mTranslationX = 0;
                mDownX = 0;
                mSwiping = false;
                break;
            }
        case MotionEvent.ACTION_MOVE:
            {
                if (mVelocityTracker == null) {
                    break;
                }
                mVelocityTracker.addMovement(motionEvent);
                float deltaX = motionEvent.getRawX() - mDownX;
                if (Math.abs(deltaX) > mSlop) {
                    mSwiping = true;
                    mView.getParent().requestDisallowInterceptTouchEvent(true);
                    // Cancel listview's touch
                    MotionEvent cancelEvent = MotionEvent.obtain(motionEvent);
                    cancelEvent.setAction(MotionEvent.ACTION_CANCEL | (motionEvent.getActionIndex() << MotionEvent.ACTION_POINTER_INDEX_SHIFT));
                    mView.onTouchEvent(cancelEvent);
                }
                if (mSwiping) {
                    mTranslationX = deltaX;
                    mView.setTranslationX(deltaX);
                    // TODO: use an ease-out interpolator or such
                    mView.setAlpha(Math.max(0f, Math.min(1f, 1f - 2f * Math.abs(deltaX) / mViewWidth)));
                    //                }
                    return true;
                }
                break;
            }
    }
    return false;
}
Example 20
Project: cardslib-master  File: CardViewNative.java View source code
/**
         * Expanding animator.
         */
private static void animateExpanding(final ExpandContainerHelper helper) {
    if (helper.getCardView().getOnExpandListAnimatorListener() != null) {
        //List Animator
        helper.getCardView().getOnExpandListAnimatorListener().onExpandStart(helper.getCardView(), helper.contentParent);
    } else {
        //Std animator
        helper.contentParent.setVisibility(View.VISIBLE);
        if (helper.getCardView().mExpandAnimator != null) {
            helper.getCardView().mExpandAnimator.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    helper.card.setExpanded(true);
                    //Callback
                    if (helper.card.getOnExpandAnimatorEndListener() != null)
                        helper.card.getOnExpandAnimatorEndListener().onExpandEnd(helper.card);
                }
            });
            helper.getCardView().mExpandAnimator.start();
        } else {
            if (helper.card.getOnExpandAnimatorEndListener() != null)
                helper.card.getOnExpandAnimatorEndListener().onExpandEnd(helper.card);
            Log.w(TAG, "Does the card have the ViewToClickToExpand?");
        }
    }
}
Example 21
Project: Protocoder-master  File: PUI.java View source code
[email protected](L)
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@ProtocoderScript
@APIParam(params = { "View" })
public void reveal(final View v) {
    // previously invisible view
    // get the center for the clipping circle
    int cx = (v.getLeft() + v.getRight()) / 2;
    int cy = (v.getTop() + v.getBottom()) / 2;
    // get the final radius for the clipping circle
    int finalRadius = v.getWidth();
    // create and start the animator for this view
    // (the start radius is zero)
    ValueAnimator anim = (ValueAnimator) ViewAnimationUtils.createCircularReveal(v, cx, cy, 0, finalRadius);
    anim.setDuration(1000);
    anim.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animation) {
            super.onAnimationStart(animation);
            v.setVisibility(View.VISIBLE);
        }
    });
    anim.start();
}
Example 22
Project: luper-master  File: TabLoginFragment.java View source code
/**
   * Shows the progress UI and hides the login form.
   */
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
private void showProgress(final boolean show) {
    // the progress spinner.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);
        mLoginStatusView.setVisibility(View.VISIBLE);
        mLoginStatusView.animate().setDuration(shortAnimTime).alpha(show ? 1 : 0).setListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                mLoginStatusView.setVisibility(show ? View.VISIBLE : View.GONE);
            }
        });
        mLoginFormView.setVisibility(View.VISIBLE);
        mLoginFormView.animate().setDuration(shortAnimTime).alpha(show ? 0 : 1).setListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
            }
        });
    } else {
        // The ViewPropertyAnimator APIs are not available, so simply show
        // and hide the relevant UI components.
        mLoginStatusView.setVisibility(show ? View.VISIBLE : View.GONE);
        mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
    }
}
Example 23
Project: financius-public-master  File: CalculatorFragment.java View source code
private void clear() {
    int cx = resultClearer_V.getRight();
    int cy = resultClearer_V.getBottom();
    float radius = Math.max(resultClearer_V.getWidth(), resultClearer_V.getHeight()) * 2.0f;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        if (resultClearer_V.getVisibility() != View.VISIBLE) {
            Animator reveal = ViewAnimationUtils.createCircularReveal(resultClearer_V, cx, cy, 0, radius);
            reveal.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationStart(Animator animation) {
                    super.onAnimationStart(animation);
                    resultClearer_V.setVisibility(View.VISIBLE);
                }

                @Override
                public void onAnimationEnd(Animator animation) {
                    calculator.clear();
                    updateResult();
                    resultClearer_V.animate().alpha(0.0f).setDuration(200).withEndAction(new Runnable() {

                        @Override
                        public void run() {
                            resultClearer_V.setVisibility(View.INVISIBLE);
                            resultClearer_V.setAlpha(1.0f);
                        }
                    }).start();
                }
            });
            reveal.setDuration(600);
            reveal.start();
        }
    } else {
        calculator.clear();
        updateResult();
    }
}
Example 24
Project: XieDaDeng-master  File: SearchPanelCircleView.java View source code
public void setCircleSize(float circleSize, boolean animated, final Runnable endRunnable, int startDelay, Interpolator interpolator) {
    boolean isAnimating = mCircleAnimator != null;
    boolean animationPending = isAnimating && !mCircleAnimator.isRunning();
    boolean animatingOut = isAnimating && mCircleAnimationEndValue == 0;
    if (animated || animationPending || animatingOut) {
        if (isAnimating) {
            if (circleSize == mCircleAnimationEndValue) {
                return;
            }
            mCircleAnimator.cancel();
        }
        mCircleAnimator = ValueAnimator.ofFloat(mCircleSize, circleSize);
        mCircleAnimator.addUpdateListener(mCircleUpdateListener);
        mCircleAnimator.addListener(mClearAnimatorListener);
        mCircleAnimator.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                if (endRunnable != null) {
                    endRunnable.run();
                }
            }
        });
        Interpolator desiredInterpolator = interpolator != null ? interpolator : circleSize == 0 ? mDisappearInterpolator : mAppearInterpolator;
        mCircleAnimator.setInterpolator(desiredInterpolator);
        mCircleAnimator.setDuration(300);
        mCircleAnimator.setStartDelay(startDelay);
        mCircleAnimator.start();
        mCircleAnimationEndValue = circleSize;
    } else {
        if (isAnimating) {
            float diff = circleSize - mCircleAnimationEndValue;
            PropertyValuesHolder[] values = mCircleAnimator.getValues();
            values[0].setFloatValues(diff, circleSize);
            mCircleAnimator.setCurrentPlayTime(mCircleAnimator.getCurrentPlayTime());
            mCircleAnimationEndValue = circleSize;
        } else {
            applyCircleSize(circleSize);
            updateElevation();
        }
    }
}
Example 25
Project: Campus-master  File: LoginActivity.java View source code
/**
	 * Shows the progress UI and hides the login form.
	 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
private void showProgress(final boolean show) {
    // the progress spinner.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);
        mLoginStatusView.setVisibility(View.VISIBLE);
        mLoginStatusView.animate().setDuration(shortAnimTime).alpha(show ? 1 : 0).setListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                mLoginStatusView.setVisibility(show ? View.VISIBLE : View.GONE);
            }
        });
        mLoginFormView.setVisibility(View.VISIBLE);
        mLoginFormView.animate().setDuration(shortAnimTime).alpha(show ? 0 : 1).setListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
            }
        });
    } else {
        // The ViewPropertyAnimator APIs are not available, so simply show
        // and hide the relevant UI components.
        mLoginStatusView.setVisibility(show ? View.VISIBLE : View.GONE);
        mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
    }
}
Example 26
Project: android-15-master  File: FragmentManager.java View source code
void moveToState(Fragment f, int newState, int transit, int transitionStyle) {
    // Fragments that are not currently added will sit in the onCreate() state.
    if (!f.mAdded && newState > Fragment.CREATED) {
        newState = Fragment.CREATED;
    }
    if (f.mRemoving && newState > f.mState) {
        // While removing a fragment, we can't change it to a higher state.
        newState = f.mState;
    }
    // if it's not already started.
    if (f.mDeferStart && f.mState < Fragment.STARTED && newState > Fragment.STOPPED) {
        newState = Fragment.STOPPED;
    }
    if (f.mState < newState) {
        // being reloaded from the layout.
        if (f.mFromLayout && !f.mInLayout) {
            return;
        }
        if (f.mAnimatingAway != null) {
            // The fragment is currently being animated...  but!  Now we
            // want to move our state back up.  Give up on waiting for the
            // animation, move to whatever the final state should be once
            // the animation is done, and then we can proceed from there.
            f.mAnimatingAway = null;
            moveToState(f, f.mStateAfterAnimating, 0, 0);
        }
        switch(f.mState) {
            case Fragment.INITIALIZING:
                if (DEBUG)
                    Log.v(TAG, "moveto CREATED: " + f);
                if (f.mSavedFragmentState != null) {
                    f.mSavedViewState = f.mSavedFragmentState.getSparseParcelableArray(FragmentManagerImpl.VIEW_STATE_TAG);
                    f.mTarget = getFragment(f.mSavedFragmentState, FragmentManagerImpl.TARGET_STATE_TAG);
                    if (f.mTarget != null) {
                        f.mTargetRequestCode = f.mSavedFragmentState.getInt(FragmentManagerImpl.TARGET_REQUEST_CODE_STATE_TAG, 0);
                    }
                    f.mUserVisibleHint = f.mSavedFragmentState.getBoolean(FragmentManagerImpl.USER_VISIBLE_HINT_TAG, true);
                    if (!f.mUserVisibleHint) {
                        f.mDeferStart = true;
                        if (newState > Fragment.STOPPED) {
                            newState = Fragment.STOPPED;
                        }
                    }
                }
                f.mActivity = mActivity;
                f.mFragmentManager = mActivity.mFragments;
                f.mCalled = false;
                f.onAttach(mActivity);
                if (!f.mCalled) {
                    throw new SuperNotCalledException("Fragment " + f + " did not call through to super.onAttach()");
                }
                mActivity.onAttachFragment(f);
                if (!f.mRetaining) {
                    f.mCalled = false;
                    f.onCreate(f.mSavedFragmentState);
                    if (!f.mCalled) {
                        throw new SuperNotCalledException("Fragment " + f + " did not call through to super.onCreate()");
                    }
                }
                f.mRetaining = false;
                if (f.mFromLayout) {
                    // For fragments that are part of the content view
                    // layout, we need to instantiate the view immediately
                    // and the inflater will take care of adding it.
                    f.mView = f.onCreateView(f.getLayoutInflater(f.mSavedFragmentState), null, f.mSavedFragmentState);
                    if (f.mView != null) {
                        f.mView.setSaveFromParentEnabled(false);
                        if (f.mHidden)
                            f.mView.setVisibility(View.GONE);
                        f.onViewCreated(f.mView, f.mSavedFragmentState);
                    }
                }
            case Fragment.CREATED:
                if (newState > Fragment.CREATED) {
                    if (DEBUG)
                        Log.v(TAG, "moveto ACTIVITY_CREATED: " + f);
                    if (!f.mFromLayout) {
                        ViewGroup container = null;
                        if (f.mContainerId != 0) {
                            container = (ViewGroup) mActivity.findViewById(f.mContainerId);
                            if (container == null && !f.mRestored) {
                                throw new IllegalArgumentException("No view found for id 0x" + Integer.toHexString(f.mContainerId) + " for fragment " + f);
                            }
                        }
                        f.mContainer = container;
                        f.mView = f.onCreateView(f.getLayoutInflater(f.mSavedFragmentState), container, f.mSavedFragmentState);
                        if (f.mView != null) {
                            f.mView.setSaveFromParentEnabled(false);
                            if (container != null) {
                                Animator anim = loadAnimator(f, transit, true, transitionStyle);
                                if (anim != null) {
                                    anim.setTarget(f.mView);
                                    anim.start();
                                }
                                container.addView(f.mView);
                            }
                            if (f.mHidden)
                                f.mView.setVisibility(View.GONE);
                            f.onViewCreated(f.mView, f.mSavedFragmentState);
                        }
                    }
                    f.mCalled = false;
                    f.onActivityCreated(f.mSavedFragmentState);
                    if (!f.mCalled) {
                        throw new SuperNotCalledException("Fragment " + f + " did not call through to super.onActivityCreated()");
                    }
                    if (f.mView != null) {
                        f.restoreViewState();
                    }
                    f.mSavedFragmentState = null;
                }
            case Fragment.ACTIVITY_CREATED:
            case Fragment.STOPPED:
                if (newState > Fragment.STOPPED) {
                    if (DEBUG)
                        Log.v(TAG, "moveto STARTED: " + f);
                    f.mCalled = false;
                    f.performStart();
                    if (!f.mCalled) {
                        throw new SuperNotCalledException("Fragment " + f + " did not call through to super.onStart()");
                    }
                }
            case Fragment.STARTED:
                if (newState > Fragment.STARTED) {
                    if (DEBUG)
                        Log.v(TAG, "moveto RESUMED: " + f);
                    f.mCalled = false;
                    f.mResumed = true;
                    f.onResume();
                    if (!f.mCalled) {
                        throw new SuperNotCalledException("Fragment " + f + " did not call through to super.onResume()");
                    }
                    // Get rid of this in case we saved it and never needed it.
                    f.mSavedFragmentState = null;
                    f.mSavedViewState = null;
                }
        }
    } else if (f.mState > newState) {
        switch(f.mState) {
            case Fragment.RESUMED:
                if (newState < Fragment.RESUMED) {
                    if (DEBUG)
                        Log.v(TAG, "movefrom RESUMED: " + f);
                    f.mCalled = false;
                    f.onPause();
                    if (!f.mCalled) {
                        throw new SuperNotCalledException("Fragment " + f + " did not call through to super.onPause()");
                    }
                    f.mResumed = false;
                }
            case Fragment.STARTED:
                if (newState < Fragment.STARTED) {
                    if (DEBUG)
                        Log.v(TAG, "movefrom STARTED: " + f);
                    f.mCalled = false;
                    f.performStop();
                    if (!f.mCalled) {
                        throw new SuperNotCalledException("Fragment " + f + " did not call through to super.onStop()");
                    }
                }
            case Fragment.STOPPED:
            case Fragment.ACTIVITY_CREATED:
                if (newState < Fragment.ACTIVITY_CREATED) {
                    if (DEBUG)
                        Log.v(TAG, "movefrom ACTIVITY_CREATED: " + f);
                    if (f.mView != null) {
                        // done already.
                        if (!mActivity.isFinishing() && f.mSavedViewState == null) {
                            saveFragmentViewState(f);
                        }
                    }
                    f.mCalled = false;
                    f.performDestroyView();
                    if (!f.mCalled) {
                        throw new SuperNotCalledException("Fragment " + f + " did not call through to super.onDestroyView()");
                    }
                    if (f.mView != null && f.mContainer != null) {
                        Animator anim = null;
                        if (mCurState > Fragment.INITIALIZING && !mDestroyed) {
                            anim = loadAnimator(f, transit, false, transitionStyle);
                        }
                        if (anim != null) {
                            final ViewGroup container = f.mContainer;
                            final View view = f.mView;
                            final Fragment fragment = f;
                            container.startViewTransition(view);
                            f.mAnimatingAway = anim;
                            f.mStateAfterAnimating = newState;
                            anim.addListener(new AnimatorListenerAdapter() {

                                @Override
                                public void onAnimationEnd(Animator anim) {
                                    container.endViewTransition(view);
                                    if (fragment.mAnimatingAway != null) {
                                        fragment.mAnimatingAway = null;
                                        moveToState(fragment, fragment.mStateAfterAnimating, 0, 0);
                                    }
                                }
                            });
                            anim.setTarget(f.mView);
                            anim.start();
                        }
                        f.mContainer.removeView(f.mView);
                    }
                    f.mContainer = null;
                    f.mView = null;
                }
            case Fragment.CREATED:
                if (newState < Fragment.CREATED) {
                    if (mDestroyed) {
                        if (f.mAnimatingAway != null) {
                            // The fragment's containing activity is
                            // being destroyed, but this fragment is
                            // currently animating away.  Stop the
                            // animation right now -- it is not needed,
                            // and we can't wait any more on destroying
                            // the fragment.
                            Animator anim = f.mAnimatingAway;
                            f.mAnimatingAway = null;
                            anim.cancel();
                        }
                    }
                    if (f.mAnimatingAway != null) {
                        // We are waiting for the fragment's view to finish
                        // animating away.  Just make a note of the state
                        // the fragment now should move to once the animation
                        // is done.
                        f.mStateAfterAnimating = newState;
                        newState = Fragment.CREATED;
                    } else {
                        if (DEBUG)
                            Log.v(TAG, "movefrom CREATED: " + f);
                        if (!f.mRetaining) {
                            f.mCalled = false;
                            f.onDestroy();
                            if (!f.mCalled) {
                                throw new SuperNotCalledException("Fragment " + f + " did not call through to super.onDestroy()");
                            }
                        }
                        f.mCalled = false;
                        f.onDetach();
                        if (!f.mCalled) {
                            throw new SuperNotCalledException("Fragment " + f + " did not call through to super.onDetach()");
                        }
                        if (!f.mRetaining) {
                            makeInactive(f);
                        } else {
                            f.mActivity = null;
                            f.mFragmentManager = null;
                        }
                    }
                }
        }
    }
    f.mState = newState;
}
Example 27
Project: android_packages_apps-master  File: DayView.java View source code
// Sets up an animator for changing the height of the allday area
private ObjectAnimator getAllDayAnimator() {
    // Calculate the absolute max height
    int maxADHeight = mViewHeight - DAY_HEADER_HEIGHT - MIN_HOURS_HEIGHT;
    // Find the desired height but don't exceed abs max
    maxADHeight = Math.min(maxADHeight, (int) (mMaxAlldayEvents * MIN_UNEXPANDED_ALLDAY_EVENT_HEIGHT));
    // calculate the current and desired heights
    int currentHeight = mAnimateDayHeight != 0 ? mAnimateDayHeight : mAlldayHeight;
    int desiredHeight = mShowAllAllDayEvents ? maxADHeight : (int) (MAX_UNEXPANDED_ALLDAY_HEIGHT - MIN_UNEXPANDED_ALLDAY_EVENT_HEIGHT - 1);
    // Set up the animator with the calculated values
    ObjectAnimator animator = ObjectAnimator.ofInt(this, "animateDayHeight", currentHeight, desiredHeight);
    animator.setDuration(ANIMATION_DURATION);
    animator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            if (!mCancellingAnimations) {
                // when finished, set this to 0 to signify not animating
                mAnimateDayHeight = 0;
                mUseExpandIcon = !mShowAllAllDayEvents;
            }
            mRemeasure = true;
            invalidate();
        }
    });
    return animator;
}
Example 28
Project: plusTimer-master  File: CurrentSessionTimerFragment.java View source code
private void playLastBarEnterAnimation() {
    if (mLastBarAnimationSet != null) {
        mLastBarAnimationSet.cancel();
    }
    mLastDeleteButton.setEnabled(true);
    mLastDnfButton.setEnabled(true);
    mLastPlusTwoButton.setEnabled(true);
    ObjectAnimator enter = ObjectAnimator.ofFloat(mLastBarLinearLayout, View.TRANSLATION_Y, -mLastBarLinearLayout.getHeight());
    ObjectAnimator exit = ObjectAnimator.ofFloat(mLastBarLinearLayout, View.TRANSLATION_Y, 0f);
    enter.setDuration(125);
    exit.setDuration(125);
    exit.setStartDelay(2000);
    enter.setInterpolator(new LinearOutSlowInInterpolator());
    exit.setInterpolator(new FastOutLinearInInterpolator());
    mLastBarAnimationSet = new AnimatorSet();
    mLastBarAnimationSet.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animation) {
            super.onAnimationStart(animation);
            mLastBarLinearLayout.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            if (mLastBarLinearLayout.getTranslationY() == 0f) {
                mLastBarLinearLayout.setVisibility(View.GONE);
            }
        }
    });
    mLastBarAnimationSet.playSequentially(enter, exit);
    mLastBarAnimationSet.start();
}
Example 29
Project: firetweet-master  File: DynamicGridView.java View source code
/**
	 * Resets all the appropriate fields to a default state while also animating
	 * the hover cell back to its correct location.
	 */
private void touchEventsEnded() {
    final View mobileView = getViewForID(mMobileItemId);
    if (mCellIsMobile || mIsWaitingForScrollFinish) {
        mCellIsMobile = false;
        mIsWaitingForScrollFinish = false;
        mIsMobileScrolling = false;
        mActivePointerId = INVALID_POINTER_ID;
        // should be animated to.
        if (mScrollState != OnScrollListener.SCROLL_STATE_IDLE) {
            mIsWaitingForScrollFinish = true;
            return;
        }
        mHoverCellCurrentBounds.offsetTo(mobileView.getLeft(), mobileView.getTop());
        final ObjectAnimator hoverViewAnimator = ObjectAnimator.ofObject(mHoverCell, "bounds", sBoundEvaluator, mHoverCellCurrentBounds);
        hoverViewAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(final ValueAnimator valueAnimator) {
                invalidate();
            }
        });
        hoverViewAnimator.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(final Animator animation) {
                mMobileItemId = INVALID_ID;
                mobileView.setVisibility(VISIBLE);
                mHoverCell = null;
                setEnabled(true);
                invalidate();
            }

            @Override
            public void onAnimationStart(final Animator animation) {
                setEnabled(false);
            }
        });
        hoverViewAnimator.start();
    } else {
        touchEventsCancelled();
    }
}
Example 30
Project: GBSlideBar-master  File: GBSlideBar.java View source code
private void endSlide() {
    if (mIsEndAnimation == false && mSlide) {
        mIsEndAnimation = true;
        mEndAnim = ValueAnimator.ofFloat(0.0f, 1.0f);
        mEndAnim.setDuration(200);
        mEndAnim.setInterpolator(new LinearInterpolator());
        mEndAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                mSlideX = (int) ((mCurrentX - mLastX) * animation.getAnimatedFraction() + mLastX);
                mSlideY = (int) (mCurrentY * animation.getAnimatedFraction());
                invalidate();
            }
        });
        mEndAnim.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                mIsStartAnimation = false;
                mLastX = mCurrentX;
                mIsEndAnimation = false;
                mCanSelect = true;
                invalidate();
            }
        });
        mEndAnim.start();
    } else {
        mLastX = mCurrentX;
        mSlideX = mCurrentX;
        invalidate();
    }
}
Example 31
Project: Transitions-Everywhere-master  File: Transition.java View source code
private void runAnimator(Animator animator, final ArrayMap<Animator, AnimationInfo> runningAnimators) {
    if (animator != null) {
        // TODO: could be a single listener instance for all of them since it uses the param
        animator.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationStart(Animator animation) {
                mCurrentAnimators.add(animation);
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                runningAnimators.remove(animation);
                mCurrentAnimators.remove(animation);
            }
        });
        animate(animator);
    }
}
Example 32
Project: FORMWatchFace-master  File: CompanionWatchFaceConfigActivity.java View source code
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void updateUIToSelectedTheme(final String themeId, final boolean animate) {
    for (final ThemeUiHolder holder : mThemeUiHolders) {
        boolean selected = holder.theme.id.equals(themeId);
        holder.button.setSelected(selected);
        if (holder.selected != selected && selected) {
            if (mCurrentRevealAnimator != null) {
                mCurrentRevealAnimator.end();
                updatePreviewView(mAnimatingTheme, mMainClockContainerView, mMainClockView);
            }
            if (animate && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                mAnimatingTheme = holder.theme;
                updatePreviewView(mAnimatingTheme, mAnimateClockContainerView, mAnimateClockView);
                Rect buttonRect = new Rect();
                Rect clockContainerRect = new Rect();
                holder.button.getGlobalVisibleRect(buttonRect);
                mMainClockContainerView.getGlobalVisibleRect(clockContainerRect);
                int cx = buttonRect.centerX() - clockContainerRect.left;
                int cy = buttonRect.centerY() - clockContainerRect.top;
                clockContainerRect.offsetTo(0, 0);
                mCurrentRevealAnimator = ViewAnimationUtils.createCircularReveal(mAnimateClockContainerView, cx, cy, 0, MathUtil.maxDistanceToCorner(clockContainerRect, cx, cy));
                mAnimateClockContainerView.setVisibility(View.VISIBLE);
                mCurrentRevealAnimator.setDuration(300);
                mCurrentRevealAnimator.addListener(new AnimatorListenerAdapter() {

                    @Override
                    public void onAnimationEnd(Animator animation) {
                        if (mCurrentRevealAnimator == animation) {
                            mAnimateClockContainerView.setVisibility(View.INVISIBLE);
                            updatePreviewView(holder.theme, mMainClockContainerView, mMainClockView);
                        }
                    }
                });
                mAnimateClockView.postInvalidateOnAnimation();
                mCurrentRevealAnimator.start();
            } else {
                updatePreviewView(holder.theme, mMainClockContainerView, mMainClockView);
            }
        }
        holder.selected = selected;
    }
}
Example 33
Project: silent-contacts-android-master  File: FloatingChildLayout.java View source code
/** Creates the open/close animation */
private void animateScale(final boolean isExitAnimation, final Runnable onAnimationEndRunnable) {
    mChild.setPivotX(mTargetScreen.centerX() - mChild.getLeft());
    mChild.setPivotY(mTargetScreen.centerY() - mChild.getTop());
    final int scaleInterpolator = isExitAnimation ? android.R.interpolator.accelerate_quint : android.R.interpolator.decelerate_quint;
    final float scaleTarget = isExitAnimation ? 0.5f : 1.0f;
    mChild.animate().setDuration(mAnimationDuration).setInterpolator(AnimationUtils.loadInterpolator(getContext(), scaleInterpolator)).scaleX(scaleTarget).scaleY(scaleTarget).alpha(isExitAnimation ? 0.0f : 1.0f).setListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mChild.setLayerType(LAYER_TYPE_NONE, null);
            if (isExitAnimation) {
                if (mForegroundPhase == ForegroundPhase.DISAPPEARING) {
                    mForegroundPhase = ForegroundPhase.AFTER;
                    if (onAnimationEndRunnable != null)
                        onAnimationEndRunnable.run();
                }
            } else {
                if (mForegroundPhase == ForegroundPhase.APPEARING) {
                    mForegroundPhase = ForegroundPhase.IDLE;
                    if (onAnimationEndRunnable != null)
                        onAnimationEndRunnable.run();
                }
            }
        }
    });
}
Example 34
Project: SealBrowser-master  File: TabsScroller.java View source code
private void animateOut(final View v, float velocity, float start) {
    if ((v == null) || (mAnimator != null))
        return;
    final int position = mContentView.indexOfChild(v);
    int target = 0;
    if (velocity < 0) {
        target = mHorizontal ? -getHeight() : -getWidth();
    } else {
        target = mHorizontal ? getHeight() : getWidth();
    }
    int distance = target - (mHorizontal ? v.getTop() : v.getLeft());
    long duration = (long) (Math.abs(distance) * 1000 / Math.abs(velocity));
    int scroll = 0;
    int translate = 0;
    int gap = mHorizontal ? v.getWidth() : v.getHeight();
    int centerView = getViewCenter(v);
    int centerScreen = getScreenCenter();
    int newpos = INVALID_POSITION;
    if (centerView < centerScreen - gap / 2) {
        // top view
        scroll = -(centerScreen - centerView - gap);
        translate = (position > 0) ? gap : 0;
        newpos = position;
    } else if (centerView > centerScreen + gap / 2) {
        // bottom view
        scroll = -(centerScreen + gap - centerView);
        if (position < mAdapter.getCount() - 1) {
            translate = -gap;
        }
    } else {
        // center view
        scroll = -(centerScreen - centerView);
        if (position < mAdapter.getCount() - 1) {
            translate = -gap;
        } else {
            scroll -= gap;
        }
    }
    mGapPosition = position;
    final int pos = newpos;
    ObjectAnimator trans = ObjectAnimator.ofFloat(v, (mHorizontal ? TRANSLATION_Y : TRANSLATION_X), start, target);
    ObjectAnimator alpha = ObjectAnimator.ofFloat(v, ALPHA, getAlpha(v, start), getAlpha(v, target));
    AnimatorSet set1 = new AnimatorSet();
    set1.playTogether(trans, alpha);
    set1.setDuration(duration);
    mAnimator = new AnimatorSet();
    ObjectAnimator trans2 = null;
    ObjectAnimator scroll1 = null;
    if (scroll != 0) {
        if (mHorizontal) {
            scroll1 = ObjectAnimator.ofInt(this, "scrollX", getScrollX(), getScrollX() + scroll);
        } else {
            scroll1 = ObjectAnimator.ofInt(this, "scrollY", getScrollY(), getScrollY() + scroll);
        }
    }
    if (translate != 0) {
        trans2 = ObjectAnimator.ofInt(this, "gap", 0, translate);
    }
    final int duration2 = 200;
    if (scroll1 != null) {
        if (trans2 != null) {
            AnimatorSet set2 = new AnimatorSet();
            set2.playTogether(scroll1, trans2);
            set2.setDuration(duration2);
            mAnimator.playSequentially(set1, set2);
        } else {
            scroll1.setDuration(duration2);
            mAnimator.playSequentially(set1, scroll1);
        }
    } else {
        if (trans2 != null) {
            trans2.setDuration(duration2);
            mAnimator.playSequentially(set1, trans2);
        }
    }
    mAnimator.addListener(new AnimatorListenerAdapter() {

        public void onAnimationEnd(Animator a) {
            if (mRemoveListener != null) {
                mRemoveListener.onRemovePosition(position);
                mAnimator = null;
                mGapPosition = INVALID_POSITION;
                mGap = 0;
                handleDataChanged(pos);
            }
        }
    });
    mAnimator.start();
}
Example 35
Project: clapir-master  File: MainActivity.java View source code
private void createCustomAnimations(LayoutTransition transition) {
    // Changing while Adding
    PropertyValuesHolder pvhLeft = PropertyValuesHolder.ofInt("left", 0, 1);
    PropertyValuesHolder pvhTop = PropertyValuesHolder.ofInt("top", 0, 1);
    PropertyValuesHolder pvhRight = PropertyValuesHolder.ofInt("right", 0, 1);
    PropertyValuesHolder pvhBottom = PropertyValuesHolder.ofInt("bottom", 0, 1);
    PropertyValuesHolder pvhScaleX = PropertyValuesHolder.ofFloat("translationX", 1f, 0f, 1f);
    PropertyValuesHolder pvhScaleY = PropertyValuesHolder.ofFloat("translationY", 1f, 0f, 1f);
    customChangingAppearingAnim = ObjectAnimator.ofPropertyValuesHolder(this, pvhLeft, pvhTop, pvhRight, pvhBottom, pvhScaleX, pvhScaleY).setDuration(transition.getDuration(LayoutTransition.CHANGE_APPEARING));
    customChangingAppearingAnim.addListener(new AnimatorListenerAdapter() {

        public void onAnimationEnd(Animator anim) {
            View view = (View) ((ObjectAnimator) anim).getTarget();
            view.setScaleX(1f);
            view.setScaleY(1f);
        }
    });
    customChangingAppearingAnim = transition.getAnimator(LayoutTransition.CHANGE_APPEARING);
    // Changing while Removing
    Keyframe kf0 = Keyframe.ofFloat(0f, 0f);
    Keyframe kf1 = Keyframe.ofFloat(.9999f, 360f);
    Keyframe kf2 = Keyframe.ofFloat(1f, 0f);
    PropertyValuesHolder pvhRotation = PropertyValuesHolder.ofKeyframe("translationY", kf0, kf1, kf2);
    customChangingDisappearingAnim = ObjectAnimator.ofPropertyValuesHolder(this, pvhLeft, pvhTop, pvhRight, pvhBottom, pvhRotation).setDuration(transition.getDuration(LayoutTransition.CHANGE_DISAPPEARING));
    customChangingDisappearingAnim.addListener(new AnimatorListenerAdapter() {

        public void onAnimationEnd(Animator anim) {
            View view = (View) ((ObjectAnimator) anim).getTarget();
            view.setRotation(0f);
        }
    });
    // Adding
    PropertyValuesHolder pvhTranslateY = PropertyValuesHolder.ofFloat("translationY", 300, 0);
    PropertyValuesHolder pvhAlpha = PropertyValuesHolder.ofFloat("alpha", 0, 1);
    customAppearingAnim = ObjectAnimator.ofPropertyValuesHolder(this, pvhTranslateY, pvhAlpha).setDuration(transition.getDuration(LayoutTransition.APPEARING));
    customAppearingAnim.addListener(new AnimatorListenerAdapter() {

        public void onAnimationEnd(Animator anim) {
            View view = (View) ((ObjectAnimator) anim).getTarget();
            view.setRotationY(0f);
        }
    });
    // Removing
    customDisappearingAnim = ObjectAnimator.ofFloat(null, "alpha", 1, 0).setDuration(transition.getDuration(LayoutTransition.DISAPPEARING) / 2);
    customDisappearingAnim.addListener(new AnimatorListenerAdapter() {

        public void onAnimationEnd(Animator anim) {
            View view = (View) ((ObjectAnimator) anim).getTarget();
            view.setRotationX(0f);
        }
    });
}
Example 36
Project: android_packages_apps_IconFilterDesigner-master  File: DynamicListView.java View source code
/**
     * Resets all the appropriate fields to a default state while also animating
     * the hover cell back to its correct location.
     */
private void touchEventsEnded() {
    final View mobileView = getViewForID(mMobileItemId);
    if (mCellIsMobile || mIsWaitingForScrollFinish) {
        mCellIsMobile = false;
        mIsWaitingForScrollFinish = false;
        mIsMobileScrolling = false;
        mActivePointerId = INVALID_POINTER_ID;
        // should be animated to.
        if (mScrollState != OnScrollListener.SCROLL_STATE_IDLE) {
            mIsWaitingForScrollFinish = true;
            return;
        }
        mHoverCellCurrentBounds.offsetTo(mHoverCellOriginalBounds.left, mobileView.getTop());
        ObjectAnimator hoverViewAnimator = ObjectAnimator.ofObject(mHoverCell, "bounds", sBoundEvaluator, mHoverCellCurrentBounds);
        hoverViewAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                invalidate();
            }
        });
        hoverViewAnimator.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationStart(Animator animation) {
                setEnabled(false);
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                mAboveItemId = INVALID_ID;
                mMobileItemId = INVALID_ID;
                mBelowItemId = INVALID_ID;
                mobileView.setVisibility(VISIBLE);
                mHoverCell = null;
                setEnabled(true);
                invalidate();
            }
        });
        hoverViewAnimator.start();
    } else {
        touchEventsCancelled();
    }
}
Example 37
Project: android-FlipView-master  File: FlipView.java View source code
private void peak(boolean next, boolean once) {
    final float baseFlipDistance = mCurrentPageIndex * FLIP_DISTANCE_PER_PAGE;
    if (next) {
        mPeakAnim = ValueAnimator.ofFloat(baseFlipDistance, baseFlipDistance + FLIP_DISTANCE_PER_PAGE / 4);
    } else {
        mPeakAnim = ValueAnimator.ofFloat(baseFlipDistance, baseFlipDistance - FLIP_DISTANCE_PER_PAGE / 4);
    }
    mPeakAnim.setInterpolator(mPeakInterpolator);
    mPeakAnim.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            setFlipDistance((Float) animation.getAnimatedValue());
        }
    });
    mPeakAnim.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            endPeak();
        }
    });
    mPeakAnim.setDuration(PEAK_ANIM_DURATION);
    mPeakAnim.setRepeatMode(ValueAnimator.REVERSE);
    mPeakAnim.setRepeatCount(once ? 1 : ValueAnimator.INFINITE);
    mPeakAnim.start();
}
Example 38
Project: beepme-master  File: GlowPadView.java View source code
private void startWaveAnimation() {
    mWaveAnimations.cancel();
    mPointCloud.waveManager.setAlpha(1.0f);
    mPointCloud.waveManager.setRadius(mHandleDrawable.getWidth() / 2.0f);
    mWaveAnimations.add(Tweener.to(mPointCloud.waveManager, WAVE_ANIMATION_DURATION, "ease", Ease.Quad.easeOut, "delay", 0, "radius", 2.0f * mOuterRadius, "onUpdate", mUpdateListener, "onComplete", new AnimatorListenerAdapter() {

        public void onAnimationEnd(Animator animator) {
            mPointCloud.waveManager.setRadius(0.0f);
            mPointCloud.waveManager.setAlpha(0.0f);
        }
    }));
    mWaveAnimations.start();
}
Example 39
Project: AmazeFileManager-master  File: Futils.java View source code
public void crossfade(View buttons, final View pathbar) {
    // Set the content view to 0% opacity but visible, so that it is visible
    // (but fully transparent) during the animation.
    buttons.setAlpha(0f);
    buttons.setVisibility(View.VISIBLE);
    // Animate the content view to 100% opacity, and clear any animation
    // listener set on the view.
    buttons.animate().alpha(1f).setDuration(100).setListener(null);
    pathbar.animate().alpha(0f).setDuration(100).setListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            pathbar.setVisibility(View.GONE);
        }
    });
// Animate the loading view to 0% opacity. After the animation ends,
// set its visibility to GONE as an optimization step (it won't
// participate in layout passes, etc.)
}
Example 40
Project: SulfurKeyboard-master  File: ViewPropertyAnimatorCompat.java View source code
static void setListener(final View view, final ViewPropertyAnimatorListener listener) {
    if (listener != null) {
        view.animate().setListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationCancel(Animator animation) {
                listener.onAnimationCancel(view);
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                listener.onAnimationEnd(view);
            }

            @Override
            public void onAnimationStart(Animator animation) {
                listener.onAnimationStart(view);
            }
        });
    } else {
        view.animate().setListener(null);
    }
}
Example 41
Project: AcDisplay-master  File: AcDisplayFragment.java View source code
//-- SWIPE-TO-DISMISS -----------------------------------------------------
private boolean swipeToDismiss() {
    if (!isDismissible(mSelectedWidget))
        return false;
    mVelocityTracker.computeCurrentVelocity(1000);
    float velocityX = mVelocityTracker.getXVelocity();
    float velocityY = mVelocityTracker.getYVelocity();
    float absVelocityX = Math.abs(velocityX);
    float absVelocityY = Math.abs(velocityY);
    float deltaY = mSceneContainer.getTranslationY();
    float absDeltaY = Math.abs(deltaY);
    int height = getSceneView().getHeight();
    if (height == 0) {
        // Scene view is not measured yet.
        return false;
    } else if (absDeltaY < height / 2) {
        boolean dismiss = false;
        if (mMinFlingVelocity <= absVelocityY && absVelocityY <= mMaxFlingVelocity && absVelocityY > absVelocityX * 2 && absDeltaY > height / 5) {
            // Dismiss only if flinging in the same direction as dragging
            dismiss = (velocityY < 0) == (deltaY < 0);
        }
        if (!dismiss) {
            return false;
        }
    }
    if (height > absDeltaY && isAnimatable()) {
        int duration;
        duration = Math.round(1000f * /* ms. */
        (height - absDeltaY) / absVelocityX);
        duration = Math.min(duration, 300);
        final Widget widget = mSelectedWidget;
        float progress = MathUtils.range(deltaY / height, 0f, 1f);
        if (mStdAnimator != null)
            mStdAnimator.cancel();
        mStdAnimator = ObjectAnimator.ofFloat(this, TRANSFORM, progress, 1f);
        mStdAnimator.setDuration(duration);
        mStdAnimator.addListener(new AnimatorListenerAdapter() {

            /**
                 * [email protected]}
                 */
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                onWidgetDismiss(widget);
            }

            @Override
            public void onAnimationCancel(Animator animation) {
                super.onAnimationCancel(animation);
                onWidgetDismiss(widget);
            }
        });
        mStdAnimator.start();
    } else {
        onWidgetDismiss(mSelectedWidget);
    }
    return true;
}