Java Code Examples for android.animation.AnimatorSet#playTogether()

The following examples show how to use android.animation.AnimatorSet#playTogether() . 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: MusicalNoteLayout.java    From TikTok with Apache License 2.0 6 votes vote down vote up
private AnimatorSet getEnterAnimator(final View target) {
    ObjectAnimator alpha = ObjectAnimator.ofFloat(target, View.ALPHA, 0.1f, 1f);
    ObjectAnimator scaleX = ObjectAnimator.ofFloat(target, View.SCALE_X, 0.0f, 1f);
    ObjectAnimator scaleY = ObjectAnimator.ofFloat(target, View.SCALE_Y, 0.0f, 1f);
    AnimatorSet enter = new AnimatorSet();
    enter.setDuration(1000);
    enter.setInterpolator(new AccelerateInterpolator());
    enter.playTogether(alpha, scaleX, scaleY);

    AnimatorSet before = new AnimatorSet();
    // 同时在正负25f的角度上做随机旋转
    ObjectAnimator rotate = ObjectAnimator.ofFloat(target, View.ROTATION, 0.0f, mRandom.nextInt(50) - 25.5f);
    rotate.setDuration(2000);
    before.playSequentially(enter, rotate);
    return before;
}
 
Example 2
Source File: AccessibilityTabModelListItem.java    From 365browser with Apache License 2.0 6 votes vote down vote up
private void runResetAnimation(boolean useCloseAnimationDuration) {
    cancelRunningAnimation();

    ObjectAnimator swipe = ObjectAnimator.ofFloat(this, View.TRANSLATION_X, 0.f);
    ObjectAnimator fadeIn = ObjectAnimator.ofFloat(this, View.ALPHA, 1.f);
    ObjectAnimator scaleX = ObjectAnimator.ofFloat(this, View.SCALE_X, 1.f);
    ObjectAnimator scaleY = ObjectAnimator.ofFloat(this, View.SCALE_Y, 1.f);
    ObjectAnimator resetHeight = ObjectAnimator.ofInt(this, "height", mDefaultHeight);

    AnimatorSet set = new AnimatorSet();
    set.playTogether(swipe, fadeIn, scaleX, scaleY, resetHeight);
    set.setDuration(useCloseAnimationDuration
            ? mCloseAnimationDurationMs : mDefaultAnimationDurationMs);
    set.start();

    mActiveAnimation = set;
}
 
Example 3
Source File: DrawerLayoutContainer.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public void closeDrawer(boolean fast) {
    cancelCurrentAnimation();
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(
            ObjectAnimator.ofFloat(this, "drawerPosition", 0)
    );
    animatorSet.setInterpolator(new DecelerateInterpolator());
    if (fast) {
        animatorSet.setDuration(Math.max((int) (200.0f / drawerLayout.getMeasuredWidth() * drawerPosition), 50));
    } else {
        animatorSet.setDuration(250);
    }
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animator) {
            onDrawerAnimationEnd(false);
        }
    });
    animatorSet.start();
}
 
Example 4
Source File: WelcomeFragment.java    From ACDD with MIT License 6 votes vote down vote up
private void startAnimationForWaitSecond() {
    for (int i = 0; i < this.pathViewArray.length; i++) {
        if (VERSION.SDK_INT >= MSG_CONSUME_FINISH) {
            AnimatorSet animatorSet = new AnimatorSet();
            ObjectAnimator ofFloat = ObjectAnimator.ofFloat(this.pathViewArray[i], "scaleX", 1.0f, 1.1f);
            ObjectAnimator ofFloat2 = ObjectAnimator.ofFloat(this.pathViewArray[i], "scaleY", 1.0f, 1.1f);
            animatorSet.playTogether(ofFloat, ofFloat2);
            animatorSet.setDuration(300);
            ofFloat.setRepeatMode(2);
            ofFloat.setRepeatCount(1);
            ofFloat2.setRepeatMode(2);
            ofFloat2.setRepeatCount(1);
            if (i == 1) {
                animatorSet.setStartDelay(200);
            } else if (i == 2) {
                animatorSet.setStartDelay(400);
            } else if (i == 3) {
                animatorSet.setStartDelay(600);
            }
            animatorSet.start();
        }
    }
}
 
