Example #1
1
  public void backTopAndCenterWithAnimation() {
    mStepLayout.setVisibility(View.VISIBLE);
    if (Build.VERSION.SDK_INT >= 11) {
      float centerHeight =
          mActivity.getResources().getDimension(R.dimen.pg_sdk_edit_center_move_top_height);
      ObjectAnimator centerAnimator =
          ObjectAnimator.ofFloat(mCenterLayoutParent, "y", -centerHeight, 0f);
      centerAnimator.setDuration(ANIMATION_TIME);
      centerAnimator.start();

      float topHeight = mActivity.getResources().getDimension(R.dimen.pg_sdk_edit_top_height);
      ObjectAnimator topAnimator = ObjectAnimator.ofFloat(mFirstTopView, "y", -topHeight, 0f);
      topAnimator.setDuration(ANIMATION_TIME);
      topAnimator.start();

    } else {
      mFirstTopView.setVisibility(View.VISIBLE);

      float topHeight = mActivity.getResources().getDimension(R.dimen.pg_sdk_edit_top_height);
      float bottomHeight = mActivity.getResources().getDimension(R.dimen.pg_sdk_edit_bottom_height);
      mCenterLayoutParent.setPadding(
          mCenterLayoutParent.getPaddingLeft(),
          Math.round(topHeight),
          mCenterLayoutParent.getPaddingRight(),
          Math.round(bottomHeight));
    }
  }
Example #2
0
  @Override
  protected void onAttachedToWindow() {
    super.onAttachedToWindow();
    isAttachedToWindow = true;

    if (dirtyAnimation) {
      knobState = this.mIsChecked;
      if (knobState) {
        knobMoveAnimator.setFloatValues(knobMoveRate, 1.0F);
        knobMoveAnimator.start();

        innerContentAnimator.setFloatValues(innerContentRate, 0.0F);
        innerContentAnimator.start();
      } else {
        knobMoveAnimator.setFloatValues(knobMoveRate, 0.0F);
        knobMoveAnimator.start();

        innerContentAnimator.setFloatValues(innerContentRate, 1.0F);
        innerContentAnimator.start();
      }

      knobExpandAnimator.setFloatValues(knobExpandRate, 0.0F);
      knobExpandAnimator.start();

      if (AnSwitch.this.onSwitchStateChangeListener != null && mIsChecked != preIsOn) {
        AnSwitch.this.onSwitchStateChangeListener.onSwitchStateChange(mIsChecked);
      }

      dirtyAnimation = false;
    }
  }
Example #3
0
        @Override
        public boolean onSingleTapUp(MotionEvent event) {
          mIsChecked = knobState;

          if (preIsOn == mIsChecked) {
            mIsChecked = !mIsChecked;
            knobState = !knobState;
          }

          if (knobState) {

            knobMoveAnimator.setFloatValues(knobMoveRate, 1.0F);
            knobMoveAnimator.start();

            innerContentAnimator.setFloatValues(innerContentRate, 0.0F);
            innerContentAnimator.start();
          } else {

            knobMoveAnimator.setFloatValues(knobMoveRate, 0.0F);
            knobMoveAnimator.start();

            innerContentAnimator.setFloatValues(innerContentRate, 1.0F);
            innerContentAnimator.start();
          }

          knobExpandAnimator.setFloatValues(knobExpandRate, 0.0F);
          knobExpandAnimator.start();

          if (AnSwitch.this.onSwitchStateChangeListener != null && mIsChecked != preIsOn) {
            AnSwitch.this.onSwitchStateChangeListener.onSwitchStateChange(mIsChecked);
          }

          return true;
        }
