Java Code Examples for android.animation.ObjectAnimator#setStartDelay()

The following examples show how to use android.animation.ObjectAnimator#setStartDelay() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CapturePhotoFragment.java    From MediaPickerInstagram with Apache License 2.0 6 votes vote down vote up
private void animateShutter() {
    mShutter.setVisibility(View.VISIBLE);
    mShutter.setAlpha(0.f);

    ObjectAnimator alphaInAnim = ObjectAnimator.ofFloat(mShutter, "alpha", 0f, 0.8f);
    alphaInAnim.setDuration(100);
    alphaInAnim.setStartDelay(100);
    alphaInAnim.setInterpolator(ACCELERATE_INTERPOLATOR);

    ObjectAnimator alphaOutAnim = ObjectAnimator.ofFloat(mShutter, "alpha", 0.8f, 0f);
    alphaOutAnim.setDuration(200);
    alphaOutAnim.setInterpolator(DECELERATE_INTERPOLATOR);

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playSequentially(alphaInAnim, alphaOutAnim);
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mShutter.setVisibility(View.GONE);
        }
    });
    animatorSet.start();
}
 
Example 2
Source File: PropertyAnimationActivity.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
/**
 * ObjectAnimator usage
 *
 * @param b
 * @return
 */
public ObjectAnimator getObjectAnimator(boolean b) {
    if (b) {
        ObjectAnimator bgColorAnimator = ObjectAnimator.ofArgb(mPuppet,
                "backgroundColor",
                0xff009688, 0xff795548);
        bgColorAnimator.setRepeatCount(1);
        bgColorAnimator.setDuration(3000);
        bgColorAnimator.setRepeatMode(ValueAnimator.REVERSE);
        bgColorAnimator.setStartDelay(0);
        return bgColorAnimator;
    } else {
        ObjectAnimator rotationXAnimator = ObjectAnimator.ofFloat(mPuppet,
                "rotationX",
                0f, 360f);
        rotationXAnimator.setRepeatCount(1);
        rotationXAnimator.setDuration(3000);
        rotationXAnimator.setRepeatMode(ValueAnimator.REVERSE);
        return rotationXAnimator;
    }
}
 
Example 3
Source File: CustormAnim.java    From LiveGiftLayout with Apache License 2.0 6 votes vote down vote up
@NonNull
    private AnimatorSet testAnim(GiftFrameLayout giftFrameLayout) {
        PropertyValuesHolder translationY = PropertyValuesHolder.ofFloat("translationY", 0, -50);
        PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1.0f, 0.5f);
        ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(giftFrameLayout, translationY, alpha);
        animator.setStartDelay(0);
        animator.setDuration(1500);

        translationY = PropertyValuesHolder.ofFloat("translationY", -50, -100);
        alpha = PropertyValuesHolder.ofFloat("alpha", 0.5f, 0f);
        ObjectAnimator animator1 = ObjectAnimator.ofPropertyValuesHolder(giftFrameLayout, translationY, alpha);
        animator1.setStartDelay(0);
        animator1.setDuration(1500);

        // 复原
//        ObjectAnimator fadeAnimator2 = GiftAnimationUtil.createFadeAnimator(giftFrameLayout, 0, 0, 0, 0);

        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.play(animator1).after(animator);
//        animatorSet.play(fadeAnimator2).after(animator1);
        animatorSet.start();
        return animatorSet;
    }
 
Example 4
Source File: LoadingOverlay.java    From android-skeleton-project with MIT License 6 votes vote down vote up
public void showLoading() {


            contentView.setVisibility(View.VISIBLE);
            ObjectAnimator carAnimator = ObjectAnimator.ofFloat(loAnim, "x", offscreen, carLeft);
            carAnimator.setDuration(SHOW_DURATION);
            carAnimator.setInterpolator(new AccelerateDecelerateInterpolator());

            ObjectAnimator textAnimator = ObjectAnimator.ofFloat(loText, "x", offscreen, loadingLeft);
            textAnimator.setDuration(SHOW_DURATION);
            textAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
            textAnimator.setStartDelay(100);

            AnimatorSet set = new AnimatorSet();
            set.playTogether(carAnimator, textAnimator);
            set.start();
        }
 
