private long[] getCurrentPlayTimeByState(State mState) {
   long[] tab = new long[3];
   switch (mState) {
     case ANIMATING_LINE_TO_DOT:
       for (int i = 0; i < mArrowToLineAnimatorSet.getChildAnimations().size(); i++) {
         tab[i] =
             ((ValueAnimator) mArrowToLineAnimatorSet.getChildAnimations().get(i))
                 .getCurrentPlayTime();
       }
       mArrowToLineAnimatorSet.cancel();
       break;
     case ANIMATING_PROGRESS:
       for (int i = 0; i < mProgressAnimationSet.getChildAnimations().size(); i++) {
         tab[i] =
             ((ValueAnimator) mProgressAnimationSet.getChildAnimations().get(i))
                 .getCurrentPlayTime();
       }
       mProgressAnimationSet.cancel();
       break;
     case ANIMATING_ERROR:
       tab[0] = mErrorAnimation.getCurrentPlayTime();
       mErrorAnimation.cancel();
       break;
     case ANIMATING_SUCCESS:
       tab[0] = mSuccessAnimation.getCurrentPlayTime();
       mSuccessAnimation.cancel();
       break;
   }
   return tab;
 }
 public void setPressed(boolean pressed) {
   if (mGlowBG != null) {
     if (pressed != isPressed()) {
       if (mPressedAnim != null && mPressedAnim.isRunning()) {
         mPressedAnim.cancel();
       }
       final AnimatorSet as = mPressedAnim = new AnimatorSet();
       if (pressed) {
         if (mGlowScale < GLOW_MAX_SCALE_FACTOR) mGlowScale = GLOW_MAX_SCALE_FACTOR;
         if (mGlowAlpha < BUTTON_QUIESCENT_ALPHA) mGlowAlpha = BUTTON_QUIESCENT_ALPHA;
         setDrawingAlpha(1f);
         as.playTogether(
             ObjectAnimator.ofFloat(this, "glowAlpha", 1f),
             ObjectAnimator.ofFloat(this, "glowScale", GLOW_MAX_SCALE_FACTOR));
         as.setDuration(50);
       } else {
         as.playTogether(
             ObjectAnimator.ofFloat(this, "glowAlpha", 0f),
             ObjectAnimator.ofFloat(this, "glowScale", 1f),
             ObjectAnimator.ofFloat(this, "drawingAlpha", BUTTON_QUIESCENT_ALPHA));
         as.setDuration(500);
       }
       as.start();
     }
   }
   super.setPressed(pressed);
 }
 public void setPressed(boolean pressed) {
   if (mGlowBG != null) {
     if (pressed != isPressed()) {
       if (mPressedAnim != null && mPressedAnim.isRunning()) {
         mPressedAnim.cancel();
       }
       final AnimatorSet as = mPressedAnim = new AnimatorSet();
       if (pressed) {
         if (mGlowScale < GLOW_MAX_SCALE_FACTOR) mGlowScale = GLOW_MAX_SCALE_FACTOR;
         if (mGlowAlpha < mQuiescentAlpha) mGlowAlpha = mQuiescentAlpha;
         setDrawingAlpha(1f);
         as.playTogether(
             ObjectAnimator.ofFloat(this, "glowAlpha", 1f),
             ObjectAnimator.ofFloat(this, "glowScale", GLOW_MAX_SCALE_FACTOR));
         as.setDuration(50);
       } else {
         mAnimateToQuiescent.cancel();
         mAnimateToQuiescent = animateToQuiescent();
         as.playTogether(
             ObjectAnimator.ofFloat(this, "glowAlpha", 0f),
             ObjectAnimator.ofFloat(this, "glowScale", 1f),
             mAnimateToQuiescent);
         as.setDuration(500);
       }
       as.start();
     }
   }
   super.setPressed(pressed);
 }
Пример #4
0
 public void expand() {
   if (!mExpanded) {
     mExpanded = true;
     mCollapseAnimation.cancel();
     mExpandAnimation.start();
   }
 }
Пример #5
0
        @Override
        public void dispatchMessage(Message msg) {
          switch (msg.what) {
            case START_FOCUS_MSG:
              // 开始对焦操作
              _startFocus((PointF) msg.obj);

              break;

            case FINISH_FOCUS_MSG:
              animSet.end(); // 结束动画
              FocusView.this.setColorFilter(ColorUtil.FOCUS_COLOR); // 改变图标的颜色

              break;

            case DISAPPEAR_MSG:
              // 将控件消失
              FocusView.this.clearColorFilter(); // 清除颜色过滤
              FocusView.this.setVisibility(View.GONE); // 控件不可见

              break;
            case CANCEL_FOCUS_MSG:
              /** 停止对焦操作 */
              animSet.cancel(); // 取消动画

              FocusView.this.clearColorFilter(); // 清除颜色过滤
              FocusView.this.setVisibility(View.GONE); // 控件不可见

              break;
          }
        }