Example #4
0
 /** Return to initial state */
 public void finish(int finishMode) {
   if (!mAttached) {
     return;
   }
   mTextHint.setVisibility(View.GONE);
   if (finishMode == FINISH_SLIDE_OUT) {
     PropertyValuesHolder slideX =
         PropertyValuesHolder.ofFloat(
             "translationX", new float[] {0.0f, mScreenshotView.getWidth()});
     mSlideoutAnimator = ObjectAnimator.ofPropertyValuesHolder(mScreenshotView, slideX);
     mSlideoutAnimator.setInterpolator(new AccelerateInterpolator());
     mSlideoutAnimator.setDuration(SLIDE_OUT_DURATION_MS);
     mSlideoutAnimator.addListener(this);
     mSlideoutAnimator.start();
   } else {
     float currentScale = mScreenshotView.getScaleX();
     float currentAlpha = mScreenshotView.getAlpha();
     PropertyValuesHolder scaleUpX =
         PropertyValuesHolder.ofFloat("scaleX", new float[] {currentScale, 1.0f});
     PropertyValuesHolder scaleUpY =
         PropertyValuesHolder.ofFloat("scaleY", new float[] {currentScale, 1.0f});
     PropertyValuesHolder scaleUpAlpha =
         PropertyValuesHolder.ofFloat("alpha", new float[] {currentAlpha, 1.0f});
     mScaleUpAnimator =
         ObjectAnimator.ofPropertyValuesHolder(mScreenshotView, scaleUpX, scaleUpY, scaleUpAlpha);
     mScaleUpAnimator.setInterpolator(new DecelerateInterpolator());
     mScaleUpAnimator.setDuration(SCALE_UP_DURATION_MS);
     mScaleUpAnimator.addListener(this);
     mScaleUpAnimator.start();
   }
 }
Example #5
0
        @Override
        public boolean onSingleTapUp(MotionEvent event) {

          isOn = knobState;

          if (preIsOn == isOn) {
            isOn = !isOn;
            knobState = !knobState;
          }

          if (knobState) {

            knobMoveAnimator.setFloatValues(knobMoveRate, 1.0F);
            knobMoveAnimator.start();

            innerContentAnimator.setFloatValues(innerContentRate, 0.0F);
            innerContentAnimator.start();
          } else {

            knobMoveAnimator.setFloatValues(knobMoveRate, 0.0F);
            knobMoveAnimator.start();

            innerContentAnimator.setFloatValues(innerContentRate, 1.0F);
            innerContentAnimator.start();
          }

          knobExpandAnimator.setFloatValues(knobExpandRate, 0.0F);
          knobExpandAnimator.start();

          if (ShSwitchView.this.onSwitchStateChangeListener != null && isOn != preIsOn) {
            ShSwitchView.this.onSwitchStateChangeListener.onSwitchStateChange(isOn);
          }

          return true;
        }
Example #6
0
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    if (!isEnabled()) return false;

    switch (event.getAction()) {
      case MotionEvent.ACTION_UP:
      case MotionEvent.ACTION_CANCEL:
        if (!knobState) {
          innerContentAnimator =
              ObjectAnimator.ofFloat(AnSwitch.this, innerContentProperty, innerContentRate, 1.0F);
          innerContentAnimator.setDuration(300L);
          innerContentAnimator.setInterpolator(new DecelerateInterpolator());

          innerContentAnimator.start();
        }

        knobExpandAnimator =
            ObjectAnimator.ofFloat(AnSwitch.this, knobExpandProperty, knobExpandRate, 0.0F);
        knobExpandAnimator.setDuration(300L);
        knobExpandAnimator.setInterpolator(new DecelerateInterpolator());

        knobExpandAnimator.start();

        mIsChecked = knobState;

        if (AnSwitch.this.onSwitchStateChangeListener != null && mIsChecked != preIsOn) {
          AnSwitch.this.onSwitchStateChangeListener.onSwitchStateChange(mIsChecked);
        }

        break;
    }

    return gestureDetector.onTouchEvent(event);
  }
 /**
  * This class should be overridden by subclasses to customize view transitions within
  * the set of visible views
  *
  * @param fromIndex The relative index within the window that the view was in, -1 if it wasn't
  *        in the window
  * @param toIndex The relative index within the window that the view is going to, -1 if it is
  *        being removed
  * @param view The view that is being animated
  */
 void transformViewForTransition(int fromIndex, int toIndex, View view, boolean animate) {
     if (fromIndex == -1) {
         mInAnimation.setTarget(view);
         mInAnimation.start();
     } else if (toIndex == -1) {
         mOutAnimation.setTarget(view);
         mOutAnimation.start();
     }
 }
 /*
  * DragController.DragListener implementation
  */
 @Override
 public void onDragStart(DragSource source, Object info, int dragAction) {
   // Animate out the QSB search bar, and animate in the drop target bar
   prepareStartAnimation(mDropTargetBar);
   mDropTargetBarAnim.start();
   if (!mIsSearchBarHidden) {
     prepareStartAnimation(mQSBSearchBar);
     mQSBSearchBarAnim.start();
   }
 }
 @Override
 public void start() {
   if (isRunning()) {
     return;
   }
   mRunning = true;
   mObjectAnimatorAngle.start();
   mObjectAnimatorSweep.start();
   invalidateSelf();
 }