Example 5
Source File: PropertyAnimationActivity.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
/**
     * AnimatorSet usage
     *
     * @return
     */
    public AnimatorSet getAnimatorSet() {
        AnimatorSet animatorSet = new AnimatorSet();

        // play together
        {
//            animatorSet.play(getObjectAnimator(true))
//                    .with(getObjectAnimator(false))
//                    .with(getValueAnimator());
        }

        //play sequentially
        {
//            animatorSet.play(getObjectAnimator(true))
//                    .after(getObjectAnimator(false))
//                    .before(getValueAnimator());
        }

        animatorSet.playTogether(getObjectAnimatorByPropertyValuesHolder(), getValueAnimator());

        animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
        return animatorSet;
    }
 
Example 6
Source File: eqlizerMain.java    From Android-Music-Player with MIT License 6 votes vote down vote up
public eqlizerMain(Context context, int width, int height) {
    super(context, width, height);
    setBackgroundColor(mainBackground.Color0);
    setPivotY(height*0.7f);
    setPivotX(width*0.5f);
    Ui.ef.clickPlay();
    setAlpha(0);
    Set = new AnimatorSet();
    Set.setInterpolator(Ui.cd.TH);
    Set.setDuration(200);
    Set.playTogether(
            ObjectAnimator.ofFloat(this, "Y",height * 0.5f, 0),
            ObjectAnimator.ofFloat(this, "Alpha", 1.0F)
    );
    Set.start();
    init();
}
 
Example 7
Source File: PlayPauseDrawable.java    From Material-Animation-Samples with Apache License 2.0 5 votes vote down vote up
public void animatePause() {
    AnimatorSet set = new AnimatorSet();
    set.playTogether(
            ObjectAnimator.ofFloat(this, mPropertyPointAX, mBounds.left + shiftY),
            ObjectAnimator.ofFloat(this, mPropertyPointAY, mBounds.top),

            ObjectAnimator.ofFloat(this, mPropertyPointBX, mBounds.left + shiftY),
            ObjectAnimator.ofFloat(this, mPropertyPointBY, mBounds.bottom),

            ObjectAnimator.ofFloat(this, mPropertyPointCX, mBounds.right - shiftY),
            ObjectAnimator.ofFloat(this, mPropertyPointCY, mBounds.top),

            ObjectAnimator.ofFloat(this, mPropertyPointDX, mBounds.right - shiftY),
            ObjectAnimator.ofFloat(this, mPropertyPointDY, mBounds.bottom),

            ObjectAnimator.ofFloat(this, mPropertyPointEX, mBounds.left + shiftY),
            ObjectAnimator.ofFloat(this, mPropertyPointEY, mBounds.centerY()),

            ObjectAnimator.ofFloat(this, mPropertyPointFX, mBounds.left + shiftY),
            ObjectAnimator.ofFloat(this, mPropertyPointFY, mBounds.centerY()),

            ObjectAnimator.ofFloat(this, mRotationProperty, 0f, 1f),
            ObjectAnimator.ofObject(this, mLineColorProperty, mArgbEvaluator, mPauseColor),
            ObjectAnimator.ofObject(this, mBackgroundColorProperty, mArgbEvaluator, mPlayColor),

            ObjectAnimator.ofFloat(this, mStrokeWidthProperty, mStrokeWidth)


    );
    set.setDuration(mAnimationDuration);
    set.setInterpolator(ANIMATION_INTERPOLATOR);
    set.start();
}
 
Example 8
Source File: Zoom.java    From android-animations with MIT License 5 votes vote down vote up
public static AnimatorSet In(View view) {
    AnimatorSet animatorSet = new AnimatorSet();

    ObjectAnimator object1 = ObjectAnimator.ofFloat(view,  "scaleX", 0.45f, 1);
    ObjectAnimator object2 = ObjectAnimator.ofFloat(view,  "scaleY", 0.45f, 1);
    ObjectAnimator object3 = ObjectAnimator.ofFloat(view,   "alpha", 0, 1);

    animatorSet.playTogether(object1, object2, object3);
    return animatorSet;
}
 
Example 9
Source File: FloatActionButton.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
public void showFloatingActionButton() {
    if (mHidden) {
        ObjectAnimator scaleX = ObjectAnimator.ofFloat(this, "scaleX", 0, 1);
        ObjectAnimator scaleY = ObjectAnimator.ofFloat(this, "scaleY", 0, 1);
        AnimatorSet animSetXY = new AnimatorSet();
        animSetXY.playTogether(scaleX, scaleY);
        animSetXY.setInterpolator(overshootInterpolator);
        animSetXY.setDuration(200);
        animSetXY.start();
        mHidden = false;
    }
}
 
