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);
 }
 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();
 }
Exemple #4
0
  @SuppressLint("NewApi")
  private void onDialogDismiss() {
    if (animatorSetForDialogDismiss.isRunning()) {
      return;
    }
    if (animatorSetForDialogDismiss != null
        && objectAnimatorsForDialogDismiss != null
        && objectAnimatorsForDialogDismiss.size() > 0) {
      animatorSetForDialogDismiss.playTogether(objectAnimatorsForDialogDismiss);
      animatorSetForDialogDismiss.start();
      animatorSetForDialogDismiss.addListener(
          new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {}

            @Override
            public void onAnimationEnd(Animator animation) {
              // 这里有可能会有bug,当Dialog所依赖的Activity关闭的时候,如果这个时候,用户关闭对话框,由于对话框的动画关闭需要时间,当动画执行完毕后,对话框所依赖的Activity已经被销毁了,执行dismiss()就会报错
              if (context != null && context instanceof Activity) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                  if (!((Activity) context).isDestroyed()) {
                    dialog.dismiss();
                  }
                } else {
                  try {
                    dialog.dismiss();
                  } catch (final IllegalArgumentException e) {

                  } catch (final Exception e) {

                  } finally {
                    dialog = null;
                  }
                }
              }
            }

            @Override
            public void onAnimationCancel(Animator animation) {}

            @Override
            public void onAnimationRepeat(Animator animation) {}
          });
    } else {
      dialog.dismiss();
    }
  }
  @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();
  }
  /**
   * Set either minutes or hours as showing.
   *
   * @param animate True to animate the transition, false to show with no animation.
   */
  public void setCurrentItemShowing(int index, boolean animate) {
    if (index != HOUR_INDEX && index != MINUTE_INDEX) {
      Log.e(TAG, "TimePicker does not support view at index " + index);
      return;
    }

    int lastIndex = getCurrentItemShowing();
    mCurrentItemShowing = index;

    if (animate && (index != lastIndex)) {
      ObjectAnimator[] anims = new ObjectAnimator[4];
      if (index == MINUTE_INDEX) {
        anims[0] = mHourRadialTextsView.getDisappearAnimator();
        anims[1] = mHourRadialSelectorView.getDisappearAnimator();
        anims[2] = mMinuteRadialTextsView.getReappearAnimator();
        anims[3] = mMinuteRadialSelectorView.getReappearAnimator();
      } else if (index == HOUR_INDEX) {
        anims[0] = mHourRadialTextsView.getReappearAnimator();
        anims[1] = mHourRadialSelectorView.getReappearAnimator();
        anims[2] = mMinuteRadialTextsView.getDisappearAnimator();
        anims[3] = mMinuteRadialSelectorView.getDisappearAnimator();
      }

      if (mTransition != null && mTransition.isRunning()) {
        mTransition.end();
      }
      mTransition = new AnimatorSet();
      mTransition.playTogether(anims);
      mTransition.start();
    } else {
      int hourAlpha = (index == HOUR_INDEX) ? 255 : 0;
      int minuteAlpha = (index == MINUTE_INDEX) ? 255 : 0;
      mHourRadialTextsView.setAlpha(hourAlpha);
      mHourRadialSelectorView.setAlpha(hourAlpha);
      mMinuteRadialTextsView.setAlpha(minuteAlpha);
      mMinuteRadialSelectorView.setAlpha(minuteAlpha);
    }
  }
    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);
    }
Exemple #8
0
  public void toggleToolbarShown(boolean shown) {
    if (mStripView == null) {
      Fragment fragment = getFragmentManager().findFragmentByTag(FRAGMENT_TAG);
      if (fragment != null && fragment instanceof AStripTabsFragment) {
        mStripView = ((AStripTabsFragment) fragment).getSlidingTabLayout();
      }
    }

    if (mToolbar == null) return;

    if (animatorSet != null && animatorSet.isRunning()) return;

    if (isToolbarShown() && shown) return;
    else if (!isToolbarShown() && !shown) return;

    if (!btnFab.isVisible() && shown) {
      btnFab.show(true);
    } else if (btnFab.isVisible() && !shown) {
      btnFab.hide(true);
    }

    PropertyValuesHolder toolBarHolder = null;
    if (shown) {
      toolBarHolder = PropertyValuesHolder.ofFloat("translationY", -1 * mToolbar.getHeight(), 0);
    } else {
      toolBarHolder = PropertyValuesHolder.ofFloat("translationY", 0, -1 * mToolbar.getHeight());
    }
    ObjectAnimator toolbarObjectAnim =
        ObjectAnimator.ofPropertyValuesHolder(mToolbar, toolBarHolder);
    toolbarObjectAnim.setDuration(150);

    ObjectAnimator stripObjectAnim = null;
    if (mStripView != null) {
      PropertyValuesHolder stripHolder = null;
      if (shown) {
        stripHolder = PropertyValuesHolder.ofFloat("translationY", -1 * mStripView.getHeight(), 0);
      } else {
        stripHolder = PropertyValuesHolder.ofFloat("translationY", 0, -1 * mStripView.getHeight());
      }
      stripObjectAnim = ObjectAnimator.ofPropertyValuesHolder(mStripView, stripHolder);
      stripObjectAnim.setDuration(150);
    }

    AnimatorSet animSet = new AnimatorSet();
    animatorSet = animSet;
    if (shown) {
      if (stripObjectAnim != null) {
        //                animSet.playSequentially(toolbarObjectAnim, stripObjectAnim);
        animSet.play(toolbarObjectAnim);
        stripObjectAnim.setStartDelay(100);
        animSet.play(stripObjectAnim);
      } else {
        animSet.play(toolbarObjectAnim);
      }
    } else {
      if (stripObjectAnim != null) {
        //                animSet.playSequentially(stripObjectAnim, toolbarObjectAnim);
        animSet.play(stripObjectAnim);
        toolbarObjectAnim.setStartDelay(100);
        animSet.play(toolbarObjectAnim);
      } else {
        animSet.play(toolbarObjectAnim);
      }
    }
    animSet.start();
  }
Exemple #9
0
 @Override
 public boolean isRunning() {
   return mAnimatorSet.isRunning();
 }