Example #10
0
  public void moveTopAndCenterToUpWithAnimation() {
    if (Build.VERSION.SDK_INT >= 11) {
      float centerMoveHeight =
          mActivity.getResources().getDimension(R.dimen.pg_sdk_edit_center_move_top_height);
      mStepLayout.setVisibility(View.INVISIBLE);
      ObjectAnimator centerAnimator =
          ObjectAnimator.ofFloat(mCenterLayoutParent, "y", 0f, -centerMoveHeight);
      centerAnimator.setDuration(ANIMATION_TIME);
      centerAnimator.start();

      float topHeight = mActivity.getResources().getDimension(R.dimen.pg_sdk_edit_top_height);
      ObjectAnimator topAnimator = ObjectAnimator.ofFloat(mFirstTopView, "y", 0f, -topHeight);
      topAnimator.setDuration(ANIMATION_TIME);
      topAnimator.addListener(
          new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animator) {}

            @Override
            public void onAnimationEnd(Animator animator) {
              mActivity.runOnUiThread(
                  new Runnable() {
                    @Override
                    public void run() {
                      if (null != mMenuListener) {
                        mMenuListener.onShowSecondAnimationEnd();
                      }
                    }
                  });
            }

            @Override
            public void onAnimationCancel(Animator animator) {}

            @Override
            public void onAnimationRepeat(Animator animator) {}
          });
      topAnimator.start();

    } else {
      mStepLayout.setVisibility(View.INVISIBLE);
      mFirstTopView.setVisibility(View.GONE);
      int centerMoveHeight =
          Math.round(
              mActivity.getResources().getDimension(R.dimen.pg_sdk_edit_center_move_top_height));
      mCenterLayoutParent.setPadding(
          mCenterLayoutParent.getPaddingLeft(),
          mCenterLayoutParent.getPaddingTop() - centerMoveHeight,
          mCenterLayoutParent.getPaddingRight(),
          centerMoveHeight + mCenterLayoutParent.getPaddingBottom());
      if (null != mMenuListener) {
        mMenuListener.onShowSecondAnimationEnd();
      }
    }
  }
    public static void animateShowing(
        final ViewHolder holder, final ListAdapter adapter, boolean isAnimate) {
      final CheckBox checkBox = holder.checkBox;
      if (checkBox.getVisibility() == View.VISIBLE) {
        return;
      }
      checkBox.setVisibility(View.VISIBLE);
      checkBox.setAlpha(0.0f);
      final int widthSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
      final int heightSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
      checkBox.measure(widthSpec, heightSpec);
      ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) checkBox.getLayoutParams();
      final long transValue = checkBox.getMeasuredWidth() + lp.leftMargin + lp.rightMargin;

      if (!isAnimate) {
        checkBox.setAlpha(1.0f);
        holder.contentLayout.setTranslationX(transValue);
        return;
      }

      final ObjectAnimator transBodyAnimator = new ObjectAnimator();
      final PropertyValuesHolder trans =
          PropertyValuesHolder.ofFloat("TranslationX", 0.0f, transValue);
      transBodyAnimator.setTarget(holder.contentLayout);
      transBodyAnimator.setValues(trans);
      transBodyAnimator.setDuration(DURATION);

      ObjectAnimator checkBoxAnim = new ObjectAnimator();
      final PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("ScaleX", 0.0f, 1.0f);
      final PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("ScaleY", 0.0f, 1.0f);
      final PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("Alpha", 0.0f, 1.0f);
      checkBoxAnim.setValues(scaleX, scaleY, alpha);
      checkBoxAnim.setTarget(holder.checkBox);
      checkBoxAnim.setDuration(DURATION);
      checkBoxAnim.setInterpolator(new DecelerateInterpolator());
      checkBoxAnim.addListener(
          new AnimatorListenerAdapter() {
            @Override
            public void onAnimationStart(Animator animation) {
              checkBox.setTag("animating");
            }

            @Override
            public void onAnimationEnd(Animator animation) {
              // adapter.setCheckBoxAnimator(false);
              checkBox.setTag("animated");
            }
          });
      if (!(checkBox.getTag() != null && "animating".equals(checkBox.getTag()))) {
        // 若正在播放动画,则不继续播放动画
        transBodyAnimator.start();
        checkBoxAnim.start();
      }
    }
    public static void animateHiding(
        final ViewHolder holder, final ListAdapter adapter, boolean isAnimate) {
      final CheckBox checkBox = holder.checkBox;
      final View tansBody = holder.contentLayout;

      if (checkBox.getVisibility() == View.GONE) {
        return;
      }
      ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) checkBox.getLayoutParams();
      final float transValue = checkBox.getMeasuredWidth() + lp.leftMargin + lp.rightMargin;

      if (!isAnimate) {
        checkBox.setVisibility(View.GONE);
        holder.contentLayout.setTranslationX(0.0f);
        return;
      }
      final ObjectAnimator transBodyAnimator = new ObjectAnimator();
      final PropertyValuesHolder trans =
          PropertyValuesHolder.ofFloat("TranslationX", transValue, 0.0f);
      transBodyAnimator.setTarget(tansBody);
      transBodyAnimator.setValues(trans);
      transBodyAnimator.setDuration(DURATION);

      ObjectAnimator checkBoxAnim = new ObjectAnimator();
      final PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("ScaleX", 1.0f, 0.0f);
      final PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("ScaleY", 1.0f, 0.0f);
      final PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("Alpha", 1.0f, 0.0f);
      checkBoxAnim.setValues(scaleX, scaleY, alpha);
      checkBoxAnim.setTarget(checkBox);
      checkBoxAnim.setDuration(DURATION);
      checkBoxAnim.setInterpolator(new AccelerateInterpolator());
      checkBoxAnim.addListener(
          new AnimatorListenerAdapter() {
            @Override
            public void onAnimationStart(Animator animation) {
              checkBox.setTag("animating");
            }

            @Override
            public void onAnimationEnd(Animator animation) {
              // adapter.setCheckBoxAnimator(false);
              checkBox.setScaleX(1.0f);
              checkBox.setScaleY(1.0f);
              checkBox.setAlpha(1.0f);
              checkBox.setVisibility(View.GONE);
              checkBox.setTag("animated");
            }
          });
      if (!(checkBox.getTag() != null && "animating".equals(checkBox.getTag()))) {
        transBodyAnimator.start();
        checkBoxAnim.start();
      }
    }
