public Bouncer(Context context, AttributeSet attrs, int flags) { super(context, attrs, flags); mAnimator = new TimeAnimator(); mAnimator.setTimeListener(this); }
/** * Sets up all the internal state to prepare for menu dragging. * @param startDragging Whether dragging is started. For example, if the app menu * is showed by tapping on a button, this should be false. If it is * showed by start dragging down on the menu button, this should be * true. */ void onShow(boolean startDragging) { mLastTouchX = Float.NaN; mLastTouchY = Float.NaN; mDragScrollOffset = 0.0f; mDragScrollOffsetRounded = 0; mDragScrollingVelocity = 0.0f; mIsSingleTapCanceled = false; if (startDragging) mDragScrolling.start(); }
/** * Stop animations when the view hierarchy is torn down. */ @Override public void onDetachedFromWindow() { mAnimator.cancel(); super.onDetachedFromWindow(); }
mTimeAnimator.setTimeListener(new TimeAnimator.TimeListener() { @Override public void onTimeUpdate(final TimeAnimator animation, mTimeAnimator.start(); } catch (IOException e) { e.printStackTrace();
private void updateVisibleProgress() { if (mAnimationLogic == null || (mIsUsingSmoothIndeterminate && !mIsRunningSmoothIndeterminate)) { super.setProgress(mTargetProgress); if (!mIsStarted) postOnAnimationDelayed(mHideRunnable, mHidingDelayMs); } else if (!mProgressAnimator.isStarted()) { mProgressAnimator.start(); } sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED); }
mDragScrolling.setTimeListener(new TimeAnimator.TimeListener() { @Override public void onTimeUpdate(TimeAnimator animation, long totalTime, long deltaTime) {
@Override public void onTimeUpdate(TimeAnimator animation, long totalTimeMs, long deltaTimeMs) { // Cap progress bar animation frame time so that it doesn't jump too much even when // the animation is janky. float progress = mAnimationLogic.updateProgress(mTargetProgress, Math.min(deltaTimeMs, PROGRESS_FRAME_TIME_CAP_MS) * 0.001f, getWidth()); progress = Math.max(progress, 0); ToolbarProgressBar.super.setProgress(progress); if (mAnimatingView != null) { int width = Math.abs( getDrawable().getBounds().right - getDrawable().getBounds().left); mAnimatingView.update(progress * width); } if (getProgress() == mTargetProgress) { if (!mIsStarted) postOnAnimationDelayed(mHideRunnable, mHidingDelayMs); mProgressAnimator.end(); return; } } });
mTimeAnimator.end(); mCodecWrapper.stopAndRelease(); mExtractor.release();
public Bouncer(Context context, AttributeSet attrs, int flags) { super(context, attrs, flags); mAnimator = new TimeAnimator(); mAnimator.setTimeListener(this); }
/** * Start the bouncing as soon as we’re on screen. */ @Override public void onAttachedToWindow() { super.onAttachedToWindow(); mAnimator.start(); }
/** * Stop animations when the view hierarchy is torn down. */ @Override public void onDetachedFromWindow() { mAnimator.cancel(); super.onDetachedFromWindow(); }
/** * Start the bouncing as soon as we’re on screen. */ @Override public void onAttachedToWindow() { super.onAttachedToWindow(); mAnimator.start(); }
/** * Dragging mode will be stopped by calling this function. Note that it will fall back to normal * non-dragging mode. */ void finishDragging() { // If the menu is being dismissed, we cannot access mAppMenu.getPopup().getListView() // needed to by menuItemAction. Only clear highlighting if the menu is still showing. // See crbug.com/589805. if (mAppMenu.getPopup().isShowing()) { menuItemAction(0, 0, ITEM_ACTION_CLEAR_HIGHLIGHT_ALL); } mDragScrolling.cancel(); }
@Override public void run() { if (!mIsStarted) return; mIsRunningSmoothIndeterminate = true; mAnimationLogic.reset(getProgress()); mProgressAnimator.start(); int width = Math.abs(getDrawable().getBounds().right - getDrawable().getBounds().left); mAnimatingView.update(getProgress() * width); mAnimatingView.startAnimation(); } };