Example 5
Source File: ObjectAnimationActivity2.java    From MaterialDesignDemo with MIT License 5 votes vote down vote up
public void startFirstAnimation(View view) {
    // 翻转动画
    ObjectAnimator rotationXAnimation = ObjectAnimator.ofFloat(mView1, "rotationX", 0f, 25f);
    // 透明动画
    ObjectAnimator alphaAnimation = ObjectAnimator.ofFloat(mView1, "alpha", 1f, 0.5f);
    // 缩放动画
    ObjectAnimator scaleXAnimation = ObjectAnimator.ofFloat(mView1, "scaleX", 1f, 0.8f);
    ObjectAnimator scaleYAnimation = ObjectAnimator.ofFloat(mView1, "scaleY", 1f, 0.8f);
    // 位移动画
    ObjectAnimator translationYAnimation = ObjectAnimator.ofFloat(mView1, "translationY", 0f, -0.1f * mView1.getHeight());
    // 翻转动画
    ObjectAnimator rerotationXAnimation = ObjectAnimator.ofFloat(mView1, "rotationX", 25f, 0f);
    rerotationXAnimation.setStartDelay(200);
    // 位移动画
    ObjectAnimator translationYAnimation2 = ObjectAnimator.ofFloat(mView2, "translationY", mView2.getHeight(), 0);
    translationYAnimation2.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            super.onAnimationStart(animation);
            mView2.setVisibility(View.VISIBLE);
        }
    });

    AnimatorSet as = new AnimatorSet();
    as.playTogether(rotationXAnimation, alphaAnimation, scaleXAnimation, scaleYAnimation, translationYAnimation, rerotationXAnimation, translationYAnimation2);
    as.setDuration(200);
    as.start();
}
 
Example 6
Source File: Ripple.java    From HeadsUp with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Starts the enter animation.
 */
public void enter() {
    cancel();

    final int radiusDuration = (int)
            (1000 * Math.sqrt(mOuterRadius / WAVE_TOUCH_DOWN_ACCELERATION * mDensity) + 0.5);

    final ObjectAnimator radius = ObjectAnimator.ofFloat(this, "radiusGravity", 1);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) radius.setAutoCancel(true);
    radius.setDuration(radiusDuration);
    radius.setInterpolator(LINEAR_INTERPOLATOR);
    radius.setStartDelay(RIPPLE_ENTER_DELAY);

    final ObjectAnimator cX = ObjectAnimator.ofFloat(this, "xGravity", 1);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) cX.setAutoCancel(true);
    cX.setDuration(radiusDuration);
    cX.setInterpolator(LINEAR_INTERPOLATOR);
    cX.setStartDelay(RIPPLE_ENTER_DELAY);

    final ObjectAnimator cY = ObjectAnimator.ofFloat(this, "yGravity", 1);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) cY.setAutoCancel(true);
    cY.setDuration(radiusDuration);
    cY.setInterpolator(LINEAR_INTERPOLATOR);
    cY.setStartDelay(RIPPLE_ENTER_DELAY);

    mAnimRadius = radius;
    mAnimX = cX;
    mAnimY = cY;

    // Enter animations always run on the UI thread, since it's unlikely
    // that anything interesting is happening until the user lifts their
    // finger.
    radius.start();
    cX.start();
    cY.start();
}
 
Example 7
Source File: RippleLayout.java    From fingerpoetry-android with Apache License 2.0 5 votes vote down vote up
private void startRipple(final Runnable animationEndRunnable) {
    if (eventCancelled) return;

    float endRadius = getEndRadius();

    cancelAnimations();

    rippleAnimator = new AnimatorSet();
    rippleAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (!ripplePersistent) {
                setRadius(0);
                setRippleAlpha(rippleAlpha);
            }
            if (animationEndRunnable != null && rippleDelayClick) {
                animationEndRunnable.run();
            }
            childView.setPressed(false);
        }
    });

    ObjectAnimator ripple = ObjectAnimator.ofFloat(this, radiusProperty, radius, endRadius);
    ripple.setDuration(rippleDuration);
    ripple.setInterpolator(new DecelerateInterpolator());
    ObjectAnimator fade = ObjectAnimator.ofInt(this, circleAlphaProperty, rippleAlpha, 0);
    fade.setDuration(rippleFadeDuration);
    fade.setInterpolator(new AccelerateInterpolator());
    fade.setStartDelay(rippleDuration - rippleFadeDuration - FADE_EXTRA_DELAY);

    if (ripplePersistent) {
        rippleAnimator.play(ripple);
    } else if (getRadius() > endRadius) {
        fade.setStartDelay(0);
        rippleAnimator.play(fade);
    } else {
        rippleAnimator.playTogether(ripple, fade);
    }
    rippleAnimator.start();
}
 