Example #13
0
  /** Show pre-send animation */
  public void showPreSend() {
    // Update display metrics
    mDisplay.getRealMetrics(mDisplayMetrics);

    final int statusBarHeight =
        mContext
            .getResources()
            .getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height);

    if (mScreenshotBitmap == null || mAttached) {
      return;
    }
    mScreenshotView.setOnTouchListener(this);
    mScreenshotView.setImageBitmap(mScreenshotBitmap);
    mScreenshotView.setTranslationX(0f);
    mScreenshotView.setAlpha(1.0f);
    mScreenshotView.setPadding(0, statusBarHeight, 0, 0);

    mScreenshotLayout.requestFocus();

    mTextHint.setAlpha(0.0f);
    mTextHint.setVisibility(View.VISIBLE);
    mHintAnimator.start();

    // Lock the orientation.
    // The orientation from the configuration does not specify whether
    // the orientation is reverse or not (ie landscape or reverse landscape).
    // So we have to use SENSOR_LANDSCAPE or SENSOR_PORTRAIT to make sure
    // we lock in portrait / landscape and have the sensor determine
    // which way is up.
    int orientation = mContext.getResources().getConfiguration().orientation;

    switch (orientation) {
      case Configuration.ORIENTATION_LANDSCAPE:
        mWindowLayoutParams.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
        break;
      case Configuration.ORIENTATION_PORTRAIT:
        mWindowLayoutParams.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
        break;
      default:
        mWindowLayoutParams.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
        break;
    }

    mWindowManager.addView(mScreenshotLayout, mWindowLayoutParams);
    // Disable statusbar pull-down
    mStatusBarManager.disable(StatusBarManager.DISABLE_EXPAND);

    mAttached = true;
    mPreAnimator.start();
  }
