Example usage for android.animation ObjectAnimator setDuration

List of usage examples for android.animation ObjectAnimator setDuration

Introduction

In this page you can find the example usage for android.animation ObjectAnimator setDuration.

Prototype

@Override
@NonNull
public ObjectAnimator setDuration(long duration) 

Source Link

Document

Sets the length of the animation.

Usage

From source file:org.taurusxi.taurusxicommon.view.drawer.DrawerArrowDrawable.java

public void animateToMain() {
    ObjectAnimator backAnim = ObjectAnimator.ofFloat(this, "parameter", 1f, 0f);
    backAnim.setDuration(500);
    backAnim.setInterpolator(LINEAR_INTERPOLATOR);
    backAnim.start();/*from  w  ww  .ja  v a  2 s  .c  o m*/
}

From source file:com.cuelogic.android.WheelIndicatorView.java

public void startItemsAnimation() {
    ObjectAnimator animation = ObjectAnimator.ofInt(WheelIndicatorView.this, "filledPercent", 0, filledPercent);
    animation.setDuration(ANIMATION_DURATION);
    animation.setInterpolator(PathInterpolatorCompat.create(0.4F, 0.0F, 0.2F, 1.0F));
    animation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override// ww  w  .  java2  s  .c  o m
        public void onAnimationUpdate(ValueAnimator animation) {
            recalculateItemsAngles();
            invalidate();
        }
    });
    animation.start();
}

From source file:org.taurusxi.taurusxicommon.view.drawer.DrawerArrowDrawable.java

public void animateToMain(final Animator.AnimatorListener animatorListener) {
    ObjectAnimator backAnim = ObjectAnimator.ofFloat(this, "parameter", 1f, 0f);
    backAnim.setDuration(500);
    backAnim.setInterpolator(LINEAR_INTERPOLATOR);
    backAnim.addListener(animatorListener);
    backAnim.start();// w ww  .  j a  va  2 s.  c  o m
}

From source file:com.joaquimley.faboptions.FabOptions.java

private void openCompatAnimation() {
    ObjectAnimator anim = ObjectAnimator.ofFloat(mBackground, "scaleX", 1.0f);
    anim.setDuration(30000); // duration 3 seconds
    anim.start();//from   ww w .j  av a 2  s . c  o m
}

From source file:com.joaquimley.faboptions.FabOptions.java

private void closeCompatAnimation() {
    ObjectAnimator anim = ObjectAnimator.ofFloat(mBackground, "scaleX", 0.0f);
    anim.setDuration(3000);
    anim.start();/*w  w  w .ja  v  a 2s . co m*/
    animateButtons(false);
}

From source file:io.vit.vitio.StartScreens.FragmentHolder.java

private void toggleCircle(ImageView imon, ImageView imoff[]) {
    imon.setActivated(true);/*from  w  ww .  j a v  a  2 s .  c om*/
    ObjectAnimator animatorX = ObjectAnimator.ofFloat(imon, "scaleX", 0.5f, 1.0f);
    ObjectAnimator animatorY = ObjectAnimator.ofFloat(imon, "scaleY", 0.5f, 1.0f);
    animatorX.setDuration(300);
    animatorY.setDuration(300);
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(animatorX, animatorY);
    animatorSet.start();
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
            (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10,
                    getResources().getDisplayMetrics()),
            (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10,
                    getResources().getDisplayMetrics()));
    if (imon != im7)
        params.setMargins(0, 0, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 13,
                getResources().getDisplayMetrics()), 0);
    imon.setLayoutParams(params);
    for (int i = 0; i < imoff.length; i++) {
        imoff[i].setActivated(false);
        params = new LinearLayout.LayoutParams(
                (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 6,
                        getResources().getDisplayMetrics()),
                (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 6,
                        getResources().getDisplayMetrics()));
        if (imoff[i] != im7)
            params.setMargins(0, 0, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 13,
                    getResources().getDisplayMetrics()), 0);
        imoff[i].setLayoutParams(params);
    }
}

From source file:com.appeaser.sublimepickerlibrary.timepicker.RadialTimePickerView.java

private static ObjectAnimator getFadeOutAnimator(IntHolder target, int startAlpha, int endAlpha,
        InvalidateUpdateListener updateListener) {
    final ObjectAnimator animator = ObjectAnimator.ofInt(target, "value", startAlpha, endAlpha);
    animator.setDuration(FADE_OUT_DURATION);
    animator.addUpdateListener(updateListener);
    return animator;
}

From source file:com.appeaser.sublimepickerlibrary.timepicker.RadialTimePickerView.java

private static ObjectAnimator getFadeInAnimator(IntHolder target, int startAlpha, int endAlpha,
        InvalidateUpdateListener updateListener) {
    final float delayMultiplier = 0.25f;
    final float transitionDurationMultiplier = 1f;
    final float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier;
    final int totalDuration = (int) (FADE_IN_DURATION * totalDurationMultiplier);
    final float delayPoint = (delayMultiplier * FADE_IN_DURATION) / totalDuration;

    final Keyframe kf0, kf1, kf2;
    kf0 = Keyframe.ofInt(0f, startAlpha);
    kf1 = Keyframe.ofInt(delayPoint, startAlpha);
    kf2 = Keyframe.ofInt(1f, endAlpha);/*from  w  ww.j  a v a  2 s. c o m*/
    final PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("value", kf0, kf1, kf2);

    final ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, fadeIn);
    animator.setDuration(totalDuration);
    animator.addUpdateListener(updateListener);
    return animator;
}