Example 8
Source File: SplashActivity.java    From Conquer with Apache License 2.0 5 votes vote down vote up
/**
 * logo的动画
 */
private void logoAnim() {
    iv_photo2 = findViewById(R.id.iv_photo2);
    ObjectAnimator oa1 = ObjectAnimator.ofFloat(iv_photo2, "Alpha", 0f, 1f).setDuration(800);
    oa1.start();
    oa1.setStartDelay(500);
    ObjectAnimator oa2 = ObjectAnimator.ofFloat(iv_photo2, "TranslationY", 0f, -100f).setDuration(800);
    oa2.setInterpolator(new OvershootInterpolator());
    oa2.start();
    oa2.setStartDelay(500);
}
 
Example 9
Source File: TransitionHelper.java    From Depth with MIT License 5 votes vote down vote up
static ValueAnimator exitAnimate(final DepthRelativeLayout target, final float moveY, final float customElevation, long delay, int subtractDelay, boolean continueOffscreen) {

        target.setPivotY(getDistanceToCenter(target));
        target.setPivotX(getDistanceToCenterX(target));
        target.setCameraDistance(10000 * target.getResources().getDisplayMetrics().density);

        ObjectAnimator rotationX = ObjectAnimator.ofFloat(target, View.ROTATION_X, TARGET_ROTATION_X).setDuration(DURATION);
        rotationX.setInterpolator(VALUEinterpolator);
        rotationX.setStartDelay(delay);
        rotationX.start();

        ObjectAnimator elevation = ObjectAnimator.ofFloat(target, "CustomShadowElevation", target.getCustomShadowElevation(), customElevation * target.getResources().getDisplayMetrics().density).setDuration(DURATION);
        elevation.setInterpolator(VALUEinterpolator);
        elevation.setStartDelay(delay);
        elevation.start();

        ObjectAnimator scaleX = ObjectAnimator.ofFloat(target, View.SCALE_X, TARGET_SCALE).setDuration(DURATION);
        scaleX.setInterpolator(new QuintOut());
        scaleX.setStartDelay(delay);
        scaleX.start();

        ObjectAnimator scaleY = ObjectAnimator.ofFloat(target, View.SCALE_Y, TARGET_SCALE).setDuration(DURATION);
        scaleY.setInterpolator(new QuintOut());
        scaleY.setStartDelay(delay);
        scaleY.start();

        ObjectAnimator rotation = ObjectAnimator.ofFloat(target, View.ROTATION, TARGET_ROTATION).setDuration(1600);
        rotation.setInterpolator(VALUEinterpolator);
        rotation.setStartDelay(delay);
        rotation.start();

        ObjectAnimator translationY = ObjectAnimator.ofFloat(target, View.TRANSLATION_Y, -moveY * target.getResources().getDisplayMetrics().density).setDuration(subtractDelay);
        translationY.setInterpolator(VALUEinterpolator);
        translationY.setStartDelay(delay);
        translationY.start();
        if (continueOffscreen) {
            continueOutToRight(target, moveY, subtractDelay);
        }
        return scaleY;
    }
 
Example 10
Source File: Ripple.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * Starts the enter animation.
 */