Пример #6
0
 public void collapse() {
   if (mExpanded) {
     mExpanded = false;
     mCollapseAnimation.start();
     mExpandAnimation.cancel();
   }
 }
 public void animateHidden() {
   if (!mIsHiddenOrHiding) {
     mVisibleAnimator.cancel();
     mHiddenAnimator.end();
     mHiddenAnimator.start();
   }
   mIsHiddenOrHiding = true;
 }
Пример #8
0
 /** Starts the animation. */
 public void start() {
   resetAllPaths();
   animatorSet.cancel();
   animatorSet.setDuration(duration);
   animatorSet.setInterpolator(interpolator);
   animatorSet.setStartDelay(delay);
   animatorSet.start();
 }
 public void show() {
   if (bubbleHideAnimator != null) {
     bubbleHideAnimator.cancel();
   }
   getHandler().removeCallbacks(bubbleHider);
   if (getVisibility() == INVISIBLE) {
     animateShow();
   }
 }
  private void cancelAnimations() {
    if (rippleAnimator != null) {
      rippleAnimator.cancel();
      rippleAnimator.removeAllListeners();
    }

    if (hoverAnimator != null) {
      hoverAnimator.cancel();
    }
  }
Пример #11
0
 @Override
 public final void onDragStart(DragSource source, Object info, int dragAction) {
   mActive = supportsDrop(source, info);
   mDrawable.setColorFilter(null);
   if (mCurrentColorAnim != null) {
     mCurrentColorAnim.cancel();
     mCurrentColorAnim = null;
   }
   setTextColor(mOriginalTextColor);
   ((ViewGroup) getParent()).setVisibility(mActive ? View.VISIBLE : View.GONE);
 }
    /** Gets rid of this popup. If the popup isn't currently showing, this will be a no-op. */
    public void dismiss() {
      if (mDismissed) {
        return;
      }

      mHidden = false;
      mDismissed = true;
      mHideAnimation.cancel();
      runDismissAnimation();
      setZeroTouchableSurface();
    }
 public void animateVisible() {
   if (mIsHiddenOrHiding) {
     if (mViewToShowHide != null) {
       mViewToShowHide.setVisibility(View.INVISIBLE);
     }
     mHiddenAnimator.cancel();
     mVisibleAnimator.end();
     setVisibility(View.VISIBLE);
     mVisibleAnimator.start();
   }
   mIsHiddenOrHiding = false;
 }
