Search in sources :

Example 6 with AnimatorListener

use of android.animation.Animator.AnimatorListener in project platform_frameworks_base by android.

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 7 with AnimatorListener

use of android.animation.Animator.AnimatorListener in project platform_frameworks_base by android.

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 8 with AnimatorListener

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

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 9 with AnimatorListener

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

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 10 with AnimatorListener

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

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)

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