Search in sources :

Example 26 with AnimatorListener

use of android.animation.Animator.AnimatorListener in project UltimateAndroid by cymcsg.

the class DefaultLayoutAnimator method animateChanges.

@Override
public void animateChanges(LayoutChangeset changeSet, final FreeFlowContainer callback) {
    this.changeSet = changeSet;
    this.callback = callback;
    cancel();
    mIsRunning = true;
    disappearingSet = null;
    appearingSet = null;
    movingSet = null;
    Comparator<FreeFlowItem> cmp = new Comparator<FreeFlowItem>() {

        @Override
        public int compare(FreeFlowItem lhs, FreeFlowItem rhs) {
            return (lhs.itemSection * 1000 + lhs.itemIndex) - (rhs.itemSection * 1000 + rhs.itemIndex);
        }
    };
    List<FreeFlowItem> removed = changeSet.getRemoved();
    if (removed.size() > 0) {
        Collections.sort(removed, cmp);
        disappearingSet = getItemsRemovedAnimation(changeSet.getRemoved());
    }
    List<FreeFlowItem> added = changeSet.getAdded();
    if (added.size() > 0) {
        Collections.sort(added, cmp);
        appearingSet = getItemsAddedAnimation(added);
    }
    if (changeSet.getMoved().size() > 0) {
        movingSet = getItemsMovedAnimation(changeSet.getMoved());
    }
    AnimatorSet all = getAnimationSequence();
    if (all == null) {
        mIsRunning = false;
        callback.onLayoutChangeAnimationsCompleted(this);
    } else {
        all.addListener(new AnimatorListener() {

            @Override
            public void onAnimationStart(Animator animation) {
            }

            @Override
            public void onAnimationRepeat(Animator animation) {
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                mIsRunning = false;
                callback.onLayoutChangeAnimationsCompleted(DefaultLayoutAnimator.this);
            }

            @Override
            public void onAnimationCancel(Animator animation) {
            }
        });
        all.start();
    }
}
Also used : AnimatorListener(android.animation.Animator.AnimatorListener) ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorSet(android.animation.AnimatorSet) FreeFlowItem(com.marshalchen.common.uimodule.freeflow.core.FreeFlowItem) Comparator(java.util.Comparator)

Example 27 with AnimatorListener

use of android.animation.Animator.AnimatorListener in project android_frameworks_base by DirtyUnicorns.

the class SettingsButton method startAccelSpin.

protected void startAccelSpin() {
    cancelAnimation();
    mAnimator = ObjectAnimator.ofFloat(this, View.ROTATION, 0, 360);
    mAnimator.setInterpolator(AnimationUtils.loadInterpolator(mContext, android.R.interpolator.accelerate_quad));
    mAnimator.setDuration(ACCEL_LENGTH);
    mAnimator.addListener(new AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            startContinuousSpin();
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }
    });
    mAnimator.start();
}
Also used : AnimatorListener(android.animation.Animator.AnimatorListener) ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator)

Example 28 with AnimatorListener

use of android.animation.Animator.AnimatorListener in project android_frameworks_base by ResurrectionRemix.

the class QSDetail method handleShowingDetail.

private void handleShowingDetail(final QSTile.DetailAdapter adapter, int x, int y) {
    final boolean showingDetail = adapter != null;
    setClickable(showingDetail);
    if (showingDetail) {
        mQsDetailHeaderTitle.setText(adapter.getTitle());
        final Boolean toggleState = adapter.getToggleState();
        if (toggleState == null) {
            mQsDetailHeaderSwitch.setVisibility(INVISIBLE);
            mQsDetailHeader.setClickable(false);
        } else {
            mQsDetailHeaderSwitch.setVisibility(VISIBLE);
            handleToggleStateChanged(toggleState, adapter.getToggleEnabled());
            mQsDetailHeader.setClickable(true);
            mQsDetailHeader.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    boolean checked = !mQsDetailHeaderSwitch.isChecked();
                    mQsDetailHeaderSwitch.setChecked(checked);
                    adapter.setToggleState(checked);
                }
            });
        }
        if (!mFullyExpanded) {
            mTriggeredExpand = true;
            mHost.animateToggleQSExpansion();
        } else {
            mTriggeredExpand = false;
        }
        mOpenX = x;
        mOpenY = y;
    } else {
        // Ensure we collapse into the same point we opened from.
        x = mOpenX;
        y = mOpenY;
        if (mTriggeredExpand) {
            mHost.animateToggleQSExpansion();
            mTriggeredExpand = false;
        }
    }
    boolean visibleDiff = (mDetailAdapter != null) != (adapter != null);
    // already in right state
    if (!visibleDiff && mDetailAdapter == adapter)
        return;
    AnimatorListener listener = null;
    if (adapter != null) {
        int viewCacheIndex = adapter.getMetricsCategory();
        View detailView = adapter.createDetailView(mContext, mDetailViews.get(viewCacheIndex), mDetailContent);
        if (detailView == null)
            throw new IllegalStateException("Must return detail view");
        final Intent settingsIntent = adapter.getSettingsIntent();
        mDetailSettingsButton.setVisibility(settingsIntent != null ? VISIBLE : GONE);
        mDetailSettingsButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                mHost.startActivityDismissingKeyguard(settingsIntent);
            }
        });
        mDetailContent.removeAllViews();
        mDetailContent.addView(detailView);
        mDetailViews.put(viewCacheIndex, detailView);
        MetricsLogger.visible(mContext, adapter.getMetricsCategory());
        announceForAccessibility(mContext.getString(R.string.accessibility_quick_settings_detail, adapter.getTitle()));
        mDetailAdapter = adapter;
        listener = mHideGridContentWhenDone;
        setVisibility(View.VISIBLE);
    } else {
        if (mDetailAdapter != null) {
            MetricsLogger.hidden(mContext, mDetailAdapter.getMetricsCategory());
        }
        mClosingDetail = true;
        mDetailAdapter = null;
        listener = mTeardownDetailWhenDone;
        mHeader.setVisibility(View.VISIBLE);
        mQsPanel.setGridContentVisibility(true);
        mQsPanelCallback.onScanStateChanged(false);
    }
    sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
    if (visibleDiff) {
        mAnimatingOpen = adapter != null;
        if (mFullyExpanded || mDetailAdapter != null) {
            setAlpha(1);
            mClipper.animateCircularClip(x, y, mDetailAdapter != null, listener);
        } else {
            animate().alpha(0).setDuration(FADE_DURATION).setListener(listener).start();
        }
    }
}
Also used : AnimatorListener(android.animation.Animator.AnimatorListener) Intent(android.content.Intent) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Example 29 with AnimatorListener