Example 10
Source File: FolderPopUpWindow.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
private void enterAnimator() {
    ObjectAnimator alpha = ObjectAnimator.ofFloat(masker, "alpha", 0, 1);
    ObjectAnimator translationY = ObjectAnimator.ofFloat(listView, "translationY", listView.getHeight(), 0);
    AnimatorSet set = new AnimatorSet();
    set.setDuration(400);
    set.playTogether(alpha, translationY);
    set.setInterpolator(new AccelerateDecelerateInterpolator());
    set.start();
}
 
Example 11
Source File: FloatingMenuAnimationHandler.java    From floatingMenu with Apache License 2.0 5 votes vote down vote up
private AnimatorSet openMenuAnimation(Point center) {
    setAnimating(true);
    Animator lastAnimation = null;
    List<SubButton> subActionItems = menu.getSubMenuButtons();
    ArrayList<Animator> animatorArrayList = new ArrayList<>();
    for (int i = 0; i < subActionItems.size(); i++) {
        SubButton currentSubButton = subActionItems.get(i);
        ArrayList<PropertyValuesHolder> properties = new ArrayList<>();
        properties.add(PropertyValuesHolder.ofFloat(View.TRANSLATION_X, currentSubButton.getX() - center.x + currentSubButton.getWidth() / 2));
        properties.add(PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, currentSubButton.getY() - center.y + currentSubButton.getHeight() / 2));
        if (shouldRotate) {
            properties.add(PropertyValuesHolder.ofFloat(View.ROTATION, 720));
        }
        if (shouldScale) {
            properties.add(PropertyValuesHolder.ofFloat(View.SCALE_X, 1));
            properties.add(PropertyValuesHolder.ofFloat(View.SCALE_Y, 1));
        }
        if (shouldFade) {
            properties.add(PropertyValuesHolder.ofFloat(View.ALPHA, 1));
        }
        PropertyValuesHolder[] parameters = new PropertyValuesHolder[properties.size() - 1];
        parameters = properties.toArray(parameters);
        final ObjectAnimator animation = ObjectAnimator.ofPropertyValuesHolder(currentSubButton.getView(), parameters);
        animation.setDuration(openingDuration);
        animation.setInterpolator(openingInterpolator);
        menuButtonAnimationListener = new FloatingMenuButtonAnimationListener(FloatingMenuAnimationHandler.this, currentSubButton, MenuState.OPENING);
        animation.addListener(menuButtonAnimationListener);
        if (i == 0) {
            lastAnimation = animation;
        }
        animation.setStartDelay((subActionItems.size() - i) * lagBetweenItems);
        animatorArrayList.add(animation);
    }
    if (lastAnimation != null) {
        lastAnimation.addListener(this);
    }
    AnimatorSet openAnimatorSet = new AnimatorSet();
    openAnimatorSet.playTogether(animatorArrayList);
    return openAnimatorSet;
}
 
Example 12
Source File: Flip.java    From android-animations with MIT License 5 votes vote down vote up
public static AnimatorSet OutY(View view){
    AnimatorSet animatorSet = new AnimatorSet();

    ObjectAnimator object1 = ObjectAnimator.ofFloat(view,    "alpha", 1, 0);
    ObjectAnimator object2 = ObjectAnimator.ofFloat(view,    "rotationY", 0, 90);

    animatorSet.playTogether(object1, object2);
    return animatorSet;
}
 
Example 13
Source File: AlipaySuccessView.java    From AndroidAnimationExercise with Apache License 2.0 5 votes vote down vote up
private void SuccessAnim() {
    ObjectAnimator scaleXAnim = ObjectAnimator.ofFloat(this, "scaleX", 1.0f, 1.1f, 1.0f);
    ObjectAnimator scaleYAnim = ObjectAnimator.ofFloat(this, "scaleY", 1.0f, 1.1f, 1.0f);
    AnimatorSet set = new AnimatorSet();
    set.setDuration(3000);
    set.setInterpolator(new BounceInterpolator());
    set.playTogether(scaleXAnim, scaleYAnim);
    set.start();
}
 
Example 14
Source File: AnimatorUtils.java    From TikTok with Apache License 2.0 5 votes vote down vote up
public static void playAnimatorArray(ArrayList<Animator> animators, AnimatorPlayType playType){
    AnimatorSet set = new AnimatorSet();
    switch (playType){
        case Sequentially:
            set.playSequentially(animators);
            break;
        case Together:
            set.playTogether(animators);
            break;
    }
    set.start();
}
 