Пример #14
0
 private void scaleToNormal(View item) {
   if (animatorSet == null) {
     return;
   }
   if (animatorSet.isRunning()) {
     animatorSet.cancel();
   }
   ObjectAnimator oa = ObjectAnimator.ofFloat(item, "ScaleX", 1f);
   oa.setDuration(durationSmall);
   oa.start();
   ObjectAnimator oa2 = ObjectAnimator.ofFloat(item, "ScaleY", 1f);
   oa2.setDuration(durationSmall);
   oa2.start();
 }
  /** Shows the toast. */
  private void transitionToVisible() {
    if (mDecorAnimation != null) {
      mDecorAnimation.cancel();
    }

    final Animator fadeIn =
        groupAnimatorOfFloat(View.ALPHA, 1f, mPreviewImage, mPrimaryText, mSecondaryText)
            .setDuration(DURATION_FADE_IN);

    mDecorAnimation = new AnimatorSet();
    mDecorAnimation.playTogether(fadeIn);
    mDecorAnimation.start();

    mShowingPreview = true;
  }
  /** Shows nothing. */
  private void transitionToHidden() {
    if (mDecorAnimation != null) {
      mDecorAnimation.cancel();
    }

    final Animator fadeOut =
        groupAnimatorOfFloat(View.ALPHA, 0f, mPreviewImage, mPrimaryText, mSecondaryText)
            .setDuration(DURATION_FADE_OUT);

    mDecorAnimation = new AnimatorSet();
    mDecorAnimation.playTogether(fadeOut);
    mDecorAnimation.start();

    mShowingPreview = false;
  }
  void animatePagesToCarousel() {
    if (mChildrenTransformsAnimator != null) {
      mChildrenTransformsAnimator.cancel();
      mChildrenTransformsAnimator = null;
    }

    int count = getChildCount();
    PropertyValuesHolder alpha;
    PropertyValuesHolder outlineAlpha;
    PropertyValuesHolder rotationY;
    PropertyValuesHolder pivotX;
    PropertyValuesHolder pivotY;
    ArrayList<Animator> anims = new ArrayList<Animator>();

    for (int i = 0; i < count; i++) {
      KeyguardWidgetFrame child = getWidgetPageAt(i);
      float finalAlpha = getAlphaForPage(mScreenCenter, i, true);
      float finalOutlineAlpha = getOutlineAlphaForPage(mScreenCenter, i, true);
      getTransformForPage(mScreenCenter, i, mTmpTransform);

      boolean inVisibleRange = (i >= mCurrentPage - 1 && i <= mCurrentPage + 1);

      ObjectAnimator a;
      alpha = PropertyValuesHolder.ofFloat("contentAlpha", finalAlpha);
      outlineAlpha = PropertyValuesHolder.ofFloat("backgroundAlpha", finalOutlineAlpha);
      pivotX = PropertyValuesHolder.ofFloat("pivotX", mTmpTransform[0]);
      pivotY = PropertyValuesHolder.ofFloat("pivotY", mTmpTransform[1]);
      rotationY = PropertyValuesHolder.ofFloat("rotationY", mTmpTransform[2]);

      if (inVisibleRange) {
        // for the central pages we animate into a rotated state
        a =
            ObjectAnimator.ofPropertyValuesHolder(
                child, alpha, outlineAlpha, pivotX, pivotY, rotationY);
      } else {
        a = ObjectAnimator.ofPropertyValuesHolder(child, alpha, outlineAlpha);
        a.setInterpolator(mFastFadeInterpolator);
      }
      anims.add(a);
    }

    int duration = REORDERING_ZOOM_IN_OUT_DURATION;
    mChildrenTransformsAnimator = new AnimatorSet();
    mChildrenTransformsAnimator.playTogether(anims);

    mChildrenTransformsAnimator.setDuration(duration);
    mChildrenTransformsAnimator.start();
  }
Пример #18
0
  public void dismiss(boolean animated) {
    setFocusable(false);
    if (animationEnabled && animated) {
      if (windowAnimatorSet != null) {
        windowAnimatorSet.cancel();
      }
      ActionBarPopupWindowLayout content = (ActionBarPopupWindowLayout) getContentView();
      windowAnimatorSet = new AnimatorSet();
      windowAnimatorSet.playTogether(
          ObjectAnimator.ofFloat(
              content, "translationY", AndroidUtilities.dp(content.showedFromBotton ? 5 : -5)),
          ObjectAnimator.ofFloat(content, "alpha", 0.0f));
      windowAnimatorSet.setDuration(150);
      windowAnimatorSet.addListener(
          new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {}

            @Override
            public void onAnimationEnd(Animator animation) {
              windowAnimatorSet = null;
              setFocusable(false);
              try {
                ActionBarPopupWindow.super.dismiss();
              } catch (Exception e) {
                // don't promt
              }
              unregisterListener();
            }

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

            @Override
            public void onAnimationRepeat(Animator animation) {}
          });
      windowAnimatorSet.start();
    } else {
      try {
        super.dismiss();
      } catch (Exception e) {
        // don't promt
      }
      unregisterListener();
    }
  }