use of android.animation.Animator.AnimatorListener in project android_frameworks_base by ResurrectionRemix.

the class SettingsButton method startAccelSpin.

protected void startAccelSpin() {
    cancelAnimation();
    mAnimator = ObjectAnimator.ofFloat(this, View.ROTATION, 0, 360);
    mAnimator.setInterpolator(AnimationUtils.loadInterpolator(mContext, android.R.interpolator.accelerate_quad));
    mAnimator.setDuration(ACCEL_LENGTH);
    mAnimator.addListener(new AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            startContinuousSpin();
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }
    });
    mAnimator.start();
}
Also used : AnimatorListener(android.animation.Animator.AnimatorListener) ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator)

Example 30 with AnimatorListener

use of android.animation.Animator.AnimatorListener in project RecyclerViewAnimator by dkmeteor.

the class HingeOut method startAnimation.

@Override
public void startAnimation(final ViewHolder holder, long duration, final BaseItemAnimator animator) {
    ViewCompat.animate(holder.itemView).cancel();
    AnimatorSet set = new AnimatorSet();
    View target = holder.itemView;
    int abs = Math.random() > 0.5 ? -1 : 1;
    float x, y;
    if (abs > 0) {
        x = target.getPaddingLeft();
        y = target.getPaddingTop();
    } else {
        x = target.getWidth();
        y = target.getPaddingTop();
    }
    set.setDuration(animator.getRemoveDuration());
    set.addListener(new AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            animator.dispatchAddFinished(holder);
            animator.mAddAnimations.remove(holder);
            animator.dispatchFinishedWhenDone();
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }
    });
    set.playTogether(ObjectAnimator.ofFloat(target, "rotation", 0, abs * 80, abs * 60, abs * 80, abs * 60, abs * 60), ObjectAnimator.ofFloat(target, "translationY", 0, 0, 0, 0, 0, 700), ObjectAnimator.ofFloat(target, "alpha", 1, 1, 1, 1, 1, 0), ObjectAnimator.ofFloat(target, "pivotX", x, x, x, x, x, x), ObjectAnimator.ofFloat(target, "pivotY", y, y, y, y, y, y));
    set.setStartDelay(mDelay * mDelayCount);
    set.setDuration(animator.getAddDuration());
    set.start();
    animator.mAddAnimations.add(holder);
}
Also used : AnimatorListener(android.animation.Animator.AnimatorListener) BaseItemAnimator(com.dk.animation.effect.BaseItemAnimator) ObjectAnimator(android.animation.ObjectAnimator) SegmentAnimator(com.dk.animation.effect.SegmentAnimator) Animator(android.animation.Animator) AnimatorSet(android.animation.AnimatorSet) View(android.view.View)

Aggregations

AnimatorListener (android.animation.Animator.AnimatorListener)32 ObjectAnimator (android.animation.ObjectAnimator)25 Animator (android.animation.Animator)24 AnimatorSet (android.animation.AnimatorSet)10 ValueAnimator (android.animation.ValueAnimator)8 View (android.view.View)8 ImageView (android.widget.ImageView)6 TextView (android.widget.TextView)6 BaseItemAnimator (com.dk.animation.effect.BaseItemAnimator)6 SegmentAnimator (com.dk.animation.effect.SegmentAnimator)6 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)5 Intent (android.content.Intent)5 ArrayList (java.util.ArrayList)4 PropertyValuesHolder (android.animation.PropertyValuesHolder)3 TimeInterpolator (android.animation.TimeInterpolator)3 ArgbEvaluator (android.animation.ArgbEvaluator)2 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)2 Comparator (java.util.Comparator)2 SuppressLint (android.annotation.SuppressLint)1 Paint (android.graphics.Paint)1