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:me.calebjones.spacelaunchnow.utils.Utils.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void animateViewColor(View v, int startColor, int endColor) {

    ObjectAnimator animator = ObjectAnimator.ofObject(v, "backgroundColor", new ArgbEvaluator(), startColor,
            endColor);/*from w w w .j av a  2s.  c o  m*/

    animator.setInterpolator(new PathInterpolator(0.4f, 0f, 1f, 1f));
    animator.setDuration(COLOR_ANIMATION_DURATION);
    animator.start();
}

From source file:com.fa.imaged.activity.DetailActivityV2.java

private static void animatePhotoLike() {
    detailvBgLike.setVisibility(View.VISIBLE);
    detailivLike.setVisibility(View.VISIBLE);

    detailvBgLike.setScaleY(0.1f);/*from  ww  w .j  ava  2  s  .  c  o  m*/
    detailvBgLike.setScaleX(0.1f);
    detailvBgLike.setAlpha(1f);
    detailivLike.setScaleY(0.1f);
    detailivLike.setScaleX(0.1f);

    AnimatorSet animatorSet = new AnimatorSet();

    ObjectAnimator bgScaleYAnim = ObjectAnimator.ofFloat(detailvBgLike, "scaleY", 0.1f, 1f);
    bgScaleYAnim.setDuration(200);
    bgScaleYAnim.setInterpolator(DECCELERATE_INTERPOLATOR);
    ObjectAnimator bgScaleXAnim = ObjectAnimator.ofFloat(detailvBgLike, "scaleX", 0.1f, 1f);
    bgScaleXAnim.setDuration(200);
    bgScaleXAnim.setInterpolator(DECCELERATE_INTERPOLATOR);
    ObjectAnimator bgAlphaAnim = ObjectAnimator.ofFloat(detailvBgLike, "alpha", 1f, 0f);
    bgAlphaAnim.setDuration(200);
    bgAlphaAnim.setStartDelay(150);
    bgAlphaAnim.setInterpolator(DECCELERATE_INTERPOLATOR);

    ObjectAnimator imgScaleUpYAnim = ObjectAnimator.ofFloat(detailivLike, "scaleY", 0.1f, 1f);
    imgScaleUpYAnim.setDuration(300);
    imgScaleUpYAnim.setInterpolator(DECCELERATE_INTERPOLATOR);
    ObjectAnimator imgScaleUpXAnim = ObjectAnimator.ofFloat(detailivLike, "scaleX", 0.1f, 1f);
    imgScaleUpXAnim.setDuration(300);
    imgScaleUpXAnim.setInterpolator(DECCELERATE_INTERPOLATOR);

    ObjectAnimator imgScaleDownYAnim = ObjectAnimator.ofFloat(detailivLike, "scaleY", 1f, 0f);
    imgScaleDownYAnim.setDuration(300);
    imgScaleDownYAnim.setInterpolator(ACCELERATE_INTERPOLATOR);
    ObjectAnimator imgScaleDownXAnim = ObjectAnimator.ofFloat(detailivLike, "scaleX", 1f, 0f);
    imgScaleDownXAnim.setDuration(300);
    imgScaleDownXAnim.setInterpolator(ACCELERATE_INTERPOLATOR);

    animatorSet.playTogether(bgScaleYAnim, bgScaleXAnim, bgAlphaAnim, imgScaleUpYAnim, imgScaleUpXAnim);
    animatorSet.play(imgScaleDownYAnim).with(imgScaleDownXAnim).after(imgScaleUpYAnim);

    animatorSet.start();
}

From source file:by.gdgminsk.animationguide.util.AnimUtils.java

public static void scaleOut(final View view, int delay) {
    PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 0.0f);
    PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 0.0f);
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0.4f);
    ObjectAnimator scaleOutAnimation = ObjectAnimator.ofPropertyValuesHolder(view, alpha, scaleX, scaleY);
    scaleOutAnimation.setInterpolator(EASE_OUT_INTERPOLATOR);
    scaleOutAnimation.addListener(new AnimatorListenerAdapter() {
        @Override/* ww w. j  av  a 2s. c om*/
        public void onAnimationEnd(Animator animation) {
            view.setVisibility(View.GONE);
        }

        @Override
        public void onAnimationStart(Animator animation) {
            view.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            view.setScaleX(0.0f);
            view.setScaleY(0.0f);
            view.setVisibility(View.GONE);
        }
    });
    scaleOutAnimation.setDuration(view.getResources().getInteger(R.integer.duration_fab_scale_out));
    scaleOutAnimation.setStartDelay(delay);

    scaleOutAnimation.start();
}

From source file:com.amaze.filemanager.utils.files.FileUtils.java

public static void revealShow(final View view, boolean reveal) {
    if (reveal) {
        ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.ALPHA, 0f, 1f);
        animator.setDuration(300); //ms
        animator.addListener(new AnimatorListenerAdapter() {
            @Override/* ww  w  .j  a v a 2  s  . c  o  m*/
            public void onAnimationStart(Animator animation) {
                view.setVisibility(View.VISIBLE);
            }
        });
        animator.start();
    } else {

        ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.ALPHA, 1f, 0f);
        animator.setDuration(300); //ms
        animator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                view.setVisibility(View.GONE);
            }
        });
        animator.start();
    }
}

