List of usage examples for android.animation ValueAnimator start
@Override public void start()
From source file:com.arlib.floatingsearchview.FloatingSearchView.java
private void closeMenuDrawable(final DrawerArrowDrawable drawerArrowDrawable, boolean withAnim) { if (withAnim) { ValueAnimator anim = ValueAnimator.ofFloat(1.0f, 0.0f); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/* ww w.j a v a 2 s . c o m*/ public void onAnimationUpdate(ValueAnimator animation) { float value = (Float) animation.getAnimatedValue(); drawerArrowDrawable.setProgress(value); } }); anim.setDuration(MENU_ICON_ANIM_DURATION); anim.start(); } else { drawerArrowDrawable.setProgress(0.0f); } }
From source file:com.android.nobug.view.pattern.PatternView.java
private void startCellStateAnimationSw(final CellState cellState, final float startAlpha, final float endAlpha, final float startTranslationY, final float endTranslationY, final float startScale, final float endScale, long delay, long duration, Interpolator interpolator, final Runnable finishRunnable) { cellState.alpha = startAlpha;/*from ww w.j a v a 2 s . c o m*/ cellState.translationY = startTranslationY; cellState.radius = mDotSize / 2 * startScale; ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f); animator.setDuration(duration); animator.setStartDelay(delay); animator.setInterpolator(interpolator); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float t = (float) animation.getAnimatedValue(); cellState.alpha = (1 - t) * startAlpha + t * endAlpha; cellState.translationY = (1 - t) * startTranslationY + t * endTranslationY; cellState.radius = mDotSize / 2 * ((1 - t) * startScale + t * endScale); invalidate(); } }); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (finishRunnable != null) { finishRunnable.run(); } } }); animator.start(); }
From source file:com.arlib.floatingsearchview.FloatingSearchView.java
private void fadeOutBackground() { ValueAnimator anim = ValueAnimator.ofInt(BACKGROUND_DRAWABLE_ALPHA_SEARCH_FOCUSED, BACKGROUND_DRAWABLE_ALPHA_SEARCH_NOT_FOCUSED); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/*from ww w . j a v a 2s . c om*/ public void onAnimationUpdate(ValueAnimator animation) { int value = (Integer) animation.getAnimatedValue(); mBackgroundDrawable.setAlpha(value); } }); anim.setDuration(BACKGROUND_FADE_ANIM_DURATION); anim.start(); }
From source file:com.arlib.floatingsearchview.FloatingSearchView.java
private void fadeInBackground() { ValueAnimator anim = ValueAnimator.ofInt(BACKGROUND_DRAWABLE_ALPHA_SEARCH_NOT_FOCUSED, BACKGROUND_DRAWABLE_ALPHA_SEARCH_FOCUSED); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override//from www. j a va 2 s .c o m public void onAnimationUpdate(ValueAnimator animation) { int value = (Integer) animation.getAnimatedValue(); mBackgroundDrawable.setAlpha(value); } }); anim.setDuration(BACKGROUND_FADE_ANIM_DURATION); anim.start(); }
From source file:es.ugr.swad.swadroid.gui.SwipeListViewTouchListener.java
private void performSwipeAction(final View swipeView, final int swipePosition, boolean toTheRight, boolean dismiss) { // Animate the dismissed list item to zero-height and fire the dismiss callback when // all dismissed list item animations have completed. This triggers layout on each animation // frame; in the future we may want to do something smarter and more performant. final ViewGroup.LayoutParams lp = swipeView.getLayoutParams(); final int originalHeight = swipeView.getHeight(); final boolean swipeRight = toTheRight; ValueAnimator animator; if (dismiss)//from w w w . j av a 2 s . c om animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime); else animator = ValueAnimator.ofInt(originalHeight, originalHeight - 1).setDuration(mAnimationTime); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { --mDismissAnimationRefCount; if (mDismissAnimationRefCount == 0) { // No active animations, process all pending dismisses. // Sort by descending position Collections.sort(mPendingSwipes); int[] swipePositions = new int[mPendingSwipes.size()]; for (int i = mPendingSwipes.size() - 1; i >= 0; i--) { swipePositions[i] = mPendingSwipes.get(i).position; } if (swipeRight) mCallback.onSwipeRight(mListView, swipePositions); else mCallback.onSwipeLeft(mListView, swipePositions); ViewGroup.LayoutParams lp; for (PendingSwipeData pendingDismiss : mPendingSwipes) { // Reset view presentation pendingDismiss.view.setAlpha(1f); pendingDismiss.view.setTranslationX(0); lp = pendingDismiss.view.getLayoutParams(); lp.height = originalHeight; pendingDismiss.view.setLayoutParams(lp); } mPendingSwipes.clear(); } } }); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { lp.height = (Integer) valueAnimator.getAnimatedValue(); swipeView.setLayoutParams(lp); } }); mPendingSwipes.add(new PendingSwipeData(swipePosition, swipeView)); animator.start(); }
From source file:com.zwj.customview.gesturelock.PatternView.java
private void startCellStateAnimationSw(final CellState cellState, final float startAlpha, final float endAlpha, final float startTranslationY, final float endTranslationY, final float startScale, final float endScale, long delay, long duration, Interpolator interpolator, final Runnable finishRunnable) { cellState.alpha = startAlpha;//from w ww . j a v a 2 s . c o m cellState.translationY = startTranslationY; cellState.radius = mDotRadius * startScale; ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f); animator.setDuration(duration); animator.setStartDelay(delay); animator.setInterpolator(interpolator); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float t = (float) animation.getAnimatedValue(); cellState.alpha = (1 - t) * startAlpha + t * endAlpha; cellState.translationY = (1 - t) * startTranslationY + t * endTranslationY; cellState.radius = mDotRadius * ((1 - t) * startScale + t * endScale); invalidate(); } }); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (finishRunnable != null) { finishRunnable.run(); } } }); animator.start(); }
From source file:com.me.harris.androidanimations._06_touch.swipelistview.SwipeListViewTouchListener.java
/** * Perform dismiss action//from www . j ava2 s . co m * @param dismissView View * @param dismissPosition Position of list */ private void performDismiss(final View dismissView, final int dismissPosition) { final ViewGroup.LayoutParams lp = dismissView.getLayoutParams(); final int originalHeight = dismissView.getHeight(); ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(animationTime); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { --dismissAnimationRefCount; if (dismissAnimationRefCount == 0) { // No active animations, process all pending dismisses. // Sort by descending position Collections.sort(pendingDismisses); int[] dismissPositions = new int[pendingDismisses.size()]; for (int i = pendingDismisses.size() - 1; i >= 0; i--) { dismissPositions[i] = pendingDismisses.get(i).position; } swipeListView.onDismiss(dismissPositions); ViewGroup.LayoutParams lp; for (PendingDismissData pendingDismiss : pendingDismisses) { // Reset view presentation ViewCompat.setAlpha(pendingDismiss.view, 1f); ViewCompat.setTranslationX(pendingDismiss.view, 0); lp = pendingDismiss.view.getLayoutParams(); lp.height = originalHeight; pendingDismiss.view.setLayoutParams(lp); } pendingDismisses.clear(); } } }); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { lp.height = (Integer) valueAnimator.getAnimatedValue(); dismissView.setLayoutParams(lp); } }); pendingDismisses.add(new PendingDismissData(dismissPosition, dismissView)); animator.start(); }
From source file:io.jawg.osmcontributor.ui.fragments.MapFragment.java
@Subscribe(threadMode = ThreadMode.MAIN) public void onPleaseChangePoiPosition(PleaseChangePoiPosition event) { Timber.d("Received event PleaseChangePoiPosition"); if (configManager.hasPoiModification()) { switchMode(MapMode.POI_POSITION_EDITION); creationPin.setVisibility(View.GONE); ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, OsmAnimatorUpdateListener.STEPS_CENTER_ANIMATION); valueAnimator.setDuration(900);/* www. j a va 2 s .c o m*/ valueAnimator.addUpdateListener(new OsmAnimatorUpdateListener(mapboxMap.getCameraPosition().target, markerSelected.getPosition(), mapboxMap)); valueAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { creationPin.setVisibility(View.VISIBLE); hideMarker(markerSelected); } }); valueAnimator.start(); } else { Toast.makeText(getActivity(), getResources().getString(R.string.point_modification_forbidden), Toast.LENGTH_SHORT).show(); } }
From source file:se.kth.csc.stayawhile.swipe.QueueTouchListener.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void performDismiss(final View dismissView, final int dismissPosition) { // Animate the dismissed list item to zero-height and fire the dismiss callback when // all dismissed list item animations have completed. This triggers layout on each animation // frame; in the future we may want to do something smarter and more performant. final ViewGroup.LayoutParams lp = dismissView.getLayoutParams(); final int originalLayoutParamsHeight = lp.height; final int originalHeight = dismissView.getHeight(); ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime); animator.addListener(new AnimatorListenerAdapter() { @Override/*from ww w. j a v a 2s . c o m*/ public void onAnimationEnd(Animator animation) { --mDismissAnimationRefCount; if (mDismissAnimationRefCount == 0) { // No active animations, process all pending dismisses. // Sort by descending position Collections.sort(mPendingDismisses); int[] dismissPositions = new int[mPendingDismisses.size()]; for (int i = mPendingDismisses.size() - 1; i >= 0; i--) { dismissPositions[i] = mPendingDismisses.get(i).position; } mQueueSwipeListener.onDismiss(mRecyclerView, dismissPositions); // Reset mDownPosition to avoid MotionEvent.ACTION_UP trying to start a dismiss // animation with a stale position mDownPosition = ListView.INVALID_POSITION; ViewGroup.LayoutParams lp; for (PendingActionData pendingDismiss : mPendingDismisses) { // Reset view presentation pendingDismiss.view.setAlpha(mAlpha); pendingDismiss.view.setTranslationX(0); lp = pendingDismiss.view.getLayoutParams(); lp.height = originalLayoutParamsHeight; pendingDismiss.view.setLayoutParams(lp); } // Send a cancel event long time = SystemClock.uptimeMillis(); MotionEvent cancelEvent = MotionEvent.obtain(time, time, MotionEvent.ACTION_CANCEL, 0, 0, 0); mRecyclerView.dispatchTouchEvent(cancelEvent); mPendingDismisses.clear(); mAnimatingPosition = ListView.INVALID_POSITION; } } }); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { lp.height = (Integer) valueAnimator.getAnimatedValue(); dismissView.setLayoutParams(lp); } }); mPendingDismisses.add(new PendingActionData(dismissPosition, dismissView)); animator.start(); }
From source file:com.android.systemui.statusbar.phone.NotificationPanelView.java
private void animateKeyguardStatusBarIn(long duration) { mKeyguardStatusBar.setVisibility(View.VISIBLE); mKeyguardStatusBar.setAlpha(0f);/*w w w .j a v a 2s . c o m*/ ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f); anim.addUpdateListener(mStatusBarAnimateAlphaListener); anim.setDuration(duration); anim.setInterpolator(mDozeAnimationInterpolator); anim.start(); }