List of usage examples for android.animation AnimatorListenerAdapter AnimatorListenerAdapter
AnimatorListenerAdapter
From source file:com.android.incallui.CallCardFragment.java
/** * Animator that performs the upwards shrinking animation of the blue call card scrim. * At the start of the animation, each child view is moved downwards by a pre-specified amount * and then translated upwards together with the scrim. *//*from w w w . ja v a 2 s . co m*/ private Animator getShrinkAnimator(int startHeight, int endHeight) { final ObjectAnimator shrinkAnimator = ObjectAnimator.ofInt(mPrimaryCallCardContainer, "bottom", startHeight, endHeight); shrinkAnimator.setDuration(mShrinkAnimationDuration); shrinkAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { mFloatingActionButton.setEnabled(true); } }); shrinkAnimator.setInterpolator(AnimUtils.EASE_IN); return shrinkAnimator; }
From source file:com.zertinteractive.wallpaper.MainActivity.java
private void searchScreenRevealAnimation() { animateButtonsOut();/*from w ww . j a va 2s. c o m*/ android.animation.Animator anim = animateRevealColorFromCoordinates(recyclerView, R.color.sample_yellow, (fabSearchWallpaper.getLeft() + fabSearchWallpaper.getRight()) / 2, (fabSearchWallpaper.getTop() + fabSearchWallpaper.getBottom()) / 2 + 2 * (fabSearchWallpaper.getTop() - fabSearchWallpaper.getBottom())); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(android.animation.Animator animation) { animateButtonsIn(); if (isSearchScreenOpen) { recyclerView.setVisibility(View.VISIBLE); mAdView.setVisibility(View.VISIBLE); searchView.setVisibility(View.GONE); fabSearchWallpaper.setVisibility(View.VISIBLE); isSearchScreenOpen = false; } else { recyclerView.setVisibility(View.GONE); searchView.setVisibility(View.VISIBLE); mAdView.setVisibility(View.GONE); searchKey.setEnabled(true); searchKey.clearFocus(); searchKey.setHint("Search here ..."); fabSearchWallpaper.setVisibility(View.GONE); isSearchScreenOpen = true; isSearchingRunning = false; } } }); }
From source file:com.android.systemui.qs.QSDragPanel.java
private void shiftAllTilesRight(int startingIndex) { int desiredColumnCount = -1; for (int j = startingIndex; j < mRecords.size() - 1; j++) { final DragTileRecord ti = (DragTileRecord) mRecords.get(j); final DragTileRecord tnext = (DragTileRecord) mRecords.get(j + 1); mCurrentlyAnimating.add(ti);// www .j ava 2 s . c o m if (tnext.row != ti.row || desiredColumnCount == -1) { desiredColumnCount = getColumnCount(tnext.destinationPage, tnext.row); //Log.w(TAG, "updated desiredColumnCount: " + desiredColumnCount); } if (DEBUG_DRAG) { Log.v(TAG, "moving " + ti + " to page " + tnext.destinationPage + ", at coords: " + tnext.row + ", col: " + tnext.col + ", dest: " + tnext.destination); } ti.row = tnext.row; ti.col = tnext.col; ti.destination.x = getLeft(tnext.destinationPage, ti.row, ti.col, desiredColumnCount); ti.destination.y = getRowTop(ti.row); if (ti.destinationPage != tnext.destinationPage) { ti.destinationPage = tnext.destinationPage; final QSPage tilePageSource = getPage(ti.page); final QSPage tilePageTarget = getPage(ti.destinationPage); tilePageSource.removeView(ti.tileView); tilePageSource.addTransientView(ti.tileView, 0); ti.tileView.animate().withLayer().x(ti.destination.x + getWidth()).y(ti.destination.y) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationCancel(Animator animation) { tilePageSource.removeTransientView(ti.tileView); mCurrentlyAnimating.remove(ti); } @Override public void onAnimationEnd(Animator animation) { tilePageSource.removeTransientView(ti.tileView); tilePageTarget.addView(ti.tileView); ti.page = tilePageTarget.getPageIndex(); ti.tileView.setX(ti.destination.x); ti.tileView.setY(ti.destination.y); mCurrentlyAnimating.remove(ti); requestLayout(); } }); } else { ti.tileView.animate().withLayer().x(ti.destination.x).y(ti.destination.y) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationCancel(Animator animation) { mCurrentlyAnimating.remove(ti); } @Override public void onAnimationEnd(Animator animation) { mCurrentlyAnimating.remove(ti); final boolean dual = getPage(ti.destinationPage).dualRecord(ti); if (ti.tileView.setDual(dual, ti.tile.hasDualTargetsDetails())) { if (DEBUG_DRAG) { Log.w(TAG, ti + " changed dual state to : " + ti.tileView.isDual()); } } requestLayout(); } }); } } // need to do last tile manually final DragTileRecord last = (DragTileRecord) mRecords.get(mRecords.size() - 1); mCurrentlyAnimating.add(last); if (DEBUG_DRAG) { Log.i(TAG, "last tile shifting to the right: " + last); } setToNextDestination(last); if (last.page != last.destinationPage) { final QSPage tilePageSource = getPage(last.page); final QSPage tilePageTarget = getPage(last.destinationPage); tilePageSource.removeView(last.tileView); tilePageSource.addTransientView(last.tileView, 0); last.tileView.animate().withLayer().x(last.destination.x + getWidth()).y(last.destination.y) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationCancel(Animator animation) { tilePageSource.removeTransientView(last.tileView); mCurrentlyAnimating.remove(last); } @Override public void onAnimationEnd(Animator animation) { tilePageSource.removeTransientView(last.tileView); tilePageTarget.addView(last.tileView); last.page = tilePageTarget.getPageIndex(); last.tileView.setX(last.destination.x); last.tileView.setY(last.destination.y); if (DEBUG_DRAG) { Log.i(TAG, "page shift finished: " + last); } mCurrentlyAnimating.remove(last); requestLayout(); } }); } else { last.tileView.animate().withLayer().x(last.destination.x).y(last.destination.y) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationCancel(Animator animation) { mCurrentlyAnimating.remove(last); } @Override public void onAnimationEnd(Animator animation) { if (DEBUG_DRAG) { Log.i(TAG, "shift finished: " + last); } mCurrentlyAnimating.remove(last); requestLayout(); } }); } }
From source file:com.aimfire.demo.CamcorderActivity.java
/** * Style 1 animation will simulate a determinate loading * * @return Animator//from w w w . j a v a2s . com */ private Animator prepare3DAnimator() { final AnimatorSet animatorSet = new AnimatorSet(); mScanProgDrawable.setIndeterminate(false); mScanProgDrawable.setUseRotation(false); mScanProgDrawable.setUseArc(false); mScanProgDrawable.setUseAlpha(false); mScanProgDrawable.setUseWifiBar(true); mScanProgDrawable.setMessageText(getString(R.string.scanning)); mScanProgDrawable.setSuppText(getString(R.string.tap_to_stop)); //if(!mScanProgDrawable.getMessageText().equals(getString(R.string.connecting))) //{ //mScanProgDrawable.setMessageText(getString(R.string.scanning) + (mAnimCyclesCnt+1) + " of " + CONNECT_ANIM_CYCLES); //} Animator determinateAnimator = ObjectAnimator.ofFloat(mScanProgDrawable, CircularProgressDrawable.PROGRESS_PROPERTY, 0, 1); determinateAnimator.setDuration(CONNECT_ANIM_CYCLE_LENGTH_SECONDS * 1000); /* * wifi bar highlight changes 3 times a second */ Animator wifiBarAnimator = ObjectAnimator.ofInt(mScanProgDrawable, CircularProgressDrawable.WIFI_BAR_PROPERTY, 0, 2 * CONNECT_ANIM_CYCLE_LENGTH_SECONDS); wifiBarAnimator.setDuration(CONNECT_ANIM_CYCLE_LENGTH_SECONDS * 1000); wifiBarAnimator.setInterpolator(new LinearInterpolator()); animatorSet.playTogether(wifiBarAnimator, determinateAnimator); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { restartScanAnim(); } }); return animatorSet; }
From source file:android.support.transition.Transition.java
/** * This is a utility method used by subclasses to handle standard parts of * setting up and running an Animator: it sets the {@link #getDuration() * duration} and the {@link #getStartDelay() startDelay}, starts the * animation, and, when the animator ends, calls {@link #end()}. * * @param animator The Animator to be run during this transition. * * @hide//from w ww. j a va 2s . c om */ protected void animate(Animator animator) { // TODO: maybe pass auto-end as a boolean parameter? if (animator == null) { end(); } else { if (getDuration() >= 0) { animator.setDuration(getDuration()); } if (getStartDelay() >= 0) { animator.setStartDelay(getStartDelay()); } if (getInterpolator() != null) { animator.setInterpolator(getInterpolator()); } animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { end(); animation.removeListener(this); } }); animator.start(); } }
From source file:com.arlib.floatingsearchview.FloatingSearchView.java
private void transitionOutLeftSection(boolean withAnim) { switch (mLeftActionMode) { case LEFT_ACTION_MODE_SHOW_HAMBURGER: closeMenuDrawable(mMenuBtnDrawable, withAnim); break;//from w w w . j av a 2s .c o m case LEFT_ACTION_MODE_SHOW_SEARCH: changeIcon(mLeftAction, mIconSearch, withAnim); break; case LEFT_ACTION_MODE_SHOW_HOME: //do nothing break; case LEFT_ACTION_MODE_NO_LEFT_ACTION: mLeftAction.setImageDrawable(mIconBackArrow); if (withAnim) { ObjectAnimator searchInputTransXAnim = ViewPropertyObjectAnimator.animate(mSearchInputParent) .translationX(-Util.dpToPx(LEFT_MENU_WIDTH_AND_MARGIN_START_DP)).get(); ObjectAnimator scaleXArrowAnim = ViewPropertyObjectAnimator.animate(mLeftAction).scaleX(0.5f).get(); ObjectAnimator scaleYArrowAnim = ViewPropertyObjectAnimator.animate(mLeftAction).scaleY(0.5f).get(); ObjectAnimator fadeArrowAnim = ViewPropertyObjectAnimator.animate(mLeftAction).alpha(0.5f).get(); scaleXArrowAnim.setDuration(300); scaleYArrowAnim.setDuration(300); fadeArrowAnim.setDuration(300); scaleXArrowAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { //restore normal state mLeftAction.setScaleX(1.0f); mLeftAction.setScaleY(1.0f); mLeftAction.setAlpha(1.0f); mLeftAction.setVisibility(View.INVISIBLE); } }); AnimatorSet animSet = new AnimatorSet(); animSet.setDuration(350); animSet.playTogether(scaleXArrowAnim, scaleYArrowAnim, fadeArrowAnim, searchInputTransXAnim); animSet.start(); } else { mLeftAction.setVisibility(View.INVISIBLE); } break; } }
From source file:com.phonemetra.turbo.launcher.AsyncTaskCallback.java
private void enableOverviewMode(boolean enable, int snapPage, boolean animated) { State finalState = AppsCustomizePagedView.State.OVERVIEW; if (!enable) { finalState = AppsCustomizePagedView.State.NORMAL; }//from ww w. ja v a2 s . c o m mLauncher.updateOverviewPanel(); Animator appsCustomizeAnim = getChangeStateAnimation(finalState, animated, 0, snapPage); if (appsCustomizeAnim != null) { onTransitionPrepare(); appsCustomizeAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator arg0) { onTransitionEnd(); } }); appsCustomizeAnim.start(); } }
From source file:com.android.systemui.qs.QSDragPanel.java
private void shiftAllTilesLeft(int startingIndex) { DragTileRecord startingTile = (DragTileRecord) mRecords.get(startingIndex); final PointF lastLocation = new PointF(startingTile.destination.x, startingTile.destination.y); PointF reallyTempLoc = new PointF(); int lastRow = startingTile.row, lastCol = startingTile.col, tempRow, tempCol, lastPage = startingTile.destinationPage, tempPage; int desiredColCount = getColumnCount(startingTile.destinationPage, startingTile.row); for (int j = startingIndex + 1; j < mRecords.size(); j++) { final DragTileRecord ti = (DragTileRecord) mRecords.get(j); mCurrentlyAnimating.add(ti);//from w w w.j a va 2 s.co m if (DEBUG_DRAG) { Log.v(TAG, "moving " + ti + " to " + lastPage + ", at coords: " + lastRow + ", col: " + lastCol); Log.i(TAG, "and will have desiredColCount: " + desiredColCount); } final int columnCountF = desiredColCount; if (ti.row != lastRow) { desiredColCount = getColumnCount(ti.destinationPage, ti.row); if (DEBUG_DRAG) { Log.e(TAG, "updating desired colum count to: " + desiredColCount); } } // save current tile's loc reallyTempLoc.x = ti.destination.x; reallyTempLoc.y = ti.destination.y; tempRow = ti.row; tempCol = ti.col; tempPage = ti.destinationPage; ti.row = lastRow; ti.col = lastCol; ti.destination.x = getLeft(lastRow, lastCol, columnCountF, lastPage == 0 && lastRow == 0 && mFirstRowLarge); ti.destination.y = getRowTop(lastRow); final boolean dual = getPage(ti.destinationPage).dualRecord(ti); if (ti.destinationPage != lastPage) { ti.destinationPage = lastPage; ti.tileView.setX(reallyTempLoc.x + getWidth()); ti.tileView.setY(reallyTempLoc.y); final QSPage originalPage = getPage(ti.page); final QSPage page = getPage(lastPage); originalPage.removeView(ti.tileView); ti.tileView.animate().withLayer().x(ti.destination.x).y(ti.destination.y) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { page.addTransientView(ti.tileView, 0); } @Override public void onAnimationCancel(Animator animation) { page.removeTransientView(ti.tileView); mCurrentlyAnimating.remove(ti); } @Override public void onAnimationEnd(Animator animation) { page.removeTransientView(ti.tileView); page.addView(ti.tileView); ti.page = page.getPageIndex(); mCurrentlyAnimating.remove(ti); requestLayout(); } }); } else { ti.tileView.animate().withLayer().x(ti.destination.x).y(ti.destination.y) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mCurrentlyAnimating.remove(ti); if (ti.tileView.setDual(dual, ti.tile.hasDualTargetsDetails())) { if (DEBUG_DRAG) { Log.w(TAG, ti + " changed dual state to : " + ti.tileView.isDual()); } } requestLayout(); } }); } // update previous location lastLocation.x = reallyTempLoc.x; lastLocation.y = reallyTempLoc.y; lastRow = tempRow; lastCol = tempCol; lastPage = tempPage; } }
From source file:com.android.systemui.statusbar.phone.NotificationPanelView.java
private void flingSettings(float vel, boolean expand, final Runnable onFinishRunnable, boolean isClick) { float target = expand ? mQsMaxExpansionHeight : mQsMinExpansionHeight; if (target == mQsExpansionHeight) { mScrollYOverride = -1;// w w w.j a va 2 s . com if (onFinishRunnable != null) { onFinishRunnable.run(); } return; } boolean belowFalsingThreshold = isBelowFalsingThreshold(); if (belowFalsingThreshold) { vel = 0; } mScrollView.setBlockFlinging(true); ValueAnimator animator = ValueAnimator.ofFloat(mQsExpansionHeight, target); if (isClick) { animator.setInterpolator(mTouchResponseInterpolator); animator.setDuration(368); } else { mFlingAnimationUtils.apply(animator, mQsExpansionHeight, target, vel); } if (belowFalsingThreshold) { animator.setDuration(350); } animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { setQsExpansion((Float) animation.getAnimatedValue()); } }); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mScrollView.setBlockFlinging(false); mScrollYOverride = -1; mQsExpansionAnimator = null; if (onFinishRunnable != null) { onFinishRunnable.run(); } } }); animator.start(); mQsExpansionAnimator = animator; mQsAnimatorExpand = expand; }
From source file:app.umitems.greenclock.widget.sgv.StaggeredGridView.java
/** * Performs layout animation of child views. * @throws IllegalStateException Exception is thrown of currently set animation mode is * not recognized./*from w w w.j a v a2 s. com*/ */ private void handleLayoutAnimation() throws IllegalStateException { final List<Animator> animators = new ArrayList<Animator>(); // b/8422632 - Without this dummy first animator, startDelays of subsequent animators won't // be honored correctly; all animators will block regardless of startDelay until the first // animator in the AnimatorSet truly starts playing. final ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f); anim.setDuration(0); animators.add(anim); addOutAnimatorsForStaleViews(animators, mAnimationOutMode); // Play the In animators at a slight delay after all Out animators have started. final int animationInStartDelay = animators.size() > 0 ? (SgvAnimationHelper.getDefaultAnimationDuration() / 2) : 0; addInAnimators(animators, mAnimationInMode, animationInStartDelay); if (animators != null && animators.size() > 0) { final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(animators); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { mIsCurrentAnimationCanceled = false; mCurrentRunningAnimatorSet = animatorSet; } @Override public void onAnimationCancel(Animator animation) { mIsCurrentAnimationCanceled = true; } @Override public void onAnimationEnd(Animator animation) { if (!mIsCurrentAnimationCanceled) { // If this animation ended naturally, not because it was canceled, then // reset the animation mode back to ANIMATION_MODE_NONE. However, if // the animation was canceled by a data change, then keep the mode as is, // so that on a re-layout, we can resume animation from the views' current // positions. resetAnimationMode(); } mCurrentRunningAnimatorSet = null; } }); Log.v(TAG, "starting"); animatorSet.start(); } else { resetAnimationMode(); } mViewsToAnimateOut.clear(); mChildRectsForAnimation.clear(); }