Example #14
0
  public void setOn(boolean on, boolean animated) {

    if (this.isOn == on) return;

    if (!isAttachedToWindow && animated) {
      dirtyAnimation = true;
      this.isOn = on;

      return;
    }

    this.isOn = on;
    knobState = this.isOn;

    if (!animated) {

      if (on) {
        setKnobMoveRate(1.0F);
        setInnerContentRate(0.0F);
      } else {
        setKnobMoveRate(0.0F);
        setInnerContentRate(1.0F);
      }

      setKnobExpandRate(0.0F);

    } else {
      if (knobState) {

        knobMoveAnimator.setFloatValues(knobMoveRate, 1.0F);
        knobMoveAnimator.start();

        innerContentAnimator.setFloatValues(innerContentRate, 0.0F);
        innerContentAnimator.start();
      } else {

        knobMoveAnimator.setFloatValues(knobMoveRate, 0.0F);
        knobMoveAnimator.start();

        innerContentAnimator.setFloatValues(innerContentRate, 1.0F);
        innerContentAnimator.start();
      }

      knobExpandAnimator.setFloatValues(knobExpandRate, 0.0F);
      knobExpandAnimator.start();
    }

    if (ShSwitchView.this.onSwitchStateChangeListener != null && isOn != preIsOn) {
      ShSwitchView.this.onSwitchStateChangeListener.onSwitchStateChange(isOn);
    }
  }
Example #15
0
  public void animateClosed() {
    if (!(getParent() instanceof DragLayer)) return;

    ObjectAnimator oa;
    if (mMode == PARTIAL_GROW) {
      PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0);
      PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 0.9f);
      PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 0.9f);
      oa = ObjectAnimator.ofPropertyValuesHolder(this, alpha, scaleX, scaleY);
    } else {
      DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams();

      PropertyValuesHolder width = PropertyValuesHolder.ofInt("width", mIconRect.width());
      PropertyValuesHolder height = PropertyValuesHolder.ofInt("height", mIconRect.height());
      PropertyValuesHolder x = PropertyValuesHolder.ofInt("x", mIconRect.left);
      PropertyValuesHolder y = PropertyValuesHolder.ofInt("y", mIconRect.top);
      oa = ObjectAnimator.ofPropertyValuesHolder(lp, width, height, x, y);
      oa.addUpdateListener(
          new AnimatorUpdateListener() {
            public void onAnimationUpdate(ValueAnimator animation) {
              requestLayout();
            }
          });

      PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0f);
      ObjectAnimator alphaOa = ObjectAnimator.ofPropertyValuesHolder(mContent, alpha);
      alphaOa.setDuration(mExpandDuration);
      alphaOa.setInterpolator(new DecelerateInterpolator(2.0f));
      alphaOa.start();
    }

    oa.addListener(
        new AnimatorListenerAdapter() {
          @Override
          public void onAnimationEnd(Animator animation) {
            onCloseComplete();
            mState = STATE_SMALL;
          }

          @Override
          public void onAnimationStart(Animator animation) {
            sendCustomAccessibilityEvent(
                AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
                getContext().getString(R.string.folder_closed));
            mState = STATE_ANIMATING;
          }
        });
    oa.setDuration(mExpandDuration);
    oa.start();
  }
