@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; } }
public void animateHidden() { if (!mIsHiddenOrHiding) { mVisibleAnimator.cancel(); mHiddenAnimator.end(); mHiddenAnimator.start(); } mIsHiddenOrHiding = true; }
public void startAnimation(View focused) { if (mAnimatorSet == null || focused == null) { return; } mAnimatorSet.end(); focused.getGlobalVisibleRect(rect); mXAnimator.setFloatValues(rect.left + mLeftOffset); mYAnimator.setFloatValues(rect.top + mTopOffset); mWAnimator.setIntValues(rect.width()); mHAnimator.setIntValues(rect.height()); mAnimatorSet.start(); }
public void animateVisible() { if (mIsHiddenOrHiding) { if (mViewToShowHide != null) { mViewToShowHide.setVisibility(View.INVISIBLE); } mHiddenAnimator.cancel(); mVisibleAnimator.end(); setVisibility(View.VISIBLE); mVisibleAnimator.start(); } mIsHiddenOrHiding = false; }
/** Starts the animation after taking the screenshot */ private void startAnimation( final Runnable finisher, int w, int h, boolean statusBarVisible, boolean navBarVisible) { // Add the view for the animation mScreenshotView.setImageBitmap(mScreenBitmap); mScreenshotLayout.requestFocus(); // Setup the animation with the screenshot just taken if (mScreenshotAnimation != null) { mScreenshotAnimation.end(); } mWindowManager.addView(mScreenshotLayout, mWindowLayoutParams); ValueAnimator screenshotDropInAnim = createScreenshotDropInAnimation(); ValueAnimator screenshotFadeOutAnim = createScreenshotDropOutAnimation(w, h, statusBarVisible, navBarVisible); mScreenshotAnimation = new AnimatorSet(); mScreenshotAnimation.playSequentially(screenshotDropInAnim, screenshotFadeOutAnim); mScreenshotAnimation.addListener( new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { // Save the screenshot once we have a bit of time now saveScreenshotInWorkerThread(finisher); mWindowManager.removeView(mScreenshotLayout); } }); mScreenshotLayout.post( new Runnable() { @Override public void run() { // Play the shutter sound to notify that we've taken a screenshot mCameraSound.playSound(CameraSound.SHUTTER_CLICK); mScreenshotView.setLayerType(View.LAYER_TYPE_HARDWARE, null); mScreenshotView.buildLayer(); mScreenshotAnimation.start(); } }); }
/** * 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); } }
@Override public void end() { mAnimatorSet.end(); }
@Override public void onUIRefreshComplete(PtrFrameLayout frame) { isRefreshing = false; circleAnimators.end(); postInvalidate(); }
private void setupAnimators() { if (mVisibleAnimator != null) { mVisibleAnimator.end(); } if (mHiddenAnimator != null) { mHiddenAnimator.end(); } final float fullSize = (mIsPortrait ? (float) getWidth() : (float) getHeight()); // show { final ValueAnimator radiusAnimator = ValueAnimator.ofFloat( mAnimateFrom.width() / 2.0f, fullSize - mAnimateFrom.width() / 2.0f); radiusAnimator.setDuration(RADIUS_ANIMATION_TIME); radiusAnimator.addUpdateListener( new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mRadius = (Float) animation.getAnimatedValue(); mDrawCircle = true; mFill = false; } }); radiusAnimator.addListener( new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mDrawCircle = false; mFill = true; } }); final ValueAnimator alphaAnimator = ValueAnimator.ofFloat(0.0f, 1.0f); alphaAnimator.setDuration(SHOW_ALPHA_ANIMATION_TIME); alphaAnimator.addUpdateListener( new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mActiveBar.setAlpha((Float) animation.getAnimatedValue()); } }); alphaAnimator.addListener( new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mActiveBar.setAlpha(1.0f); } }); final int deltaX = getResources().getDimensionPixelSize(R.dimen.mode_options_buttons_anim_delta_x); int childCount = mActiveBar.getChildCount(); ArrayList<Animator> paddingAnimators = new ArrayList<Animator>(); for (int i = 0; i < childCount; i++) { final View button; if (mIsPortrait) { button = mActiveBar.getChildAt(i); } else { button = mActiveBar.getChildAt(childCount - 1 - i); } final ValueAnimator paddingAnimator = ValueAnimator.ofFloat(deltaX * (childCount - i), 0.0f); paddingAnimator.setDuration(PADDING_ANIMATION_TIME); paddingAnimator.addUpdateListener( new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { if (mIsPortrait) { button.setTranslationX((Float) animation.getAnimatedValue()); } else { button.setTranslationY(-((Float) animation.getAnimatedValue())); } invalidate(); } }); paddingAnimators.add(paddingAnimator); } AnimatorSet paddingAnimatorSet = new AnimatorSet(); paddingAnimatorSet.playTogether(paddingAnimators); mVisibleAnimator = new AnimatorSet(); mVisibleAnimator.setInterpolator(Gusterpolator.INSTANCE); mVisibleAnimator.playTogether(radiusAnimator, alphaAnimator, paddingAnimatorSet); } // hide { final ValueAnimator radiusAnimator = ValueAnimator.ofFloat( fullSize - mAnimateFrom.width() / 2.0f, mAnimateFrom.width() / 2.0f); radiusAnimator.setDuration(RADIUS_ANIMATION_TIME); radiusAnimator.addUpdateListener( new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mRadius = (Float) animation.getAnimatedValue(); mDrawCircle = true; mFill = false; invalidate(); } }); radiusAnimator.addListener( new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (mViewToShowHide != null) { mViewToShowHide.setVisibility(View.VISIBLE); mDrawCircle = false; mFill = false; invalidate(); } } }); final ValueAnimator alphaAnimator = ValueAnimator.ofFloat(1.0f, 0.0f); alphaAnimator.setDuration(HIDE_ALPHA_ANIMATION_TIME); alphaAnimator.addUpdateListener( new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mActiveBar.setAlpha((Float) animation.getAnimatedValue()); invalidate(); } }); alphaAnimator.addListener( new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { setVisibility(View.INVISIBLE); if (mActiveBar != mMainBar) { mActiveBar.setAlpha(1.0f); mActiveBar.setVisibility(View.INVISIBLE); } mMainBar.setAlpha(1.0f); mMainBar.setVisibility(View.VISIBLE); mActiveBar = mMainBar; invalidate(); } }); mHiddenAnimator = new AnimatorSet(); mHiddenAnimator.setInterpolator(Gusterpolator.INSTANCE); mHiddenAnimator.playTogether(radiusAnimator, alphaAnimator); } }