Пример #19
0
 public void dismiss() {
   if (!mAttached) {
     return;
   }
   // Immediately set to false, to prevent .cancel() calls
   // below from immediately calling into dismiss() again.
   mAttached = false;
   mPreAnimator.cancel();
   mSlowSendAnimator.cancel();
   mFastCloneAnimator.cancel();
   mSuccessAnimatorSet.cancel();
   mScaleUpAnimator.cancel();
   mWindowManager.removeView(mScreenshotLayout);
   mStatusBarManager.disable(StatusBarManager.DISABLE_NONE);
   releaseScreenshot();
 }
  public void close(final boolean animate) {
    if (isOpened()) {
      if (isBackgroundEnabled()) {
        mHideBackgroundAnimator.start();
      }

      if (mIconAnimated) {
        if (mIconToggleSet != null) {
          mIconToggleSet.start();
        } else {
          mCloseAnimatorSet.start();
          mOpenAnimatorSet.cancel();
        }
      }

      mMenuOpened = false;
      int delay = 0;
      for (int i = 0; i < getChildCount(); i++) {
        View child = getChildAt(i);
        if (child instanceof FloatingActionButton
            && child != mMenuButton
            && child.getVisibility() != GONE) {

          final FloatingActionButton fab = (FloatingActionButton) child;
          mUiHandler.postDelayed(
              new Runnable() {
                @Override
                public void run() {
                  fab.hide(animate);
                  Label label = (Label) fab.getTag(R.id.fab_label);
                  if (label != null) {
                    label.hide(animate);
                  }
                }
              },
              delay);
          delay += mAnimationDelayPerItem;
        }
      }

      if (mToggleListener != null) {
        mToggleListener.onMenuToggle(false);
      }
    }
  }
  /**
   * Transitions the preview text to a new section. Handles animation, measurement, and layout. If
   * the new preview text is empty, returns false.
   *
   * @param sectionIndex The section index to which the preview should transition.
   * @return False if the new preview text is empty.
   */
  private boolean transitionPreviewLayout(int sectionIndex) {
    String text = mAlphabetList.get(sectionIndex).firstAlphabet;

    final Rect bounds = mTempBounds;
    final TextView showing;
    final TextView target;
    if (mShowingPrimary) {
      showing = mPrimaryText;
      target = mSecondaryText;
    } else {
      showing = mSecondaryText;
      target = mPrimaryText;
    }

    // Set and layout target immediately.
    target.setText(text);
    measurePreview(target, bounds);
    applyLayout(target, bounds);

    if (mPreviewAnimation != null) {
      mPreviewAnimation.cancel();
    }

    // Cross-fade preview text.
    final Animator showTarget = animateAlpha(target, 1f).setDuration(DURATION_CROSS_FADE);
    final Animator hideShowing = animateAlpha(showing, 0f).setDuration(DURATION_CROSS_FADE);
    hideShowing.addListener(mSwitchPrimaryListener);

    // Apply preview image padding and animate bounds, if necessary.
    bounds.left -= mPreviewImage.getPaddingLeft();
    bounds.top -= mPreviewImage.getPaddingTop();
    bounds.right += mPreviewImage.getPaddingRight();
    bounds.bottom += mPreviewImage.getPaddingBottom();
    /*final Animator resizePreview = animateBounds(preview, bounds);
    resizePreview.setDuration(DURATION_RESIZE);*/

    mPreviewAnimation = new AnimatorSet();
    mPreviewAnimation.play(hideShowing).with(showTarget);
    mPreviewAnimation.start();

    return !TextUtils.isEmpty(text);
  }
  @Override
  public void updateSecurityIcon(int securityLevel) {
    // ImageView#setImageResource is no-op if given resource is the current one.
    mSecurityButton.setImageResource(
        LocationBarLayout.getSecurityIconResource(securityLevel, !shouldEmphasizeHttpsScheme()));

    if (mSecurityIconType == securityLevel) return;
    mSecurityIconType = securityLevel;

    if (securityLevel == ConnectionSecurityLevel.NONE) {
      // TODO(yusufo): Add an animator for hiding as well.
      mSecurityButton.setVisibility(GONE);
    } else if (mSecurityButton.getVisibility() != View.VISIBLE) {
      if (mSecurityButtonShowAnimator.isRunning()) mSecurityButtonShowAnimator.cancel();
      mSecurityButtonShowAnimator.start();
      mUrlBar.deEmphasizeUrl();
    }
    mUrlBar.emphasizeUrl();
    mUrlBar.invalidate();
  }
  void animatePagesToNeutral() {
    if (mChildrenTransformsAnimator != null) {
      mChildrenTransformsAnimator.cancel();
      mChildrenTransformsAnimator = null;
    }

    int count = getChildCount();
    PropertyValuesHolder alpha;
    PropertyValuesHolder outlineAlpha;
    PropertyValuesHolder rotationY;
    ArrayList<Animator> anims = new ArrayList<Animator>();

    for (int i = 0; i < count; i++) {
      KeyguardWidgetFrame child = getWidgetPageAt(i);
      boolean inVisibleRange = (i >= mCurrentPage - 1 && i <= mCurrentPage + 1);
      if (!inVisibleRange) {
        child.setRotationY(0f);
      }
      alpha = PropertyValuesHolder.ofFloat("contentAlpha", 1.0f);
      outlineAlpha =
          PropertyValuesHolder.ofFloat(
              "backgroundAlpha", KeyguardWidgetFrame.OUTLINE_ALPHA_MULTIPLIER);
      rotationY = PropertyValuesHolder.ofFloat("rotationY", 0f);
      ObjectAnimator a =
          ObjectAnimator.ofPropertyValuesHolder(child, alpha, outlineAlpha, rotationY);
      child.setVisibility(VISIBLE);
      if (!inVisibleRange) {
        a.setInterpolator(mSlowFadeInterpolator);
      }
      anims.add(a);
    }

    int duration = REORDERING_ZOOM_IN_OUT_DURATION;
    mChildrenTransformsAnimator = new AnimatorSet();
    mChildrenTransformsAnimator.playTogether(anims);

    mChildrenTransformsAnimator.setDuration(duration);
    mChildrenTransformsAnimator.start();
  }
  private void hide() {
    if (showAnimatorSet != null) {
      showAnimatorSet.cancel();
    }

    if (callback != null) {
      callback.onHideStart();
    }

    ObjectAnimator hideAnimator = ObjectAnimator.ofFloat(this, View.ALPHA, 1f, 0f);
    hideAnimator.setInterpolator(new Quart.EaseOut());
    hideAnimator.setDuration(
        getResources().getInteger(R.integer.framework_animation_duration_medium));
    hideAnimator.addListener(
        new AnimatorListenerAdapter() {
          @Override
          public void onAnimationEnd(Animator animation) {
            if (callback != null) {
              callback.onHideEnd();
            }
          }
        });
    hideAnimator.start();
  }
