List of usage examples for android.animation ValueAnimator setStartDelay
@Override public void setStartDelay(long startDelay)
From source file:org.catrobat.paintroid.ui.BottomBar.java
private void delayedAnimateSelectedTool(int startDelay) { ImageButton button = getToolButtonByToolType(mCurrentToolType); int color = ContextCompat.getColor(button.getContext(), R.color.bottom_bar_button_activated); int fadedColor = color & 0x00ffffff; ValueAnimator valueAnimator = ObjectAnimator.ofInt(button, "backgroundColor", color, fadedColor); valueAnimator.setEvaluator(new ArgbEvaluator()); valueAnimator.setInterpolator(new LinearInterpolator()); valueAnimator.setDuration(500);/* w w w. j av a 2 s . co m*/ valueAnimator.setRepeatCount(5); valueAnimator.setRepeatMode(ValueAnimator.REVERSE); valueAnimator.setStartDelay(startDelay); valueAnimator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { if (PaintroidApplication.currentTool != null) { setActivatedToolButton(PaintroidApplication.currentTool.getToolType()); } } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); valueAnimator.start(); }
From source file:io.github.sin3hz.wifispinnerview.WifiSpinnerDrawable.java
private void setupAnimators() { AnimatorSet set = new AnimatorSet(); for (int i = 0; i < mSpinnerCount; i++) { final int index = i; final ValueAnimator sweepAnimator = ValueAnimator.ofFloat(0, MAX_SWEEP_ANGLE); sweepAnimator.setInterpolator(SWEEP_ANIMATOR_INTERPOLATOR); sweepAnimator.setDuration(mSweepAnimatorDuration); sweepAnimator.setRepeatMode(ValueAnimator.RESTART); sweepAnimator.setRepeatCount(ValueAnimator.INFINITE); sweepAnimator.setStartDelay(index * SWEEP_ANIMATOR_DELAY); sweepAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/*from w w w . j ava 2 s . c o m*/ public void onAnimationUpdate(ValueAnimator animation) { mSpinners[index].sweepAngle = (float) animation.getAnimatedValue(); mSpinners[index].updatePath(); invalidateSelf(); } }); sweepAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationRepeat(Animator animation) { mSpinners[index].sweepAngleOffset = (mSpinners[index].sweepAngleOffset + MAX_SWEEP_ANGLE) % 360; mSpinners[index].updatePath(); } }); set.playTogether(sweepAnimator); } mSweepAnimator = set; mAngleAnimator = ValueAnimator.ofFloat(0, 360); mAngleAnimator.setInterpolator(ANGLE_ANIMATOR_INTERPOLATOR); mAngleAnimator.setRepeatCount(ValueAnimator.INFINITE); mAngleAnimator.setRepeatMode(ValueAnimator.RESTART); mAngleAnimator.setDuration(ANGLE_ANIMATOR_DURATION); mAngleAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mGlobalAngle = (float) animation.getAnimatedValue(); updatePath(); invalidateSelf(); } }); }
From source file:org.digitalcampus.oppia.activity.DownloadMediaActivity.java
private void showDownloadMediaMessage() { TranslateAnimation anim = new TranslateAnimation(0, 0, -200, 0); anim.setDuration(900);/*w w w . j ava 2 s. c o m*/ missingMediaContainer.startAnimation(anim); missingMediaContainer.measure(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); ValueAnimator animator = ValueAnimator.ofInt(0, missingMediaContainer.getMeasuredHeight()); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { //@Override public void onAnimationUpdate(ValueAnimator valueAnimator) { mediaList.setPadding(0, (Integer) valueAnimator.getAnimatedValue(), 0, 0); mediaList.setSelectionAfterHeaderView(); } }); animator.setStartDelay(200); animator.setDuration(700); animator.start(); }
From source file:org.digitalcampus.oppia.activity.DownloadMediaActivity.java
private void hideDownloadMediaMessage() { TranslateAnimation anim = new TranslateAnimation(0, 0, 0, -200); anim.setDuration(900);/* www. j av a 2s . co m*/ missingMediaContainer.startAnimation(anim); missingMediaContainer.measure(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); ValueAnimator animator = ValueAnimator.ofInt(missingMediaContainer.getMeasuredHeight(), 0); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { //@Override public void onAnimationUpdate(ValueAnimator valueAnimator) { mediaList.setPadding(0, (Integer) valueAnimator.getAnimatedValue(), 0, 0); mediaList.setSelectionAfterHeaderView(); } }); animator.setStartDelay(0); animator.setDuration(700); animator.start(); missingMediaContainer.setVisibility(View.GONE); }
From source file:org.digitalcampus.oppia.activity.OppiaMobileActivity.java
private void animateScanMediaMessage() { TranslateAnimation anim = new TranslateAnimation(0, 0, -200, 0); anim.setDuration(900);/* w w w . j a va2 s . c om*/ messageContainer.startAnimation(anim); messageContainer.measure(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); ValueAnimator animator = ValueAnimator.ofInt(initialCourseListPadding, messageContainer.getMeasuredHeight()); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { //@Override public void onAnimationUpdate(ValueAnimator valueAnimator) { courseList.setPadding(0, (Integer) valueAnimator.getAnimatedValue(), 0, 0); courseList.setSelectionAfterHeaderView(); } }); animator.setStartDelay(200); animator.setDuration(700); animator.start(); }
From source file:com.bitants.wally.fragments.ImageZoomFragment.java
private void animateIn(final Dialog dialog) { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) zoomableImageView.getLayoutParams(); params.width = rect.right;// w w w .j a v a2 s .c om params.height = rect.bottom; zoomableImageView.setLayoutParams(params); zoomableImageView.setX(rect.left); zoomableImageView.setY(rect.top - statusBarHeightCorrection); zoomableImageView.setAlpha(0.0f); zoomableImageView.setImageBitmap(bitmap); WindowManager win = getActivity().getWindowManager(); Display d = win.getDefaultDisplay(); int displayWidth = d.getWidth(); // Width of the actual device int displayHeight = d.getHeight() + statusBarHeightCorrection; ValueAnimator animWidth = ValueAnimator.ofInt(rect.right, displayWidth); animWidth.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { int val = (Integer) valueAnimator.getAnimatedValue(); ViewGroup.LayoutParams layoutParams = zoomableImageView.getLayoutParams(); layoutParams.width = val; zoomableImageView.setLayoutParams(layoutParams); } }); animWidth.setDuration(500); animWidth.setInterpolator(new LinearOutSlowInInterpolator()); animWidth.start(); ValueAnimator animHeight = ValueAnimator.ofInt(rect.bottom, displayHeight); animHeight.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { int val = (Integer) valueAnimator.getAnimatedValue(); ViewGroup.LayoutParams layoutParams = zoomableImageView.getLayoutParams(); layoutParams.height = val; zoomableImageView.setLayoutParams(layoutParams); } }); animHeight.setDuration(500); animHeight.setInterpolator(new LinearOutSlowInInterpolator()); animHeight.start(); if (statusBarHeightCorrection > 0) { zoomableImageView.animate().y(0.0f).setDuration(300).start(); } ValueAnimator animDim = ValueAnimator.ofFloat(0.0f, 0.5f); animDim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(); layoutParams.copyFrom(dialog.getWindow().getAttributes()); layoutParams.dimAmount = (Float) valueAnimator.getAnimatedValue(); dialog.getWindow().setAttributes(layoutParams); } }); animDim.setDuration(300); animDim.setStartDelay(300); animDim.start(); zoomableImageView.animate().alpha(1.0f).setDuration(300).start(); }
From source file:com.bitants.wally.activities.ImageDetailsActivity.java
/** * Animations animations animations./* w ww .ja va 2s . com*/ * @param visibility if VISIBLE, expands toolbar. */ private void animateToolbar(int visibility) { float from; float to; int toolbarOffset; int fabOffset; if (visibility == View.VISIBLE) { from = 0.0f; to = 1.0f; fabOffset = 200; toolbarOffset = 0; } else { from = 1.0f; to = 0.0f; fabOffset = 0; toolbarOffset = 200; } buttonFullscreen.animate().scaleX(to).scaleY(to).setDuration(400).setStartDelay(fabOffset) .setInterpolator(new EaseInOutBezierInterpolator()).setListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { buttonFullscreen.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animator) { } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }).start(); int toolbarFrom; int toolbarTo; if (from > 0.0f) { toolbarFrom = getResources().getDimensionPixelSize(R.dimen.details_toolbar_height); toolbarTo = 0; } else { toolbarFrom = 0; toolbarTo = getResources().getDimensionPixelSize(R.dimen.details_toolbar_height); } ValueAnimator valueAnimator = ValueAnimator.ofInt(toolbarFrom, toolbarTo); valueAnimator.setDuration(400); valueAnimator.setStartDelay(toolbarOffset); valueAnimator.setInterpolator(new EaseInOutBezierInterpolator()); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { int val = (Integer) valueAnimator.getAnimatedValue(); RelativeLayout.LayoutParams toolbarParams = (RelativeLayout.LayoutParams) toolbar.getLayoutParams(); toolbarParams.height = val; toolbar.setLayoutParams(toolbarParams); } }); valueAnimator.start(); }
From source file:org.mythtv.client.ui.BackendStatusFragment.java
private void animateCardLinearLayout(final LinearLayout linearLayout, long startDelay) { linearLayout.setAlpha(1);// w w w . j a va2 s.c om // animator that translates linearlayout AnimatorUpdateListener translationAnimatorListener = new AnimatorUpdateListener() { /* (non-Javadoc) * @see android.animation.ValueAnimator.AnimatorUpdateListener#onAnimationUpdate(android.animation.ValueAnimator) */ @Override public void onAnimationUpdate(ValueAnimator animation) { Float w = (Float) animation.getAnimatedValue(); linearLayout.setTranslationY(w); } }; ValueAnimator scaleAnimator = ValueAnimator.ofFloat(linearLayout.getTranslationY(), 0f); scaleAnimator.setDuration(500); scaleAnimator.setRepeatCount(0); scaleAnimator.setStartDelay(startDelay); scaleAnimator.addUpdateListener(translationAnimatorListener); scaleAnimator.start(); }
From source file:com.android.settings.widget.DotsPageIndicator.java
private ValueAnimator createJoiningAnimator(final int leftJoiningDot, final long startDelay) { // animate the joining fraction for the given dot ValueAnimator joining = ValueAnimator.ofFloat(0f, 1.0f); joining.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/* w w w .j a v a2 s .c o m*/ public void onAnimationUpdate(ValueAnimator valueAnimator) { setJoiningFraction(leftJoiningDot, valueAnimator.getAnimatedFraction()); } }); joining.setDuration(animHalfDuration); joining.setStartDelay(startDelay); joining.setInterpolator(interpolator); return joining; }
From source file:android.support.graphics.drawable.AnimatorInflaterCompat.java
/** * @param anim The animator, must not be null * @param arrayAnimator Incoming typed array for Animator's attributes. * @param arrayObjectAnimator Incoming typed array for Object Animator's * attributes. * @param pixelSize The relative pixel size, used to calculate the * maximum error for path animations. *//*from ww w . j ava 2s . co m*/ private static void parseAnimatorFromTypeArray(ValueAnimator anim, TypedArray arrayAnimator, TypedArray arrayObjectAnimator, float pixelSize, XmlPullParser parser) { long duration = TypedArrayUtils.getNamedInt(arrayAnimator, parser, "duration", AndroidResources.STYLEABLE_ANIMATOR_DURATION, 300); long startDelay = TypedArrayUtils.getNamedInt(arrayAnimator, parser, "startOffset", AndroidResources.STYLEABLE_ANIMATOR_START_OFFSET, 0); int valueType = TypedArrayUtils.getNamedInt(arrayAnimator, parser, "valueType", AndroidResources.STYLEABLE_ANIMATOR_VALUE_TYPE, VALUE_TYPE_UNDEFINED); // Change to requiring both value from and to, otherwise, throw exception for now. if (TypedArrayUtils.hasAttribute(parser, "valueFrom") && TypedArrayUtils.hasAttribute(parser, "valueTo")) { if (valueType == VALUE_TYPE_UNDEFINED) { valueType = inferValueTypeFromValues(arrayAnimator, AndroidResources.STYLEABLE_ANIMATOR_VALUE_FROM, AndroidResources.STYLEABLE_ANIMATOR_VALUE_TO); } PropertyValuesHolder pvh = getPVH(arrayAnimator, valueType, AndroidResources.STYLEABLE_ANIMATOR_VALUE_FROM, AndroidResources.STYLEABLE_ANIMATOR_VALUE_TO, ""); if (pvh != null) { anim.setValues(pvh); } } anim.setDuration(duration); anim.setStartDelay(startDelay); anim.setRepeatCount(TypedArrayUtils.getNamedInt(arrayAnimator, parser, "repeatCount", AndroidResources.STYLEABLE_ANIMATOR_REPEAT_COUNT, 0)); anim.setRepeatMode(TypedArrayUtils.getNamedInt(arrayAnimator, parser, "repeatMode", AndroidResources.STYLEABLE_ANIMATOR_REPEAT_MODE, ValueAnimator.RESTART)); if (arrayObjectAnimator != null) { setupObjectAnimator(anim, arrayObjectAnimator, valueType, pixelSize, parser); } }