Example 15
Source File: MainActivity.java    From android-ripple-background with MIT License 5 votes vote down vote up
private void foundDevice(){
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.setDuration(400);
    animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
    ArrayList<Animator> animatorList=new ArrayList<Animator>();
    ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(foundDevice, "ScaleX", 0f, 1.2f, 1f);
    animatorList.add(scaleXAnimator);
    ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(foundDevice, "ScaleY", 0f, 1.2f, 1f);
    animatorList.add(scaleYAnimator);
    animatorSet.playTogether(animatorList);
    foundDevice.setVisibility(View.VISIBLE);
    animatorSet.start();
}
 
Example 16
Source File: PasscodeView.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
private void processDone(boolean fingerprint) {
    if (!fingerprint) {
        if (SharedConfig.passcodeRetryInMs > 0) {
            return;
        }
        String password = "";
        if (SharedConfig.passcodeType == 0) {
            password = passwordEditText2.getString();
        } else if (SharedConfig.passcodeType == 1) {
            password = passwordEditText.getText().toString();
        }
        if (password.length() == 0) {
            onPasscodeError();
            return;
        }
        if (!SharedConfig.checkPasscode(password)) {
            SharedConfig.increaseBadPasscodeTries();
            if (SharedConfig.passcodeRetryInMs > 0) {
                checkRetryTextView();
            }
            passwordEditText.setText("");
            passwordEditText2.eraseAllCharacters(true);
            onPasscodeError();
            return;
        }
    }
    SharedConfig.badPasscodeTries = 0;
    passwordEditText.clearFocus();
    AndroidUtilities.hideKeyboard(passwordEditText);

    AnimatorSet AnimatorSet = new AnimatorSet();
    AnimatorSet.setDuration(200);
    AnimatorSet.playTogether(
            ObjectAnimator.ofFloat(this, View.TRANSLATION_Y, AndroidUtilities.dp(20)),
            ObjectAnimator.ofFloat(this, View.ALPHA, AndroidUtilities.dp(0.0f)));
    AnimatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            setVisibility(View.GONE);
        }
    });
    AnimatorSet.start();

    SharedConfig.appLocked = false;
    SharedConfig.saveConfig();
    NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didSetPasscode);
    setOnTouchListener(null);
    if (delegate != null) {
        delegate.didAcceptedPassword();
    }
}
 
Example 17
Source File: ColorPicker.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public void setType(int resetType, boolean hasChanges, boolean twoColors, boolean hasSecondColor, boolean myMessages, int angle, boolean animated) {
    currentResetType = resetType;
    myMessagesColor = myMessages;
    if (myMessagesColor) {
        exchangeButton.setImageResource(R.drawable.menu_switch);
        exchangeButton.setRotation(0);
    } else {
        exchangeButton.setImageResource(R.drawable.editor_rotate);
        exchangeButton.setRotation(angle - 45);
    }
    if (menuItem != null) {
        if (resetType == 1) {
            menuItem.setVisibility(VISIBLE);
        } else {
            menuItem.setVisibility(GONE);
        }
    }

    ArrayList<Animator> animators;
    if (animated) {
        animators = new ArrayList<>();
    } else {
        animators = null;
    }

    if (!twoColors || !hasSecondColor) {
        colorEditText[1].requestFocus();
    }
    for (int a = 2; a < 4; a++) {
        if (animated) {
            if (twoColors) {
                colorEditText[a].setVisibility(VISIBLE);
            }
            animators.add(ObjectAnimator.ofFloat(colorEditText[a], View.ALPHA, twoColors && hasSecondColor ? 1.0f : 0.0f));
        } else {
            colorEditText[a].setVisibility(twoColors ? VISIBLE : GONE);
            colorEditText[a].setAlpha(twoColors && hasSecondColor ? 1.0f : 0.0f);
        }
        colorEditText[a].setTag(twoColors ? 1 : null);
    }
    if (animated) {
        if (twoColors) {
            exchangeButton.setVisibility(VISIBLE);
        }
        animators.add(ObjectAnimator.ofFloat(exchangeButton, View.ALPHA, twoColors && hasSecondColor ? 1.0f : 0.0f));
    } else {
        exchangeButton.setVisibility(twoColors ? VISIBLE : GONE);
        exchangeButton.setAlpha(twoColors && hasSecondColor ? 1.0f : 0.0f);
    }
    if (twoColors) {
        clearButton.setTag(hasSecondColor ? 1 : null);
        clearButton.setRotation(hasSecondColor ? 0 : 45);
    }
    if (animated) {
        if (twoColors) {
            clearButton.setVisibility(VISIBLE);
        }
        animators.add(ObjectAnimator.ofFloat(clearButton, View.ALPHA, twoColors ? 1.0f : 0.0f));
    } else {
        clearButton.setVisibility(twoColors ? VISIBLE : GONE);
        clearButton.setAlpha(twoColors ? 1.0f : 0.0f);
    }

    resetButton.setTag(hasChanges ? 1 : null);
    resetButton.setText(resetType == 1 ? LocaleController.getString("ColorPickerResetAll", R.string.ColorPickerResetAll) : LocaleController.getString("ColorPickerReset", R.string.ColorPickerReset));
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) resetButton.getLayoutParams();
    layoutParams.rightMargin = AndroidUtilities.dp(resetType == 1 ? 14 : (14 + 47));
    if (animated) {
        if (!hasChanges || resetButton.getVisibility() == VISIBLE && hasSecondColor) {
            animators.add(ObjectAnimator.ofFloat(resetButton, View.ALPHA, 0.0f));
        } else if (resetButton.getVisibility() != VISIBLE && !hasSecondColor) {
            resetButton.setVisibility(VISIBLE);
            animators.add(ObjectAnimator.ofFloat(resetButton, View.ALPHA, 1.0f));
        }
    } else {
        resetButton.setAlpha(!hasChanges || hasSecondColor ? 0.0f : 1.0f);
        resetButton.setVisibility(!hasChanges || hasSecondColor ? GONE : VISIBLE);
    }

    if (animators != null && !animators.isEmpty()) {
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(animators);
        animatorSet.setDuration(180);
        animatorSet.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                if (!hasChanges || hasSecondColor) {
                    resetButton.setVisibility(GONE);
                }
                if (!twoColors) {
                    clearButton.setVisibility(GONE);
                    exchangeButton.setVisibility(GONE);
                    for (int a = 2; a < 4; a++) {
                        colorEditText[a].setVisibility(GONE);
                    }
                }
            }
        });
        animatorSet.start();
    }
}
 