public void enter() {
    cancel();

    final int radiusDuration = (int)
            (1000 * Math.sqrt(mOuterRadius / WAVE_TOUCH_DOWN_ACCELERATION * mDensity) + 0.5);

    final ObjectAnimator radius = ObjectAnimator.ofFloat(this, "radiusGravity", 1);
    radius.setAutoCancel(true);
    radius.setDuration(radiusDuration);
    radius.setInterpolator(LINEAR_INTERPOLATOR);
    radius.setStartDelay(RIPPLE_ENTER_DELAY);

    final ObjectAnimator cX = ObjectAnimator.ofFloat(this, "xGravity", 1);
    cX.setAutoCancel(true);
    cX.setDuration(radiusDuration);
    cX.setInterpolator(LINEAR_INTERPOLATOR);
    cX.setStartDelay(RIPPLE_ENTER_DELAY);

    final ObjectAnimator cY = ObjectAnimator.ofFloat(this, "yGravity", 1);
    cY.setAutoCancel(true);
    cY.setDuration(radiusDuration);
    cY.setInterpolator(LINEAR_INTERPOLATOR);
    cY.setStartDelay(RIPPLE_ENTER_DELAY);

    mAnimRadius = radius;
    mAnimX = cX;
    mAnimY = cY;

    // Enter animations always run on the UI thread, since it's unlikely
    // that anything interesting is happening until the user lifts their
    // finger.
    radius.start();
    cX.start();
    cY.start();
}
 
Example 11
Source File: UDAnimator.java    From VideoOS-Android-SDK with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 启动延时
 *
 * @param delay
 * @return
 */
public UDAnimator setStartDelay(long delay) {
    ObjectAnimator animator = getAnimator();
    if (animator != null && delay >= 0) {
        animator.setStartDelay(delay);
    }
    return this;
}
 
Example 12
Source File: NewTabPageRecyclerView.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onCardBound(CardViewHolder cardViewHolder) {
    if (cardViewHolder.getAdapterPosition() == getNewTabPageAdapter().getFirstCardPosition()) {
        updatePeekingCard(cardViewHolder);
    } else {
        cardViewHolder.setNotPeeking();
    }

    // Animate the peeking card.
    // We only run if the feature is enabled and once per NTP.
    if (!shouldAnimateFirstCard()) return;
    mFirstCardAnimationRun = true;

    // We only want an animation to run if we are not scrolled.
    if (computeVerticalScrollOffset() != 0) return;

    // We only show the animation a certain number of times to a user.
    ChromePreferenceManager manager = ChromePreferenceManager.getInstance();
    int animCount = manager.getNewTabPageFirstCardAnimationRunCount();
    if (animCount > CardsVariationParameters.getFirstCardAnimationMaxRuns()) return;
    manager.setNewTabPageFirstCardAnimationRunCount(animCount + 1);

    // We do not show the animation if the user has previously seen it then scrolled.
    if (manager.getCardsImpressionAfterAnimation()) return;

    // The peeking card bounces up twice from its position.
    ObjectAnimator animator =
            ObjectAnimator.ofFloat(cardViewHolder.itemView, View.TRANSLATION_Y, 0f,
                    -mPeekingCardBounceDistance, 0f, -mPeekingCardBounceDistance, 0f);
    animator.setStartDelay(PEEKING_CARD_ANIMATION_START_DELAY_MS);
    animator.setDuration(PEEKING_CARD_ANIMATION_TIME_MS);
    animator.setInterpolator(PEEKING_CARD_INTERPOLATOR);
    animator.start();
}
 
Example 13
Source File: Workspace.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
private void fadeAndRemoveEmptyScreen(int delay, int duration, final Runnable onComplete,
        final boolean stripEmptyScreens) {
     
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0f);
    PropertyValuesHolder bgAlpha = PropertyValuesHolder.ofFloat("backgroundAlpha", 0f);

    final CellLayout cl = mWorkspaceScreens.get(EXTRA_EMPTY_SCREEN_ID);

    mRemoveEmptyScreenRunnable = new Runnable() {
        @Override
        public void run() {
            if (hasExtraEmptyScreen()) {
                mWorkspaceScreens.remove(EXTRA_EMPTY_SCREEN_ID);
                mScreenOrder.remove(EXTRA_EMPTY_SCREEN_ID);
                removeView(cl);
                if (stripEmptyScreens) {
                    stripEmptyScreens();
                }
            }
        }
    };

    ObjectAnimator oa = ObjectAnimator.ofPropertyValuesHolder(cl, alpha, bgAlpha);
    oa.setDuration(duration);
    oa.setStartDelay(delay);
    oa.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (mRemoveEmptyScreenRunnable != null) {
                mRemoveEmptyScreenRunnable.run();
            }
            if (onComplete != null) {
                onComplete.run();
            }
        }
    });
    oa.start();
}
 