Example #16
0
        @Override
        public boolean onDown(MotionEvent event) {
          if (!isEnabled()) return false;

          preIsOn = mIsChecked;

          innerContentAnimator.setFloatValues(innerContentRate, 0.0F);
          innerContentAnimator.start();

          knobExpandAnimator.setFloatValues(knobExpandRate, 1.0F);
          knobExpandAnimator.start();

          return true;
        }
Example #17
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();
 }
Example #18
0
 @Override
 public void onClick(View v) {
   if (mViewPager.getCurrentItem() == 0) {
     ObjectAnimator anim = ObjectAnimator.ofFloat(v, "rotation", 360.0f, 315.0f);
     anim.setDuration(200);
     anim.start();
     mViewPager.setCurrentItem(1);
   } else {
     ObjectAnimator anim = ObjectAnimator.ofFloat(v, "rotation", 315.0f, 360.0f);
     anim.setDuration(200);
     anim.start();
     mViewPager.setCurrentItem(0);
   }
 }
          @Override
          public void onClick(View v) {
            if (startButton.getVisibility() == View.VISIBLE) {
              startButton.setVisibility(View.INVISIBLE);
            }

            if (upAnimation.isStarted()) {
              upAnimation.cancel();
            }

            if (startPosition == 0) {
              startPosition = bird.getTop();
            }

            isUpAnimationCancelled = false;
            isDownEndByClick = true;
            // bird.layout(bird.getLeft(), 228, bird.getRight(), 228 + bird.getMeasuredHeight());
            bird.layout(
                bird.getLeft(),
                (int) bird.getY(),
                bird.getRight(),
                (int) bird.getY() + bird.getMeasuredHeight());
            bird.setTranslationY(0);
            upAnimation.start();
          }
  /**
   * Starts the transition of showing or hiding the mask. If showMask is true, the mask will be set
   * to be invisible then fade into hide the other views in this container. If showMask is false,
   * the mask will be set to be hide other views initially. Then, the other views in this container
   * will be revealed.
   */
  public void startMaskTransition(boolean showMask) {
    // Stop any animation that may still be running.
    if (mAnimator != null && mAnimator.isRunning()) {
      mAnimator.end();
    }

    mMaskingView.setVisibility(View.VISIBLE);
    if (showMask) {
      mAnimator = ObjectAnimator.ofFloat(mMaskingView, View.ALPHA, 0.0f, 1.0f);
      mAnimator.start();
    } else {
      // asked to hide the view
      mAnimator = ObjectAnimator.ofFloat(mMaskingView, View.ALPHA, 1.0f, 0.0f);
      mAnimator.start();
    }
  }
  /**
   * ��ת����
   *
   * @param one
   * @param two
   */
  private void flipit(View one, View two) {
    final View visible;
    final View invisible;
    if (one.getVisibility() == View.GONE) {
      visible = two;
      invisible = one;

    } else {
      invisible = two;
      visible = one;
    }
    ObjectAnimator visToInvis = ObjectAnimator.ofFloat(visible, "rotationY", 0f, 90f);
    visToInvis.setDuration(500);
    visToInvis.setInterpolator(accelerator);
    final ObjectAnimator invisToVis = ObjectAnimator.ofFloat(invisible, "rotationY", -90f, 0f);
    invisToVis.setDuration(500);
    invisToVis.setInterpolator(decelerator);
    visToInvis.addListener(
        new AnimatorListenerAdapter() {
          @Override
          public void onAnimationEnd(Animator anim) {
            visible.setVisibility(View.GONE);
            invisToVis.start();
            invisible.setVisibility(View.VISIBLE);
          }
        });
    visToInvis.start();
  }
 // 开始动画
 private void startAnim() {
   // 遍历第一个不是主菜单的ImageView列表
   for (int i = 1; i < res.length; i++) {
     // 获取展开角度
     float angle = (90 * 1.0f / (res.length - 2)) * (i - 1);
     // 获取X位移
     PropertyValuesHolder holder1 =
         PropertyValuesHolder.ofFloat(
             "translationX", 0, (float) (Math.sin((angle * 1.57 / 90)) * 200));
     // 获取Y位移
     PropertyValuesHolder holder2 =
         PropertyValuesHolder.ofFloat(
             "translationY", 0, (float) (Math.cos((angle * 1.57 / 90)) * 200));
     // 设置ImageView的属性动画
     ObjectAnimator animator =
         ObjectAnimator.ofPropertyValuesHolder(imageViewList.get(i), holder1, holder2);
     // ObjectAnimator animator =
     // ObjectAnimator.ofFloat(imageViewList.get(i), "translationY", 0, i *
     // 60);
     // 动画时间
     animator.setDuration(1000);
     // 动画延迟时间
     animator.setFrameDelay(500 * i);
     // 设置加速器
     animator.setInterpolator(new BounceInterpolator());
     // 启动动画
     animator.start();
     isNotExpand = false;
   }
 }
 void doTransition(View view, float to) {
   if (mAnim != null) {
     mAnim.cancel();
   }
   mAnim = ObjectAnimator.ofFloat(view, "alpha", to);
   mAnim.start();
 }
