List of usage examples for android.animation Animator addListener
public void addListener(AnimatorListener listener)
From source file:com.android.clear.reminder.ItemAnimator.java
@Override public boolean animateRemove(final ViewHolder holder) { endAnimation(holder);// w ww.j a va2s . c o m final float prevAlpha = holder.itemView.getAlpha(); final Animator removeAnimator = ObjectAnimator.ofFloat(holder.itemView, View.ALPHA, 0f); removeAnimator.setDuration(getRemoveDuration()); removeAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { dispatchRemoveStarting(holder); } @Override public void onAnimationEnd(Animator animator) { animator.removeAllListeners(); mAnimators.remove(holder); holder.itemView.setAlpha(prevAlpha); dispatchRemoveFinished(holder); } }); mRemoveAnimatorsList.add(removeAnimator); mAnimators.put(holder, removeAnimator); return true; }
From source file:org.cyanogenmod.designertools.ui.CreditsActivity.java
private void circularRevealActivity(View v) { int cx = v.getWidth() / 2; int cy = v.getHeight() / 2; float finalRadius = Math.max(v.getWidth(), v.getHeight()); // create the animator for this view (the start radius is zero) Animator circularReveal = ViewAnimationUtils.createCircularReveal(v, cx, cy, 0, finalRadius); circularReveal.setDuration(getResources().getInteger(R.integer.credits_circular_reveal_duration)); // make the view visible and start the animation v.setVisibility(View.VISIBLE); circularReveal.setInterpolator(new AccelerateDecelerateInterpolator()); circularReveal.addListener(new Animator.AnimatorListener() { @Override/* ww w . j a v a2 s. c o m*/ public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { animateContent(); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); circularReveal.start(); }
From source file:com.android.incallui.CircularRevealActivity.java
private void setupDecorView(final Point touchPoint, MaterialPalette palette) { final View view = getWindow().getDecorView(); // The circle starts from an initial size of 0 so clip it such that it is invisible. When // the animation later starts, this clip will be clobbered by the circular reveal clip. // See ViewAnimationUtils.createCircularReveal. view.setOutlineProvider(new ViewOutlineProvider() { @Override//from w w w. j av a2 s.c o m public void getOutline(View view, Outline outline) { // Using (0, 0, 0, 0) will not work since the outline will simply be treated as // an empty outline. outline.setOval(-1, -1, 0, 0); } }); view.setClipToOutline(true); if (palette != null) { view.findViewById(R.id.outgoing_call_animation_circle).setBackgroundColor(palette.mPrimaryColor); getWindow().setStatusBarColor(palette.mSecondaryColor); } view.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() { @Override public boolean onPreDraw() { final ViewTreeObserver vto = view.getViewTreeObserver(); if (vto.isAlive()) { vto.removeOnPreDrawListener(this); } final Animator animator = getRevealAnimator(touchPoint); // Since this animator is a RenderNodeAnimator (native animator), add an arbitary // start delay to force the onAnimationStart callback to happen later on the UI // thread. Otherwise it would happen right away inside animator.start() animator.setStartDelay(5); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { InCallPresenter.getInstance().onCircularRevealStarted(CircularRevealActivity.this); } @Override public void onAnimationEnd(Animator animation) { view.setClipToOutline(false); super.onAnimationEnd(animation); } }); animator.start(); return false; } }); }
From source file:liam.franco.selene.activities.MainActivity.java
private void animateCloseBottomFabSheet() { if (bottomFabBar != null && bottomFabBar.getVisibility() == View.VISIBLE) { final int[] xy = ViewUtils.viewCoordinates(fab); Animator animator = ViewAnimationUtils.createCircularReveal(bottomFabBar, (xy[0] + (fab.getMeasuredWidth() >> 1)), -bottomFabBar.getHeight(), Math.max(bottomFabBar.getWidth(), bottomFabBar.getHeight()), 0); animator.setDuration(500);/*from w w w .j a va 2 s.c om*/ animator.setStartDelay(500); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (fab != null) { fab.setVisibility(View.VISIBLE); } if (bottomFabBar != null) { bottomFabBar.setVisibility(View.INVISIBLE); } } }); animator.start(); } }
From source file:com.cryart.sabbathschool.viewmodel.SSQuarterliesViewModel.java
public void onMenuClick() { final View view = ssQuarterliesActivityBinding.ssLanguageMenu.ssLanguageMenu; final int state = view.getVisibility() == View.VISIBLE ? View.INVISIBLE : View.VISIBLE; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int centerX = view.getRight(); int centerY = 0; int startRadius = (state == View.VISIBLE) ? 0 : view.getHeight(); int endRadius = (state == View.VISIBLE) ? view.getHeight() : 0; Animator anim = ViewAnimationUtils.createCircularReveal(view, centerX, centerY, startRadius, endRadius); if (state == View.VISIBLE) { view.setVisibility(state);//from w w w.j a va 2 s . com ssQuarterliesActivityBinding.ssLanguageMenuOverlay.setVisibility(state); } else { anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); view.setVisibility(state); ssQuarterliesActivityBinding.ssLanguageMenuOverlay.setVisibility(state); } }); } anim.start(); } else { view.setVisibility(state); ssQuarterliesActivityBinding.ssLanguageMenuOverlay.setVisibility(state); } }
From source file:com.andremion.floatingnavigationview.FloatingNavigationView.java
private void startCloseAnimations() { // Icon/*from w w w.j ava 2s .c o m*/ AnimatedVectorDrawable closeIcon = (AnimatedVectorDrawable) ContextCompat.getDrawable(getContext(), R.drawable.ic_close_animated); mFabView.setImageDrawable(closeIcon); closeIcon.start(); // Unreveal int centerX = mFabRect.centerX(); int centerY = mFabRect.centerY(); float startRadius = getMaxRadius(); float endRadius = getMinRadius(); Animator reveal = ViewAnimationUtils.createCircularReveal(mNavigationView, centerX, centerY, startRadius, endRadius); reveal.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { detachNavigationView(); } }); // Fade out Animator fade = ObjectAnimator.ofFloat(mNavigationMenuView, View.ALPHA, 1, 0); // Animations AnimatorSet set = new AnimatorSet(); set.playTogether(fade, reveal); set.start(); }
From source file:shetye.prathamesh.notifyme.Utilities.java
public void hideView(final LinearLayout lview) { // get the center for the clipping circle int cx = (lview.getLeft() + lview.getRight()) / 2; int cy = (lview.getTop() + lview.getBottom()) / 2; // get the initial radius for the clipping circle int initialRadius = lview.getWidth(); // create the animation (the final radius is zero) Animator anim = ViewAnimationUtils.createCircularReveal(lview, cx, cy, initialRadius, 0); // make the view invisible when the animation is done anim.addListener(new AnimatorListenerAdapter() { @Override//from ww w.j a v a 2 s.com public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); lview.setVisibility(View.INVISIBLE); } }); anim.start(); }
From source file:com.google.android.apps.gutenberg.ScannerActivity.java
private void showCheckinAnimation(Checkin checkin) { if (mLastAnimator != null) { mLastAnimator.cancel();/*from w w w . ja v a2s .c o m*/ } final FrameLayout cover = (FrameLayout) findViewById(R.id.item_cover); cover.setVisibility(View.VISIBLE); final FrameLayout layer = (FrameLayout) findViewById(R.id.animation_layer); final CheckinHolder holder = new CheckinHolder(getLayoutInflater(), layer); FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); lp.gravity = Gravity.CENTER_VERTICAL; holder.setWillAnimate(true); holder.bind(checkin, mImageLoader); holder.itemView.setBackgroundColor(Color.rgb(0xf0, 0xf0, 0xf0)); float elevation = getResources().getDimension(R.dimen.popup_elevation); ViewCompat.setTranslationZ(holder.itemView, elevation); holder.setLines(false, false); layer.addView(holder.itemView, lp); // Interpolator for animators FastOutSlowInInterpolator interpolator = new FastOutSlowInInterpolator(); // Pop-up Animator popUpAnim = AnimatorInflater.loadAnimator(this, R.animator.pop_up); popUpAnim.setTarget(holder.itemView); popUpAnim.setInterpolator(interpolator); popUpAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { holder.animateCheckin(); } }); // Wait ObjectAnimator waitAnim = new ObjectAnimator(); waitAnim.setTarget(holder.itemView); waitAnim.setPropertyName("translationY"); waitAnim.setFloatValues(0.f, 0.f); waitAnim.setDuration(2000); // Slide-down ObjectAnimator slideDownAnim = new ObjectAnimator(); slideDownAnim.setTarget(holder.itemView); slideDownAnim.setPropertyName("translationY"); slideDownAnim.setFloatValues(0.f, calcSlideDistance()); slideDownAnim.setInterpolator(interpolator); // Landing anim ObjectAnimator landingAnim = new ObjectAnimator(); landingAnim.setTarget(holder.itemView); landingAnim.setPropertyName("translationZ"); landingAnim.setFloatValues(elevation, 0.f); landingAnim.setInterpolator(interpolator); landingAnim.setDuration(500); // Play the animators AnimatorSet set = new AnimatorSet(); set.setInterpolator(interpolator); set.playSequentially(popUpAnim, waitAnim, slideDownAnim, landingAnim); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { clean(); } @Override public void onAnimationCancel(Animator animation) { clean(); } private void clean() { mLastAnimator = null; layer.removeAllViews(); cover.setVisibility(View.INVISIBLE); } }); mLastAnimator = set; set.start(); }
From source file:com.google.samples.apps.iosched.ui.SearchActivity.java
/** * On Lollipop+ perform a circular animation (a contracting circular mask) when hiding the * search panel.//w w w. j a va 2 s.c om */ @TargetApi(Build.VERSION_CODES.LOLLIPOP) private void doExitAnim() { final View searchPanel = findViewById(R.id.search_panel); // Center the animation on the top right of the panel i.e. near to the search button which // launched this screen. The starting radius therefore is the diagonal distance from the top // right to the bottom left int revealRadius = (int) Math .sqrt(Math.pow(searchPanel.getWidth(), 2) + Math.pow(searchPanel.getHeight(), 2)); // Animating the radius to 0 produces the contracting effect Animator shrink = ViewAnimationUtils.createCircularReveal(searchPanel, searchPanel.getRight(), searchPanel.getTop(), revealRadius, 0f); shrink.setDuration(200L); shrink.setInterpolator( AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.fast_out_slow_in)); shrink.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { searchPanel.setVisibility(View.INVISIBLE); ActivityCompat.finishAfterTransition(SearchActivity.this); } }); shrink.start(); // We also animate out the translucent background at the same time. findViewById(R.id.scrim).animate().alpha(0f).setDuration(200L).setInterpolator( AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.fast_out_slow_in)) .start(); }
From source file:com.example.android.saddacampus.MainActivity.java
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) public void circleReveal(int viewID, int posFromRight, boolean containsOverflow, final boolean isShow) { final View myView = findViewById(viewID); int width = myView.getWidth(); if (posFromRight > 0) width -= (posFromRight//w w w . ja va2 s . c o m * getResources().getDimensionPixelSize(R.dimen.abc_action_button_min_width_material)) - (getResources().getDimensionPixelSize(R.dimen.abc_action_button_min_width_material) / 2); if (containsOverflow) width -= getResources().getDimensionPixelSize(R.dimen.abc_action_button_min_width_overflow_material); int cx = width; int cy = myView.getHeight() / 2; Animator anim; if (isShow) anim = ViewAnimationUtils.createCircularReveal(myView, cx, cy, 0, (float) width); else anim = ViewAnimationUtils.createCircularReveal(myView, cx, cy, (float) width, 0); anim.setDuration((long) 220); // make the view invisible when the animation is done anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (!isShow) { super.onAnimationEnd(animation); myView.setVisibility(View.INVISIBLE); } } }); // make the view visible and start the animation if (isShow) myView.setVisibility(View.VISIBLE); // start the animation anim.start(); }