Example 14
Source File: TimePickerDialog.java    From date_picker_converter with Apache License 2.0 4 votes vote down vote up
private void setCurrentItemShowing(int index, boolean animateCircle, boolean delayLabelAnimate,
        boolean announce) {
    mTimePicker.setCurrentItemShowing(index, animateCircle);

    TextView labelToAnimate;
    switch(index) {
        case HOUR_INDEX:
            int hours = mTimePicker.getHours();
            if (!mIs24HourMode) {
                hours = hours % 12;
            }
            mTimePicker.setContentDescription(mHourPickerDescription + ": " + hours);
            if (announce) {
                Utils.tryAccessibilityAnnounce(mTimePicker, mSelectHours);
            }
            labelToAnimate = mHourView;
            break;
        case MINUTE_INDEX:
            int minutes = mTimePicker.getMinutes();
            mTimePicker.setContentDescription(mMinutePickerDescription + ": " + minutes);
            if (announce) {
                Utils.tryAccessibilityAnnounce(mTimePicker, mSelectMinutes);
            }
            labelToAnimate = mMinuteView;
            break;
        default:
            int seconds = mTimePicker.getSeconds();
            mTimePicker.setContentDescription(mSecondPickerDescription + ": " + seconds);
            if (announce) {
                Utils.tryAccessibilityAnnounce(mTimePicker, mSelectSeconds);
            }
            labelToAnimate = mSecondView;
    }

    int hourColor = (index == HOUR_INDEX) ? mSelectedColor : mUnselectedColor;
    int minuteColor = (index == MINUTE_INDEX) ? mSelectedColor : mUnselectedColor;
    int secondColor = (index == SECOND_INDEX) ? mSelectedColor : mUnselectedColor;
    mHourView.setTextColor(hourColor);
    mMinuteView.setTextColor(minuteColor);
    mSecondView.setTextColor(secondColor);

    ObjectAnimator pulseAnimator = Utils.getPulseAnimator(labelToAnimate, 0.85f, 1.1f);
    if (delayLabelAnimate) {
        pulseAnimator.setStartDelay(PULSE_ANIMATOR_DELAY);
    }
    pulseAnimator.start();
}
 
Example 15
Source File: RippleBackground.java    From AsteroidOSSync with GNU General Public License v3.0 4 votes vote down vote up
private void init(final Context context, final AttributeSet attrs) {
    if (isInEditMode())
        return;

    if (null == attrs) {
        throw new IllegalArgumentException("Attributes should be provided to this view,");
    }

    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RippleBackground);
    rippleColor=typedArray.getColor(R.styleable.RippleBackground_rb_color, getResources().getColor(R.color.rippelColor));
    rippleStrokeWidth=typedArray.getDimension(R.styleable.RippleBackground_rb_strokeWidth, getResources().getDimension(R.dimen.rippleStrokeWidth));
    rippleRadius=typedArray.getDimension(R.styleable.RippleBackground_rb_radius,getResources().getDimension(R.dimen.rippleRadius));
    rippleDurationTime=typedArray.getInt(R.styleable.RippleBackground_rb_duration,DEFAULT_DURATION_TIME);
    rippleAmount=typedArray.getInt(R.styleable.RippleBackground_rb_rippleAmount,DEFAULT_RIPPLE_COUNT);
    rippleScale=typedArray.getFloat(R.styleable.RippleBackground_rb_scale,DEFAULT_SCALE);
    rippleType=typedArray.getInt(R.styleable.RippleBackground_rb_type,DEFAULT_FILL_TYPE);
    typedArray.recycle();

    rippleDelay=rippleDurationTime/rippleAmount;

    paint = new Paint();
    paint.setAntiAlias(true);
    if(rippleType==DEFAULT_FILL_TYPE){
        rippleStrokeWidth=0;
        paint.setStyle(Paint.Style.FILL);
    }else
        paint.setStyle(Paint.Style.STROKE);
    paint.setColor(rippleColor);

    rippleParams=new LayoutParams((int)(2*(rippleRadius+rippleStrokeWidth)),(int)(2*(rippleRadius+rippleStrokeWidth)));
    rippleParams.addRule(CENTER_IN_PARENT, TRUE);

    animatorSet = new AnimatorSet();
    animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
    animatorList=new ArrayList<Animator>();

    for(int i=0;i<rippleAmount;i++){
        RippleView rippleView=new RippleView(getContext());
        addView(rippleView,rippleParams);
        rippleViewList.add(rippleView);
         final ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(rippleView, "ScaleX", 1.0f, rippleScale);
        scaleXAnimator.setRepeatCount(ObjectAnimator.INFINITE);
        scaleXAnimator.setRepeatMode(ObjectAnimator.RESTART);
        scaleXAnimator.setStartDelay(i * rippleDelay);
        scaleXAnimator.setDuration(rippleDurationTime);
        animatorList.add(scaleXAnimator);
        final ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(rippleView, "ScaleY", 1.0f, rippleScale);
        scaleYAnimator.setRepeatCount(ObjectAnimator.INFINITE);
        scaleYAnimator.setRepeatMode(ObjectAnimator.RESTART);
        scaleYAnimator.setStartDelay(i * rippleDelay);
        scaleYAnimator.setDuration(rippleDurationTime);
        animatorList.add(scaleYAnimator);
        final ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(rippleView, "Alpha", 1.0f, 0f);
        alphaAnimator.setRepeatCount(ObjectAnimator.INFINITE);
        alphaAnimator.setRepeatMode(ObjectAnimator.RESTART);
        alphaAnimator.setStartDelay(i * rippleDelay);
        alphaAnimator.setDuration(rippleDurationTime);
        animatorList.add(alphaAnimator);
    }

    animatorSet.playTogether(animatorList);
}
 