From source file:com.stanzione.licensesmanagement.ui.CompanyRecyclerAdapter.java

@Override
public void onBindViewHolder(final ViewHolder holder, int position) {

    final Company currentCompany = values.get(position);
    final int companyPosition = position;

    if (isFirstLoad) {
        originalEditIconPosition = holder.companyListItemEditIcon.getX();
        originalRemoveIconPosition = holder.companyListItemRemoveIcon.getX();
        //isFirstLoad = false;
    }/*from  w ww.  j  av  a  2  s.  co m*/

    holder.companyListItemName.setText(currentCompany.getName());
    holder.companyListItemAddress.setText(currentCompany.getAddress());

    if (showEdit) {
        holder.companyListItemRemoveIcon.setVisibility(View.VISIBLE);
        holder.companyListItemEditIcon.setVisibility(View.VISIBLE);
        ObjectAnimator animEditIcon = ObjectAnimator.ofFloat(holder.companyListItemEditIcon, "translationX",
                holder.companyListItemEditIcon.getX(), originalEditIconPosition);
        animEditIcon.setDuration(500);
        animEditIcon.start();
        ObjectAnimator animRemoveIcon = ObjectAnimator.ofFloat(holder.companyListItemRemoveIcon, "translationX",
                holder.companyListItemRemoveIcon.getX(), originalRemoveIconPosition);
        animRemoveIcon.setDuration(500);
        animRemoveIcon.setStartDelay(100);
        animRemoveIcon.start();
    } else {
        if (isFirstLoad) {
            holder.companyListItemEditIcon.setVisibility(View.INVISIBLE);
            holder.companyListItemRemoveIcon.setVisibility(View.INVISIBLE);
        } else {
            holder.companyListItemEditIcon.setVisibility(View.VISIBLE);
            holder.companyListItemRemoveIcon.setVisibility(View.VISIBLE);
        }

        ObjectAnimator animEditIcon = ObjectAnimator.ofFloat(holder.companyListItemEditIcon, "translationX",
                originalEditIconPosition, originalEditIconPosition + 300);
        animEditIcon.setDuration(500);
        animEditIcon.setStartDelay(100);
        animEditIcon.start();

        ObjectAnimator animRemoveIcon = ObjectAnimator.ofFloat(holder.companyListItemRemoveIcon, "translationX",
                originalRemoveIconPosition, originalRemoveIconPosition + 300);
        animRemoveIcon.setDuration(500);
        animRemoveIcon.start();

    }

    holder.companyListItemRemoveIcon.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            AlertDialog.Builder builder = new AlertDialog.Builder(context);
            builder.setTitle("Remove Company").setMessage(
                    "Removing this company, any related Project and its Licenses will be removed as well. Do you want to continue?")
                    .setIcon(android.R.drawable.ic_dialog_alert)
                    .setPositiveButton("Remove", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            Log.d(TAG, "Removing company: " + currentCompany.getId() + " - "
                                    + currentCompany.getName());
                            removeCompany(companyPosition);
                        }
                    }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            // User cancelled the dialog
                        }
                    });

            builder.create().show();

        }
    });

    holder.companyListItemEditIcon.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.d(TAG, "selectedCompany ID: " + currentCompany.getId());
            activity.get().onCompanyToEdit(companyPosition);
        }
    });

    holder.companyListRelativeLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            Log.d(TAG, "selectedCompany ID: " + currentCompany.getId());
            activity.get().onCompanySelected(companyPosition);

        }
    });

}

From source file:com.zandbee.floatingtitlebar.FloatingTitleBarActivity.java

@Override
public void onScrollChanged(int deltaX, int deltaY) {
    final int scrollY = scrollView.getScrollY();

    /** title is going up and has not yet collided with a toolbar */
    if (getLocationYonScreen(bodyLayout) <= (toolbarHeight + titleViewHeight)) {
        titleLayout.setTranslationY(scrollY);
        quasiFab.setTranslationY(scrollY + toolbarHeight + titleViewHeight - quasiFabCenterHeight);

        // TODO try without delta
        if (!titleInUpperPosition
        //&& deltaY > 0
        ) {//  w w  w  .  j  a v  a 2s.co  m
            titleInUpperPosition = true;
            final ObjectAnimator animPd = ObjectAnimator.ofFloat(titleBackDrawable, "progress",
                    titleBackDrawable.max - titleViewHeight, 0f);
            animPd.setInterpolator(new DecelerateInterpolator(2f));
            animPd.setDuration(200).start();
        }
    }

    /** title is going down */
    if (titleInUpperPosition && getLocationYonScreen(titleView) > toolbarHeight
    // + getLocationYonScreen(toolbar)
            && deltaY < 0) {
        titleInUpperPosition = false;
        final ObjectAnimator animPd = ObjectAnimator.ofFloat(titleBackDrawable, "progress", 0f,
                titleBackDrawable.max - titleViewHeight);
        animPd.setInterpolator(new AccelerateDecelerateInterpolator());
        animPd.setDuration(250).start();
    }

    imageView.setTranslationY(scrollY * 0.5f);
}