From source file:org.bwgz.quotation.activity.LaunchActivity.java

@Override
protected void onResume() {
    super.onResume();
    Log.d(TAG, String.format("onResume"));

    LinearLayout layout = (LinearLayout) findViewById(R.id.quotation_layout);
    ObjectAnimator animator = ObjectAnimator.ofFloat(layout, "alpha", 0f, 1f);
    animator.setDuration(TimeUnit.SECONDS.toMillis(6));
    animator.start();//from   w  w  w  . j  a  v a2s  .  c  om

    Toast toast = Toast.makeText(this, R.string.launch_message, (int) TimeUnit.SECONDS.toMillis(6));
    toast.show();
}

From source file:ua.yyunikov.android.view.AdditionRemovalListView.java

public void removeWithAnimation(final AdditionRemovalAdapter.Item item, final View itemView) {
    final ObjectAnimator anim = ObjectAnimator.ofFloat(itemView, View.ALPHA, 0);

    anim.setDuration(ANIMATION_TIME);
    ViewCompat.setHasTransientState(itemView, true);

    anim.addListener(new AnimatorListenerAdapter() {
        @Override//  w  w w  .  jav  a2 s. co m
        public void onAnimationEnd(Animator animation) {
            remove(item);
            itemView.setAlpha(1);
            ViewCompat.setHasTransientState(itemView, false);
        }
    });
    anim.start();
}

From source file:org.deviceconnect.android.deviceplugin.linking.setting.fragment.LinkingHelpFragment.java

private void createAnimation(final View v) {
    float size = 12.0f * getResources().getDisplayMetrics().density;
    long time = 1000;

    List<Animator> animatorList = new ArrayList<>();

    ObjectAnimator fadeIn = ObjectAnimator.ofFloat(v, "translationY", -size, 0);
    fadeIn.setDuration(time);
    animatorList.add(fadeIn);/*ww w . j a v a2s.c o m*/

    ObjectAnimator fadeOut = ObjectAnimator.ofFloat(v, "translationY", 0, -size);
    fadeOut.setDuration(time);
    animatorList.add(fadeOut);

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playSequentially(animatorList);
    animatorSet.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (!mDestroy) {
                animation.start();
            }
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    });
    animatorSet.start();
}

From source file:com.softminds.matrixcalculator.base_activities.faqs.java

@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
    switch (motionEvent.getAction()) {
    case MotionEvent.ACTION_DOWN:
        ObjectAnimator animator = ObjectAnimator.ofFloat(view, "translationZ", 20);
        animator.setDuration(200);
        animator.setInterpolator(new DecelerateInterpolator());
        animator.start();//  w w  w . ja v a2  s . c om
        view.performClick();
        return true;
    case MotionEvent.ACTION_CANCEL:
    case MotionEvent.ACTION_UP:
        ObjectAnimator animator2 = ObjectAnimator.ofFloat(view, "translationZ", 0);
        animator2.setDuration(200);
        animator2.setInterpolator(new AccelerateInterpolator());
        animator2.start();
        return true;
    default:
        return false;
    }
}

From source file:com.karthikb351.vitinfo2.customwidget.ScheduleView.java

public void setAttendance(int attendance) {
    ObjectAnimator animation = ObjectAnimator.ofInt(progressAttendance, "progress", attendance);
    animation.setDuration(1500);
    animation.setInterpolator(new DecelerateInterpolator());
    animation.start();/*from w ww . j  ava 2s. c  om*/

    if (attendance >= 80) {
        progressAttendance.setReachedBarColor(ContextCompat.getColor(getContext(), R.color.text_secondary));
        progressAttendance.setProgressTextColor(ContextCompat.getColor(getContext(), R.color.text_secondary));
    } else if (attendance < 75) {
        progressAttendance
                .setReachedBarColor(ContextCompat.getColor(getContext(), android.R.color.holo_red_light));
        progressAttendance
                .setProgressTextColor(ContextCompat.getColor(getContext(), android.R.color.holo_red_light));
    } else {
        progressAttendance.setReachedBarColor(ContextCompat.getColor(getContext(), R.color.midAttend));
        progressAttendance.setProgressTextColor(ContextCompat.getColor(getContext(), R.color.midAttend));
    }
}

From source file:de.persoapp.android.activity.fragment.InitializeAppFragment.java

private void playSuccessAnimation() {
    ObjectAnimator animator = ObjectAnimator.ofFloat(this, "saturation", 1F);
    animator.setDuration(1000L);
    animator.addListener(new AnimatorListenerAdapter() {
        @Override/*  www  .j  a  v a2  s.co m*/
        public void onAnimationEnd(Animator animation) {
            mImageView.animate().alpha(0).setDuration(300l).withEndAction(new Runnable() {
                @Override
                public void run() {
                    mEventBus.post(new OnAppInitialized(true));
                }
            });
        }
    });
    animator.start();
}