Example 16
Source File: LikeButtonView.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
private void setupAnimation() {
  animatorSet = new AnimatorSet();

  ObjectAnimator outerCircleAnimator =
      ObjectAnimator.ofFloat(vCircle, CircleView.OUTER_CIRCLE_RADIUS_PROGRESS, 0.1f, 1f);
  outerCircleAnimator.setDuration(250);
  outerCircleAnimator.setInterpolator(DECELERATE_INTERPOLATOR);

  ObjectAnimator innerCircleAnimator =
      ObjectAnimator.ofFloat(vCircle, CircleView.INNER_CIRCLE_RADIUS_PROGRESS, 0.1f, 1f);
  innerCircleAnimator.setDuration(200);
  innerCircleAnimator.setStartDelay(200);
  innerCircleAnimator.setInterpolator(DECELERATE_INTERPOLATOR);

  ObjectAnimator starScaleYAnimator = ObjectAnimator.ofFloat(vHeart, ImageView.SCALE_Y, 0.2f, 1f);
  starScaleYAnimator.setDuration(350);
  starScaleYAnimator.setStartDelay(250);
  starScaleYAnimator.setInterpolator(OVERSHOOT_INTERPOLATOR);

  ObjectAnimator starScaleXAnimator = ObjectAnimator.ofFloat(vHeart, ImageView.SCALE_X, 0.2f, 1f);
  starScaleXAnimator.setDuration(350);
  starScaleXAnimator.setStartDelay(250);
  starScaleXAnimator.setInterpolator(OVERSHOOT_INTERPOLATOR);

  ObjectAnimator dotsAnimator = ObjectAnimator.ofFloat(vDotsView, DotsView.DOTS_PROGRESS, 0, 1f);
  dotsAnimator.setDuration(900);
  dotsAnimator.setStartDelay(50);
  dotsAnimator.setInterpolator(ACCELERATE_DECELERATE_INTERPOLATOR);

  animatorSet.playTogether(outerCircleAnimator, innerCircleAnimator, starScaleYAnimator,
      starScaleXAnimator, dotsAnimator);

  animatorSet.addListener(new AnimatorListenerAdapter() {
    @Override public void onAnimationCancel(Animator animation) {
      vCircle.setInnerCircleRadiusProgress(0);
      vCircle.setOuterCircleRadiusProgress(0);
      vDotsView.setCurrentProgress(50);
      vHeart.setScaleX(1);
      vHeart.setScaleY(1);
    }
  });
}
 
