List of usage examples for android.animation AnimatorListenerAdapter AnimatorListenerAdapter
AnimatorListenerAdapter
From source file:com.achep.acdisplay.ui.fragments.AcDisplayFragment.java
/** * Updates the visibility of divider between * the scene and icons./* w ww . j av a 2s . co m*/ */ @SuppressLint("NewApi") private void updateDividerVisibility(boolean animate) { final View view = mDividerView; final boolean visible = view.getVisibility() == View.VISIBLE; final boolean visibleNow = !mWidgetsMap.isEmpty(); if (animate && isAnimatable()) { int visibleInt = MathUtils.bool(visible); int visibleNowInt = MathUtils.bool(visibleNow); float[] values = { 1.0f, 0.1f, 1.0f, 0.5f }; ViewUtils.setVisible(view, true); view.setScaleX(values[1 - visibleInt]); view.setAlpha(values[3 - visibleInt]); view.animate().scaleX(values[1 - visibleNowInt]).alpha(values[3 - visibleNowInt]) .setInterpolator(new AccelerateInterpolator()).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); ViewUtils.setVisible(view, visibleNow, View.INVISIBLE); view.setAlpha(1); view.setScaleX(1); } }); } else { ViewUtils.setVisible(view, visibleNow, View.INVISIBLE); } }
From source file:com.aimfire.demo.CamcorderActivity.java
private Animator prepareRecordingAnimator(int durationSeconds) { final AnimatorSet animatorSet = new AnimatorSet(); mProgDrawable.setIndeterminate(false); mProgDrawable.setUseRotation(false); mProgDrawable.setUseArc(false);//from ww w . j a va 2 s . c o m mProgDrawable.setUseAlpha(false); mProgDrawable.setUseWifiBar(false); Animator determinateAnimator = ObjectAnimator.ofFloat(mProgDrawable, CircularProgressDrawable.PROGRESS_PROPERTY, 0, 1); determinateAnimator.setDuration(durationSeconds * 1000); animatorSet.playTogether(determinateAnimator); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { // we only need to execute this once if (mInSync) { syncStopRecording(); } else { soloStopRecording(); } } }); return animatorSet; }
From source file:com.android.systemui.qs.QSDragPanel.java
private void restoreDraggingTilePosition(View v, final Runnable onAnimationFinishedRunnable) { if (mRestored) { return;//from w ww.j a v a 2s . co m } mRestored = true; mRestoring = true; mCurrentlyAnimating.add(mDraggingRecord); if (DEBUG_DRAG) { Log.i(TAG, "restoreDraggingTilePosition() called with " + "v = [" + (v.getTag() != null ? v.getTag() : v) + "]"); } final boolean dragRecordDetached = mRecords.indexOf(mDraggingRecord) == -1; if (DEBUG_DRAG) { Log.v(TAG, "mLastLeftShift: " + mLastLeftShift + ", detached: " + dragRecordDetached + ", drag record: " + mDraggingRecord); } final QSPage originalPage = getPage(mDraggingRecord.page); originalPage.removeView(mDraggingRecord.tileView); addTransientView(mDraggingRecord.tileView, 0); mDraggingRecord.tileView.setTransitionVisibility(View.VISIBLE); // need to move center of the dragging view to the coords of the event. final float touchEventBoxLeft = v.getX() + (mLastTouchLocationX - (mDraggingRecord.tileView.getWidth() / 2)); final float touchEventBoxTop = v.getY() + (mLastTouchLocationY - (mDraggingRecord.tileView.getHeight() / 2)); mDraggingRecord.tileView.setX(touchEventBoxLeft); mDraggingRecord.tileView.setY(touchEventBoxTop); if (dragRecordDetached) { setToLastDestination(mDraggingRecord); if (DEBUG_DRAG) { Log.d(TAG, "setting drag record view to coords: x:" + touchEventBoxLeft + ", y:" + touchEventBoxTop); Log.d(TAG, "animating drag record to: " + mDraggingRecord + ", loc: " + mDraggingRecord.destination); } } else { mDraggingRecord.destination.x = getLeft(mDraggingRecord.destinationPage, mDraggingRecord.row, mDraggingRecord.col, getColumnCount(mDraggingRecord.destinationPage, mDraggingRecord.row)); mDraggingRecord.destination.y = getRowTop(mDraggingRecord.row); } // setup x destination to animate to float destinationX = mDraggingRecord.destination.x; // see if we should animate this to the left or right off the page // the +1's are to account for the edit page if (mDraggingRecord.destinationPage > mViewPager.getCurrentItem() - 1) { if (DEBUG_DRAG) { Log.d(TAG, "adding width to animate out >>>>>"); } destinationX += getWidth(); } else if (mDraggingRecord.destinationPage < mViewPager.getCurrentItem() - 1) { if (DEBUG_DRAG) { Log.d(TAG, "removing width to animate out <<<<<"); } destinationX -= getWidth(); } // setup y float destinationY = mDraggingRecord.destination.y + mViewPager.getTop(); mDraggingRecord.tileView.animate().withLayer().x(destinationX).y(destinationY) // part of the viewpager now .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { mDraggingRecord.tileView.setAlpha(1); } @Override public void onAnimationCancel(Animator animation) { mViewPager.requestDisallowInterceptTouchEvent(false); removeTransientView(mDraggingRecord.tileView); mCurrentlyAnimating.remove(mDraggingRecord); mRestoring = false; mPagerAdapter.notifyDataSetChanged(); onStopDrag(); if (onAnimationFinishedRunnable != null) { postOnAnimation(onAnimationFinishedRunnable); } } @Override public void onAnimationEnd(Animator animation) { mViewPager.requestDisallowInterceptTouchEvent(false); removeTransientView(mDraggingRecord.tileView); final QSPage targetP = getPage(mDraggingRecord.destinationPage); if (DEBUG_DRAG) { if (dragRecordDetached) { Log.i(TAG, "drag record was detached"); } else { Log.i(TAG, "drag record was attached"); } } targetP.addView(mDraggingRecord.tileView); mDraggingRecord.page = mDraggingRecord.destinationPage; mDraggingRecord.tileView.setX(mDraggingRecord.destination.x); // reset this to be in the coords of the page, not viewpager anymore mDraggingRecord.tileView.setY(mDraggingRecord.destination.y); mCurrentlyAnimating.remove(mDraggingRecord); mRestoring = false; if (dragRecordDetached) { mRecords.add(mDraggingRecord); mPagerAdapter.notifyDataSetChanged(); } onStopDrag(); if (onAnimationFinishedRunnable != null) { postOnAnimation(onAnimationFinishedRunnable); } else { requestLayout(); } } }); }
From source file:com.android.systemui.statusbar.phone.NotificationPanelView.java
private void animateHeaderSlidingOut() { mHeaderAnimating = true;//from www .ja va2 s . c om mHeader.animate().y(-mHeader.getHeight()).setStartDelay(0) .setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD) .setInterpolator(mFastOutSlowInInterpolator).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mHeader.animate().setListener(null); mHeaderAnimating = false; updateQsState(); } }).start(); mQsContainer.animate().y(-mQsContainer.getHeight()).setStartDelay(0) .setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD) .setInterpolator(mFastOutSlowInInterpolator).start(); }
From source file:com.android.systemui.statusbar.phone.NotificationPanelView.java
private void animateKeyguardStatusBarOut() { ValueAnimator anim = ValueAnimator.ofFloat(mKeyguardStatusBar.getAlpha(), 0f); anim.addUpdateListener(mStatusBarAnimateAlphaListener); anim.setStartDelay(mStatusBar.isKeyguardFadingAway() ? mStatusBar.getKeyguardFadingAwayDelay() : 0); anim.setDuration(mStatusBar.isKeyguardFadingAway() ? mStatusBar.getKeyguardFadingAwayDuration() / 2 : StackStateAnimator.ANIMATION_DURATION_STANDARD); anim.setInterpolator(mDozeAnimationInterpolator); anim.addListener(new AnimatorListenerAdapter() { @Override/* w w w . ja v a 2s . c o m*/ public void onAnimationEnd(Animator animation) { mAnimateKeyguardStatusBarInvisibleEndRunnable.run(); } }); anim.start(); }
From source file:com.filemanager.free.utils.Futils.java
public void crossfade(View buttons, final View pathbar) { // Set the content view to 0% opacity but visible, so that it is visible // (but fully transparent) during the animation. buttons.setAlpha(0f);/*w ww . j a v a 2 s .c o m*/ buttons.setVisibility(View.VISIBLE); // Animate the content view to 100% opacity, and clear any animation // listener set on the view. buttons.animate().alpha(1f).setDuration(100).setListener(null); pathbar.animate().alpha(0f).setDuration(100).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { pathbar.setVisibility(View.GONE); } }); // Animate the loading view to 0% opacity. After the animation ends, // set its visibility to GONE as an optimization step (it won't // participate in layout passes, etc.) }
From source file:com.android.incallui.CallCardFragment.java
@Override public void animateForNewOutgoingCall() { final ViewGroup parent = (ViewGroup) mPrimaryCallCardContainer.getParent(); final ViewTreeObserver observer = getView().getViewTreeObserver(); mIsAnimating = true;// ww w . j a v a 2 s . co m observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { final ViewTreeObserver observer = getView().getViewTreeObserver(); if (!observer.isAlive()) { return; } observer.removeOnGlobalLayoutListener(this); final LayoutIgnoringListener listener = new LayoutIgnoringListener(); mPrimaryCallCardContainer.addOnLayoutChangeListener(listener); // Prepare the state of views before the slide animation final int originalHeight = mPrimaryCallCardContainer.getHeight(); mPrimaryCallCardContainer.setTag(R.id.view_tag_callcard_actual_height, originalHeight); mPrimaryCallCardContainer.setBottom(parent.getHeight()); // Set up FAB. mFloatingActionButtonContainer.setVisibility(View.GONE); mFloatingActionButtonController.setScreenWidth(parent.getWidth()); mCallButtonsContainer.setAlpha(0); mCallStateLabel.setAlpha(0); mPrimaryName.setAlpha(0); mCallTypeLabel.setAlpha(0); mCallNumberAndLabel.setAlpha(0); assignTranslateAnimation(mCallStateLabel, 1); assignTranslateAnimation(mCallStateIcon, 1); assignTranslateAnimation(mPrimaryName, 2); assignTranslateAnimation(mCallNumberAndLabel, 3); assignTranslateAnimation(mCallTypeLabel, 4); assignTranslateAnimation(mCallButtonsContainer, 5); final Animator animator = getShrinkAnimator(parent.getHeight(), originalHeight); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mPrimaryCallCardContainer.setTag(R.id.view_tag_callcard_actual_height, null); setViewStatePostAnimation(listener); mIsAnimating = false; InCallPresenter.getInstance().onShrinkAnimationComplete(); } }); animator.start(); } }); }
From source file:com.zertinteractive.wallpaper.MainActivity.java
@SuppressWarnings("NewApi") private void animateRevealHide(final View viewRoot) { int cx = (viewRoot.getLeft() + viewRoot.getRight()) / 2; int cy = (viewRoot.getTop() + viewRoot.getBottom()) / 2; int initialRadius = viewRoot.getWidth(); android.animation.Animator anim = ViewAnimationUtils.createCircularReveal(viewRoot, cx, cy, initialRadius, 0);//from www .ja v a2 s . c o m anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(android.animation.Animator animation) { super.onAnimationEnd(animation); viewRoot.setVisibility(View.INVISIBLE); } }); anim.setDuration(getResources().getInteger(R.integer.anim_duration_medium)); anim.start(); }
From source file:com.filemanager.free.utils.Futils.java
public void crossfadeInverse(final View buttons, final View pathbar) { // Set the content view to 0% opacity but visible, so that it is visible // (but fully transparent) during the animation. pathbar.setAlpha(0f);/*from www .j a v a 2 s . co m*/ pathbar.setVisibility(View.VISIBLE); // Animate the content view to 100% opacity, and clear any animation // listener set on the view. pathbar.animate().alpha(1f).setDuration(500).setListener(null); buttons.animate().alpha(0f).setDuration(500).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { buttons.setVisibility(View.GONE); } }); // Animate the loading view to 0% opacity. After the animation ends, // set its visibility to GONE as an optimization step (it won't // participate in layout passes, etc.) }
From source file:com.app.afteryou.ui.staggered.StaggeredGridView.java
private void performAnimation() { if (!mViewCacheForAnim.isEmpty()) { isAnimating = true;/*from w w w . jav a 2s.co m*/ int count = mViewCacheForAnim.size(); final View view = mViewCacheForAnim.remove(0); Rect rect = new Rect(); this.getGlobalVisibleRect(rect); int fly_distance = (int) (rect.height()); float top = view.getY(); float bottom = view.getY() + view.getMeasuredHeight(); float startTop = top + fly_distance; float startBottom = bottom + fly_distance; int bufferDis = rect.height() / 4; if (startBottom < 0) { Log.d(TAG, "No animation as the view is passed!!"); view.setVisibility(View.VISIBLE); performAnimation(); return; } else if (startTop < rect.height()) { fly_distance += (rect.height() - startTop + bufferDis); } if (fly_distance > rect.height() * 2) { Log.d(TAG, "No animation as the fly distance is too long!"); view.setVisibility(View.VISIBLE); performAnimation(); return; } else if (fly_distance < rect.height()) { fly_distance = rect.height(); } view.setTranslationY(fly_distance); long delay = FLY_IN_DELAY / count; long duration = delay > FLY_IN_DURATION ? FLY_IN_DURATION : delay; view.animate().setDuration(duration).setInterpolator(new DecelerateInterpolator()) .setListener(new AnimatorListenerAdapter() { public void onAnimationStart(Animator anim) { view.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator anim) { view.clearAnimation(); view.setTranslationY(0f); performAnimation(); } }).translationY(0); } else { isAnimating = false; } }