Example #24
0
 private void fadeIn(View v) {
   v.setAlpha(0f);
   ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(v, "alpha", 1f);
   alphaAnimator.setDuration(
       v.getContext().getResources().getInteger(android.R.integer.config_mediumAnimTime));
   alphaAnimator.start();
 }
  @Override
  public void setWeekParams(HashMap<String, Integer> params, String tz) {
    super.setWeekParams(params, tz);

    if (params.containsKey(VIEW_PARAMS_ORIENTATION)) {
      mOrientation = params.get(VIEW_PARAMS_ORIENTATION);
    }

    updateToday(tz);
    mNumCells = mNumDays + 1;

    if (params.containsKey(VIEW_PARAMS_ANIMATE_TODAY) && mHasToday) {
      synchronized (mAnimatorListener) {
        if (mTodayAnimator != null) {
          mTodayAnimator.removeAllListeners();
          mTodayAnimator.cancel();
        }
        mTodayAnimator =
            ObjectAnimator.ofInt(this, "animateTodayAlpha", Math.max(mAnimateTodayAlpha, 80), 255);
        mTodayAnimator.setDuration(150);
        mAnimatorListener.setAnimator(mTodayAnimator);
        mAnimatorListener.setFadingIn(true);
        mTodayAnimator.addListener(mAnimatorListener);
        mAnimateToday = true;
        mTodayAnimator.start();
      }
    }
  }