Example 17
Source File: TimePickerDialog.java    From AssistantBySDK with Apache License 2.0 4 votes vote down vote up
private void setCurrentItemShowing(int index, boolean animateCircle, boolean delayLabelAnimate,
        boolean announce) {
    mTimePicker.setCurrentItemShowing(index, animateCircle);

    TextView labelToAnimate;
    switch(index) {
        case HOUR_INDEX:
            int hours = mTimePicker.getHours();
            if (!mIs24HourMode) {
                hours = hours % 12;
            }
            mTimePicker.setContentDescription(mHourPickerDescription + ": " + hours);
            if (announce) {
                Utils.tryAccessibilityAnnounce(mTimePicker, mSelectHours);
            }
            labelToAnimate = mHourView;
            break;
        case MINUTE_INDEX:
            int minutes = mTimePicker.getMinutes();
            mTimePicker.setContentDescription(mMinutePickerDescription + ": " + minutes);
            if (announce) {
                Utils.tryAccessibilityAnnounce(mTimePicker, mSelectMinutes);
            }
            labelToAnimate = mMinuteView;
            break;
        default:
            int seconds = mTimePicker.getSeconds();
            mTimePicker.setContentDescription(mSecondPickerDescription + ": " + seconds);
            if (announce) {
                Utils.tryAccessibilityAnnounce(mTimePicker, mSelectSeconds);
            }
            labelToAnimate = mSecondView;
    }

    int hourColor = (index == HOUR_INDEX) ? mSelectedColor : mUnselectedColor;
    int minuteColor = (index == MINUTE_INDEX) ? mSelectedColor : mUnselectedColor;
    int secondColor = (index == SECOND_INDEX) ? mSelectedColor : mUnselectedColor;
    mHourView.setTextColor(hourColor);
    mMinuteView.setTextColor(minuteColor);
    mSecondView.setTextColor(secondColor);

    ObjectAnimator pulseAnimator = Utils.getPulseAnimator(labelToAnimate, 0.85f, 1.1f);
    if (delayLabelAnimate) {
        pulseAnimator.setStartDelay(PULSE_ANIMATOR_DELAY);
    }
    pulseAnimator.start();
}
 
Example 18
Source File: RippleBackground.java    From Conquer with Apache License 2.0 4 votes vote down vote up
private void init(final Context context, final AttributeSet attrs) {
    if (isInEditMode()) return;

    if (null == attrs) {
        throw new IllegalArgumentException("Attributes should be provided to this view,");
    }

    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RippleBackground);
    rippleColor = typedArray.getColor(R.styleable.RippleBackground_rb_color, getResources().getColor(R.color.rippelColor));
    rippleStrokeWidth = typedArray.getDimension(R.styleable.RippleBackground_rb_strokeWidth,
            getResources().getDimension(R.dimen.rippleStrokeWidth));
    rippleRadius = typedArray.getDimension(R.styleable.RippleBackground_rb_radius, getResources().getDimension(R.dimen.rippleRadius));
    rippleDurationTime = typedArray.getInt(R.styleable.RippleBackground_rb_duration, DEFAULT_DURATION_TIME);
    rippleAmount = typedArray.getInt(R.styleable.RippleBackground_rb_rippleAmount, DEFAULT_RIPPLE_COUNT);
    rippleScale = typedArray.getFloat(R.styleable.RippleBackground_rb_scale, DEFAULT_SCALE);
    rippleType = typedArray.getInt(R.styleable.RippleBackground_rb_type, DEFAULT_FILL_TYPE);
    typedArray.recycle();

    rippleDelay = rippleDurationTime / rippleAmount;

    paint = new Paint();
    paint.setAntiAlias(true);
    if (rippleType == DEFAULT_FILL_TYPE) {
        rippleStrokeWidth = 0;
        paint.setStyle(Paint.Style.FILL);
    } else paint.setStyle(Paint.Style.STROKE);
    paint.setColor(rippleColor);

    rippleParams = new LayoutParams((int) (2 * (rippleRadius + rippleStrokeWidth)), (int) (2 * (rippleRadius + rippleStrokeWidth)));
    rippleParams.addRule(CENTER_IN_PARENT, TRUE);

    animatorSet = new AnimatorSet();
    animatorSet.setDuration(rippleDurationTime);
    animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
    animatorList = new ArrayList<Animator>();

    for (int i = 0; i < rippleAmount; i++) {
        RippleView rippleView = new RippleView(getContext());
        addView(rippleView, rippleParams);
        rippleViewList.add(rippleView);
        final ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(rippleView, "ScaleX", 1.0f, rippleScale);
        scaleXAnimator.setRepeatCount(ObjectAnimator.INFINITE);
        scaleXAnimator.setRepeatMode(ObjectAnimator.RESTART);
        scaleXAnimator.setStartDelay(i * rippleDelay);
        animatorList.add(scaleXAnimator);
        final ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(rippleView, "ScaleY", 1.0f, rippleScale);
        scaleYAnimator.setRepeatCount(ObjectAnimator.INFINITE);
        scaleYAnimator.setRepeatMode(ObjectAnimator.RESTART);
        scaleYAnimator.setStartDelay(i * rippleDelay);
        animatorList.add(scaleYAnimator);
        final ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(rippleView, "Alpha", 1.0f, 0f);
        alphaAnimator.setRepeatCount(ObjectAnimator.INFINITE);
        alphaAnimator.setRepeatMode(ObjectAnimator.RESTART);
        alphaAnimator.setStartDelay(i * rippleDelay);
        animatorList.add(alphaAnimator);
    }

    animatorSet.playTogether(animatorList);
}
 
