List of usage examples for android.animation AnimatorListenerAdapter AnimatorListenerAdapter
AnimatorListenerAdapter
From source file:com.btmura.android.reddit.app.AbstractBrowserActivity.java
private AnimatorSet newCollapseRightAnimator() { ObjectAnimator tcTransX = ObjectAnimator.ofFloat(thingContainer, "translationX", leftWidth, 0); AnimatorSet as = new AnimatorSet(); as.setDuration(durationMs).play(tcTransX); as.addListener(new AnimatorListenerAdapter() { @Override/*w ww. jav a 2s . c om*/ public void onAnimationStart(Animator animation) { if (leftContainer != null) { leftContainer.setVisibility(View.GONE); } rightContainer.setVisibility(View.VISIBLE); thingContainer.setLayerType(View.LAYER_TYPE_HARDWARE, null); thingContainer.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animation) { thingContainer.setLayerType(View.LAYER_TYPE_NONE, null); } }); return as; }
From source file:fr.cph.chicago.fragment.NearbyFragment.java
/** * Show progress bar/* ww w. j a v a 2 s . co m*/ * * @param show * true or falseO */ @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) private final void showProgress(final boolean show) { try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime); mLoadLayout.setVisibility(View.VISIBLE); mLoadLayout.animate().setDuration(shortAnimTime).alpha(show ? 1 : 0) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mLoadLayout.setVisibility(show ? View.VISIBLE : View.GONE); } }); } else { mLoadLayout.setVisibility(show ? View.VISIBLE : View.GONE); } mActivity.overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); } catch (IllegalStateException e) { Log.w(TAG, e.getMessage(), e); } }
From source file:com.android.tv.settings.dialog.SettingsLayoutFragment.java
private void prepareAndAnimateView(final View v, float initTransX, final boolean notifyAnimationFinished) { v.setLayerType(View.LAYER_TYPE_HARDWARE, null); v.buildLayer();/* w w w .j av a 2 s.c o m*/ v.setAlpha(0); v.setTranslationX(initTransX); v.animate().alpha(1f).translationX(0).setDuration(mAnimateInDuration).setStartDelay(mSecondaryAnimateDelay); v.animate().setInterpolator(new DecelerateInterpolator(1.0f)); v.animate().setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { v.setLayerType(View.LAYER_TYPE_NONE, null); if (notifyAnimationFinished) { onIntroAnimationFinished(); } } }); v.animate().start(); }
From source file:com.android.calculator2.Calculator.java
private void reveal(View sourceView, int colorRes, AnimatorListener listener) { final ViewGroupOverlay groupOverlay = (ViewGroupOverlay) getWindow().getDecorView().getOverlay(); final Rect displayRect = new Rect(); mDisplayView.getGlobalVisibleRect(displayRect); // Make reveal cover the display and status bar. final View revealView = new View(this); revealView.setBottom(displayRect.bottom); revealView.setLeft(displayRect.left); revealView.setRight(displayRect.right); revealView.setBackgroundColor(getResources().getColor(colorRes)); groupOverlay.add(revealView);/*from ww w.j a v a 2s . co m*/ final int[] clearLocation = new int[2]; sourceView.getLocationInWindow(clearLocation); clearLocation[0] += sourceView.getWidth() / 2; clearLocation[1] += sourceView.getHeight() / 2; final int revealCenterX = clearLocation[0] - revealView.getLeft(); final int revealCenterY = clearLocation[1] - revealView.getTop(); final double x1_2 = Math.pow(revealView.getLeft() - revealCenterX, 2); final double x2_2 = Math.pow(revealView.getRight() - revealCenterX, 2); final double y_2 = Math.pow(revealView.getTop() - revealCenterY, 2); final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2)); final Animator revealAnimator = ViewAnimationUtils.createCircularReveal(revealView, revealCenterX, revealCenterY, 0.0f, revealRadius); revealAnimator.setDuration(getResources().getInteger(android.R.integer.config_longAnimTime)); revealAnimator.addListener(listener); final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f); alphaAnimator.setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime)); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(revealAnimator).before(alphaAnimator); animatorSet.setInterpolator(new AccelerateDecelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { groupOverlay.remove(revealView); mCurrentAnimator = null; } }); mCurrentAnimator = animatorSet; animatorSet.start(); }
From source file:com.android.systemui.statusbar.phone.NavigationBarView.java
public void setLowProfile(final boolean lightsOut, final boolean animate, final boolean force) { if (!force && lightsOut == mLowProfile) return;/* w w w. j a va 2 s . co m*/ mLowProfile = lightsOut; if (DEBUG) Slog.d(TAG, "setting lights " + (lightsOut ? "out" : "on")); final View navButtons = mCurrentView.findViewById(R.id.nav_buttons); final View lowLights = mCurrentView.findViewById(R.id.lights_out); // ok, everyone, stop it right there navButtons.animate().cancel(); lowLights.animate().cancel(); if (!animate) { navButtons.setAlpha(lightsOut ? 0f : 1f); lowLights.setAlpha(lightsOut ? 1f : 0f); lowLights.setVisibility(lightsOut ? View.VISIBLE : View.GONE); } else { navButtons.animate().alpha(lightsOut ? 0f : 1f).setDuration(lightsOut ? 750 : 250).start(); lowLights.setOnTouchListener(mLightsOutListener); if (lowLights.getVisibility() == View.GONE) { lowLights.setAlpha(0f); lowLights.setVisibility(View.VISIBLE); } lowLights.animate().alpha(lightsOut ? 1f : 0f).setDuration(lightsOut ? 750 : 250) .setInterpolator(new AccelerateInterpolator(2.0f)) .setListener(lightsOut ? null : new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator _a) { lowLights.setVisibility(View.GONE); } }).start(); } }
From source file:com.google.samples.apps.sergio.ui.BaseActivity.java
private void setupAccountBoxToggle() { int selfItem = getSelfNavDrawerItem(); if (mDrawerLayout == null || selfItem == NAVDRAWER_ITEM_INVALID) { // this Activity does not have a nav drawer return;/*from w w w .jav a2 s. c o m*/ } mExpandAccountBoxIndicator.setImageResource(mAccountBoxExpanded ? R.drawable.ic_drawer_accounts_collapse : R.drawable.ic_drawer_accounts_expand); int hideTranslateY = -mAccountListContainer.getHeight() / 4; // last 25% of animation if (mAccountBoxExpanded && mAccountListContainer.getTranslationY() == 0) { // initial setup mAccountListContainer.setAlpha(0); mAccountListContainer.setTranslationY(hideTranslateY); } AnimatorSet set = new AnimatorSet(); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mDrawerItemsListContainer.setVisibility(mAccountBoxExpanded ? View.INVISIBLE : View.VISIBLE); mAccountListContainer.setVisibility(mAccountBoxExpanded ? View.VISIBLE : View.INVISIBLE); } @Override public void onAnimationCancel(Animator animation) { onAnimationEnd(animation); } }); if (mAccountBoxExpanded) { mAccountListContainer.setVisibility(View.VISIBLE); AnimatorSet subSet = new AnimatorSet(); subSet.playTogether( ObjectAnimator.ofFloat(mAccountListContainer, View.ALPHA, 1) .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION), ObjectAnimator.ofFloat(mAccountListContainer, View.TRANSLATION_Y, 0) .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION)); set.playSequentially(ObjectAnimator.ofFloat(mDrawerItemsListContainer, View.ALPHA, 0) .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION), subSet); set.start(); } else { mDrawerItemsListContainer.setVisibility(View.VISIBLE); AnimatorSet subSet = new AnimatorSet(); subSet.playTogether( ObjectAnimator.ofFloat(mAccountListContainer, View.ALPHA, 0) .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION), ObjectAnimator.ofFloat(mAccountListContainer, View.TRANSLATION_Y, hideTranslateY) .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION)); set.playSequentially(subSet, ObjectAnimator.ofFloat(mDrawerItemsListContainer, View.ALPHA, 1) .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION)); set.start(); } set.start(); }
From source file:com.btmura.android.reddit.app.AbstractBrowserActivity.java
private AnimatorSet newExpandRightAnimator() { ObjectAnimator tcTransX = ObjectAnimator.ofFloat(thingContainer, "translationX", 0, leftWidth); AnimatorSet as = new AnimatorSet(); as.setDuration(durationMs).play(tcTransX); as.addListener(new AnimatorListenerAdapter() { @Override// w ww .j a v a 2 s .c om public void onAnimationStart(Animator animation) { if (leftContainer != null) { leftContainer.setVisibility(View.GONE); } rightContainer.setVisibility(View.VISIBLE); thingContainer.setLayerType(View.LAYER_TYPE_HARDWARE, null); thingContainer.setVisibility(View.GONE); } @Override public void onAnimationEnd(Animator animation) { thingContainer.setLayerType(View.LAYER_TYPE_NONE, null); } }); return as; }
From source file:bottombar.BottomBar.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void backgroundCircularRevealAnimation(View clickedView, final int newColor) { int centerX = (int) (ViewCompat.getX(clickedView) + (clickedView.getMeasuredWidth() / 2)); int yOffset = isTabletMode ? (int) ViewCompat.getY(clickedView) : 0; int centerY = yOffset + clickedView.getMeasuredHeight() / 2; int startRadius = 0; int finalRadius = isTabletMode ? outerContainer.getHeight() : outerContainer.getWidth(); Animator animator = ViewAnimationUtils.createCircularReveal(backgroundOverlay, centerX, centerY, startRadius, finalRadius);/*from w ww.j ava 2 s . c o m*/ if (isTabletMode) { animator.setDuration(500); } animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { onEnd(); } @Override public void onAnimationCancel(Animator animation) { onEnd(); } private void onEnd() { outerContainer.setBackgroundColor(newColor); backgroundOverlay.setVisibility(View.INVISIBLE); ViewCompat.setAlpha(backgroundOverlay, 1); } }); animator.start(); }
From source file:com.pitchedapps.primenumbercalculator.Calculator.java
License:asdf
void exitReveal(View view) { // previously visible view final View myView = view; // get the initial radius for the clipping circle int initialRadius = Math.max(myView.getWidth(), myView.getHeight()); // create the animation (the final radius is zero) Animator anim = ViewAnimationUtils.createCircularReveal(myView, x, y, initialRadius, 0).setDuration(600); // make the view invisible when the animation is done anim.addListener(new AnimatorListenerAdapter() { @Override//from w ww . j ava 2 s . c o m public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); myView.setVisibility(View.INVISIBLE); } }); // start the animation anim.start(); }
From source file:com.achep.acdisplay.ui.fragments.AcDisplayFragment.java
/** * Updates the visibility of status clock (appears above on top of the screen). *///ww w. j av a 2s . c o m private void updateStatusClockVisibility(boolean visibleNow) { if (mStatusClockTextView == null) { return; } View view = mStatusClockTextView; boolean visible = view.getVisibility() == View.VISIBLE; if (visible == visibleNow) return; if (isAnimatable()) { final float[] values; if (visibleNow) { values = new float[] { 0.0f, 1.0f, 0.8f, 1.0f, 0.8f, 1.0f, }; view.setVisibility(View.VISIBLE); view.animate().setListener(null); } else { values = new float[] { 1.0f, 0.0f, 1.0f, 0.8f, 1.0f, 0.8f, }; view.animate().setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); mStatusClockTextView.setVisibility(View.GONE); } }); } view.setAlpha(values[0]); view.setScaleX(values[2]); view.setScaleY(values[4]); view.animate().alpha(values[1]).scaleX(values[3]).scaleY(values[5]); } else { ViewUtils.setVisible(view, visibleNow); } }