Example #26
0
  public void snapChild(final SwipeableItemView view) {
    final View animView = view.getSwipeableView().getView();
    final boolean canAnimViewBeDismissed = mCallback.canChildBeDismissed(view);
    final ObjectAnimator anim = createTranslationAnimation(animView, 0);
    final int duration = SNAP_ANIM_LEN;
    anim.setDuration(duration);
    anim.addUpdateListener(
        new AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            if (FADE_OUT_DURING_SWIPE && canAnimViewBeDismissed) {
              animView.setAlpha(getAlphaForOffset(animView));
            }
            invalidateGlobalRegion(animView);
          }
        });
    anim.addListener(
        new Animator.AnimatorListener() {
          @Override
          public void onAnimationStart(Animator animation) {}

          @Override
          public void onAnimationEnd(Animator animation) {
            animView.setAlpha(1.0f);
            mCallback.onDragCancelled(mCurrView);
          }

          @Override
          public void onAnimationCancel(Animator animation) {}

          @Override
          public void onAnimationRepeat(Animator animation) {}
        });
    anim.start();
  }
  /** Animation for the textview if the action bar is visible. */
  public void startShowAnimation() {
    if (mCurrentAnimation != null) mCurrentAnimation.cancel();

    mCurrentAnimation =
        ObjectAnimator.ofInt(
                mActionBarDelegate,
                TOP_MARGIN_ANIM_PROPERTY,
                (int) (Math.max(0, queryCurrentActionBarHeight() - mTabStripHeight)))
            .setDuration(SLIDE_DURATION_MS);

    mCurrentAnimation.addListener(
        new AnimatorListenerAdapter() {
          @Override
          public void onAnimationEnd(Animator animation) {
            mCurrentAnimation = null;
          }
        });

    mCurrentAnimation.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            ActionBar actionBar = mActionBarDelegate.getSupportActionBar();
            if (actionBar != null) {
              animation.setIntValues(
                  (int) (Math.max(0, queryCurrentActionBarHeight() - mTabStripHeight)));
            }
          }
        });

    mActionBarDelegate.setActionBarBackgroundVisibility(true);
    mCurrentAnimation.start();
    mShowingActionMode = true;
  }
Example #28
0
 private void animateArrow(boolean shouldRotateUp) {
   int start = shouldRotateUp ? 0 : MAX_LEVEL;
   int end = shouldRotateUp ? MAX_LEVEL : 0;
   ObjectAnimator animator = ObjectAnimator.ofInt(drawable, "level", start, end);
   animator.setInterpolator(new LinearOutSlowInInterpolator());
   animator.start();
 }
  public void animateClosed() {
    if (!(getParent() instanceof DragLayer)) return;
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0);
    PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 0.9f);
    PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 0.9f);
    final ObjectAnimator oa = LauncherAnimUtils.ofPropertyValuesHolder(this, alpha, scaleX, scaleY);

    oa.addListener(
        new AnimatorListenerAdapter() {
          @Override
          public void onAnimationEnd(Animator animation) {
            onCloseComplete();
            setLayerType(LAYER_TYPE_NONE, null);
            mState = STATE_SMALL;
          }

          @Override
          public void onAnimationStart(Animator animation) {
            sendCustomAccessibilityEvent(
                AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
                getContext().getString(R.string.folder_closed));
            mState = STATE_ANIMATING;
          }
        });
    oa.setDuration(mExpandDuration);
    setLayerType(LAYER_TYPE_HARDWARE, null);
    oa.start();
  }
Example #30
0
  private void showPostVoteAnimation(Vote vote) {
    if (vote == null || vote == Vote.NEUTRAL) return;

    // quickly center the vote button
    simulateScroll();

    String text = vote == Vote.UP ? "+" : (vote == Vote.DOWN ? "-" : "*");
    voteAnimationIndicator.setText(text);

    voteAnimationIndicator.setVisibility(View.VISIBLE);
    voteAnimationIndicator.setAlpha(0);
    voteAnimationIndicator.setScaleX(0.7f);
    voteAnimationIndicator.setScaleY(0.7f);

    ObjectAnimator animator =
        ObjectAnimator.ofPropertyValuesHolder(
            voteAnimationIndicator,
            ofFloat(View.ALPHA, 0, 0.6f, 0.7f, 0.6f, 0),
            ofFloat(View.SCALE_X, 0.7f, 1.3f),
            ofFloat(View.SCALE_Y, 0.7f, 1.3f));

    animator.start();
    animator.addListener(
        new AnimatorListenerAdapter() {
          @Override
          public void onAnimationEnd(Animator animation) {
            View view = PostFragment.this.voteAnimationIndicator;
            if (view != null) {
              view.setVisibility(View.GONE);
            }
          }
        });
  }