Example 19
Source File: AnimateableDialogDecorator.java    From AndroidMaterialDialog with Apache License 2.0 4 votes vote down vote up
/**
 * Creates an animator, which should be used for a circle reveal animation.
 *
 * @param animatedView
 *         The animated view as an instance of the class {@link View}. The view may not be null
 * @param rootView
 *         The root view of the dialog as an instance of the class {@link View}. The view may
 *         not be null
 * @param animation
 *         The animation as an instance of the class {@link CircleRevealAnimation}. The
 *         animation may not be null
 * @param listener
 *         The listener, which should be notified about the animation's events, as an instance
 *         of type {@link AnimatorListener} or null, if no listener should be notified
 * @param show
 *         True, if the animation should be used for showing the dialog, false otherwise
 * @return The animator, which has been created, as an instance of the class {@link Animator} or
 * null, if no animation should be used
 */
@Nullable
private Animator createAnimator(@NonNull final View animatedView, @NonNull final View rootView,
                                @NonNull final CircleRevealAnimation animation,
                                @Nullable final AnimatorListener listener, final boolean show) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        long duration = getDuration(animatedView, animation);
        int horizontalDistance = Math.max(Math.abs(rootView.getLeft() - animation.getX()),
                Math.abs(rootView.getRight() - animation.getX()));
        int verticalDistance = Math.max(Math.abs(rootView.getTop() - animation.getY()),
                Math.abs(rootView.getBottom() - animation.getY()));
        float maxRadius = (float) Math
                .sqrt(Math.pow(horizontalDistance, 2) + Math.pow(verticalDistance, 2));
        Animator animator = ViewAnimationUtils
                .createCircularReveal(animatedView, animation.getX(), animation.getY(),
                        show ? animation.getRadius() : maxRadius,
                        show ? maxRadius : animation.getRadius());
        animator.setInterpolator(animation.getInterpolator());
        animator.setStartDelay(animation.getStartDelay());
        animator.setDuration(duration);

        if (listener != null) {
            animator.addListener(listener);
        }

        if (animation.getAlpha() != null) {
            ObjectAnimator alphaAnimator = ObjectAnimator
                    .ofFloat(animatedView, "alpha", show ? animation.getAlpha() : 1,
                            show ? 1 : animation.getAlpha());
            alphaAnimator.setInterpolator(animation.getInterpolator());
            alphaAnimator.setStartDelay(animation.getStartDelay());
            alphaAnimator.setDuration(duration);
            AnimatorSet animatorSet = new AnimatorSet();
            animatorSet.playTogether(animator, alphaAnimator);
            return animatorSet;
        }

        return animator;
    }

    return null;
}
 
Example 20
Source File: GuillotineAnimation.java    From SmartZPN with GNU Lesser General Public License v3.0 4 votes vote down vote up
private ObjectAnimator initAnimator(ObjectAnimator animator) {
    animator.setStartDelay(mDelay);
    return animator;
}