public void setShown(boolean shown, boolean animate) { synchronized (mWindowManagerService.mWindowMap) { if (mShown == shown) { return; } mShown = shown; if (animate) { if (mShowHideFrameAnimator.isRunning()) { mShowHideFrameAnimator.reverse(); } else { if (shown) { mShowHideFrameAnimator.start(); } else { mShowHideFrameAnimator.reverse(); } } } else { mShowHideFrameAnimator.cancel(); if (shown) { setAlpha(MAX_ALPHA); } else { setAlpha(MIN_ALPHA); } } if (DEBUG_VIEWPORT_WINDOW) { Slog.i(LOG_TAG, "ViewportWindow shown: " + mShown); } } }
private void reverse(Animator a) { if (a instanceof AnimatorSet) { final ArrayList<Animator> animators = ((AnimatorSet) a).getChildAnimations(); for (Animator anim : animators) { reverse(anim); } } else if (a instanceof ValueAnimator) { ((ValueAnimator) a).reverse(); } }
/** Shows the search bar. */ public void showSearchBar(boolean animated) { if (!mIsSearchBarHidden) return; if (animated) { prepareStartAnimation(mQSBSearchBar); mHideSearchBarAnim.reverse(); } else { mHideSearchBarAnim.cancel(); if (mQSBSearchBar != null) { mQSBSearchBar.setAlpha(1f); } } mIsSearchBarHidden = false; }
@Override public boolean onTouchEvent(MotionEvent event) { switch (event.getActionMasked()) { case MotionEvent.ACTION_DOWN: return true; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: if (!mAnim.isRunning()) { if (mAnimText1ToText2) { mAnim.start(); } else if (!mAnimText1ToText2) { mAnim.reverse(); } return true; } } return false; }
/** Finishes all the animations on the search and drop target bars. */ public void finishAnimations() { prepareStartAnimation(mDropTargetBar); mShowDropTargetBarAnim.reverse(); prepareStartAnimation(mQSBSearchBar); mHideSearchBarAnim.reverse(); }