Пример #25
0
    void createAnimation(boolean appearing) {
      // mVisible: previous state; appearing: new state

      float start, end;

      // 0: on-screen
      // height: off-screen
      float y = mContentParent.getTranslationY();
      if (appearing) {
        // we want to go from near-the-top to the top, unless we're half-open in the right
        // general vicinity
        end = 0;
        if (mNotificationCount == 0) {
          end += mContentFrameMissingTranslation;
        }
        start = HYPERSPACE_OFFRAMP + end;
      } else {
        start = y;
        end = y + HYPERSPACE_OFFRAMP;
      }

      Animator posAnim = ObjectAnimator.ofFloat(mContentParent, "translationY", start, end);
      posAnim.setInterpolator(appearing ? sDecelerateInterpolator : sAccelerateInterpolator);

      if (mContentAnim != null && mContentAnim.isRunning()) {
        mContentAnim.cancel();
      }

      Animator fadeAnim = ObjectAnimator.ofFloat(mContentParent, "alpha", appearing ? 1.0f : 0.0f);
      fadeAnim.setInterpolator(appearing ? sAccelerateInterpolator : sDecelerateInterpolator);

      mContentAnim = new AnimatorSet();
      mContentAnim.play(fadeAnim).with(posAnim);
      mContentAnim.setDuration((DEBUG ? 10 : 1) * (appearing ? OPEN_DURATION : CLOSE_DURATION));
      mContentAnim.addListener(this);
    }
Пример #26
0
  @TargetApi(Build.VERSION_CODES.LOLLIPOP)
  private void animateTextColor(int targetColor) {
    if (mCurrentColorAnim != null) {
      mCurrentColorAnim.cancel();
    }

    mCurrentColorAnim = new AnimatorSet();
    mCurrentColorAnim.setDuration(DragView.COLOR_CHANGE_DURATION);

    if (mSrcFilter == null) {
      mSrcFilter = new ColorMatrix();
      mDstFilter = new ColorMatrix();
      mCurrentFilter = new ColorMatrix();
    }

    DragView.setColorScale(getTextColor(), mSrcFilter);
    DragView.setColorScale(targetColor, mDstFilter);
    ValueAnimator anim1 =
        ValueAnimator.ofObject(
            new FloatArrayEvaluator(mCurrentFilter.getArray()),
            mSrcFilter.getArray(),
            mDstFilter.getArray());
    anim1.addUpdateListener(
        new AnimatorUpdateListener() {

          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            mDrawable.setColorFilter(new ColorMatrixColorFilter(mCurrentFilter));
            invalidate();
          }
        });

    mCurrentColorAnim.play(anim1);
    mCurrentColorAnim.play(ObjectAnimator.ofArgb(this, "textColor", targetColor));
    mCurrentColorAnim.start();
  }
Пример #27
0
 @Override
 public void cancel() {
   mAnimatorSet.cancel();
 }
Пример #28
0
 /** Cancel an in progress animation */
 public static void cancel() {
   if (mSetAnim != null) mSetAnim.cancel();
 }
Пример #29
0
 public void cancel() {
   if (animatorSet != null) {
     animatorSet.cancel();
   }
 }
 private void cancelDismissAndHideAnimations() {
   mDismissAnimation.cancel();
   mHideAnimation.cancel();
 }