Example 18
Source File: ActionBarLayout.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public void movePreviewFragment(float dy) {
    if (!inPreviewMode || transitionAnimationPreviewMode) {
        return;
    }
    float currentTranslation = containerView.getTranslationY();
    float nextTranslation = -dy;
    if (nextTranslation > 0) {
        nextTranslation = 0;
    } else if (nextTranslation < -AndroidUtilities.dp(60)) {
        previewOpenAnimationInProgress = true;
        inPreviewMode = false;
        nextTranslation = 0;

        BaseFragment prevFragment = fragmentsStack.get(fragmentsStack.size() - 2);
        BaseFragment fragment = fragmentsStack.get(fragmentsStack.size() - 1);

        if (Build.VERSION.SDK_INT >= 21) {
            fragment.fragmentView.setOutlineProvider(null);
            fragment.fragmentView.setClipToOutline(false);
        }
        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) fragment.fragmentView.getLayoutParams();
        layoutParams.topMargin = layoutParams.bottomMargin = layoutParams.rightMargin = layoutParams.leftMargin = 0;
        fragment.fragmentView.setLayoutParams(layoutParams);

        presentFragmentInternalRemoveOld(false, prevFragment);

        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(
                ObjectAnimator.ofFloat(fragment.fragmentView, View.SCALE_X, 1.0f, 1.05f, 1.0f),
                ObjectAnimator.ofFloat(fragment.fragmentView, View.SCALE_Y, 1.0f, 1.05f, 1.0f));
        animatorSet.setDuration(200);
        animatorSet.setInterpolator(new CubicBezierInterpolator(0.42, 0.0, 0.58, 1.0));
        animatorSet.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                previewOpenAnimationInProgress = false;
            }
        });
        animatorSet.start();
        performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);

        fragment.setInPreviewMode(false);
    }
    if (currentTranslation != nextTranslation) {
        containerView.setTranslationY(nextTranslation);
        invalidate();
    }
}
 
Example 19
Source File: RippleBackground.java    From ShowcaseView with Apache License 2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
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(android.R.color.holo_red_light));
    rippleStrokeWidth = typedArray.getDimension(R.styleable.RippleBackground_rb_strokeWidth, 4);
    rippleRadius = typedArray.getDimension(R.styleable.RippleBackground_rb_radius, 4);
    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 20
Source File: ExpandableSelectorAnimator.java    From ExpandableSelector with Apache License 2.0 4 votes vote down vote up
private void playAnimatorsTogether(Animator[] animations) {
  AnimatorSet animatorSet = new AnimatorSet();
  animatorSet.playTogether(animations);
  animatorSet.start();
}