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:com.karthikb351.vitinfo2.fragment.courses.CourseListAdapter.java

public void setAttendance(CourseViewHolder courseViewHolder, int attendance) {
    ObjectAnimator animation = ObjectAnimator.ofInt(courseViewHolder.numberProgressBar, "progress", attendance);
    animation.setDuration(1500);
    animation.setInterpolator(new DecelerateInterpolator());
    animation.start();/* ww  w. j  a va2  s  .  c  o m*/

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

From source file:com.github.rubensousa.floatingtoolbar.FloatingAnimatorImpl.java

@Override
public void show() {
    super.show();
    int rootWidth = getRootView().getWidth();
    float endFabX;

    if (getFab().getLeft() > rootWidth / 2f) {
        endFabX = getFab().getLeft() - getFab().getWidth();
    } else {/* www  .j a v a2s  .  c om*/
        endFabX = getFab().getLeft() + getFab().getWidth();
    }

    PropertyValuesHolder xProperty = PropertyValuesHolder.ofFloat(View.X, endFabX);
    PropertyValuesHolder yProperty = PropertyValuesHolder.ofFloat(View.Y, getFloatingToolbar().getY() * 0.95f);
    PropertyValuesHolder scaleXProperty = PropertyValuesHolder.ofFloat(View.SCALE_X, 0);
    PropertyValuesHolder scaleYProperty = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0);

    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(getFab(), xProperty, yProperty,
            scaleXProperty, scaleYProperty);
    animator.setDuration(FAB_MORPH_DURATION);
    animator.setInterpolator(new AccelerateInterpolator());
    animator.start();

    ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(getFloatingToolbar(), "scaleX", 1f);
    objectAnimator.setDuration(CIRCULAR_REVEAL_DURATION);
    objectAnimator.setStartDelay(CIRCULAR_REVEAL_DELAY);
    objectAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
    objectAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            getFloatingToolbar().setVisibility(View.VISIBLE);
            getFab().setVisibility(View.INVISIBLE);
        }
    });
    objectAnimator.start();
}

From source file:es.wolfi.app.passman.CredentialDisplay.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getArguments() != null) {
        Vault v = (Vault) SingleTon.getTon().getExtra(SettingValues.ACTIVE_VAULT.toString());
        credential = v.findCredentialByGUID(getArguments().getString(CREDENTIAL));
    }/*from w  w w .  j  a  v  a  2  s .  co m*/

    handler = new Handler();
    otp_refresh = new Runnable() {
        @Override
        public void run() {
            int progress = (int) (System.currentTimeMillis() / 1000) % 30;
            otp_progress.setProgress(progress * 100);

            ObjectAnimator animation = ObjectAnimator.ofInt(otp_progress, "progress", (progress + 1) * 100);
            animation.setDuration(1000);
            animation.setInterpolator(new LinearInterpolator());
            animation.start();

            otp.setText(TOTPHelper.generate(new Base32().decode(credential.getOtp())));
            handler.postDelayed(this, 1000);
        }
    };
}

From source file:com.gbozza.android.popularmovies.adapters.ReviewsAdapter.java

@Override
public void onBindViewHolder(final ReviewsAdapterViewHolder reviewsAdapterViewHolder, int position) {
    Review review = mReviewList.get(position);
    reviewsAdapterViewHolder.mReviewAuthorTextView.append(SpannableUtilities.makeBold(mDetailReviewByLabel));
    reviewsAdapterViewHolder.mReviewAuthorTextView.append(review.getAuthor());
    reviewsAdapterViewHolder.mReviewContentTextView.setText(review.getContent());
    reviewsAdapterViewHolder.mReviewShowMoreImageView.setOnClickListener(new View.OnClickListener() {
        @Override//from  www  . ja  v a2s  .  co  m
        public void onClick(View view) {
            int reviewContentLines = TextViewCompat
                    .getMaxLines(reviewsAdapterViewHolder.mReviewContentTextView);
            int reviewCollapsedMaxLines = reviewsAdapterViewHolder.mContext.getResources()
                    .getInteger(R.integer.review_collapsed_max_lines);
            if (reviewContentLines != reviewCollapsedMaxLines) {
                reviewsAdapterViewHolder.mReviewContentTextView.setMaxLines(reviewCollapsedMaxLines);
                reviewsAdapterViewHolder.mReviewShowMoreImageView.setImageResource(R.drawable.ic_expand_more);
            } else {
                ObjectAnimator animation = ObjectAnimator.ofInt(reviewsAdapterViewHolder.mReviewContentTextView,
                        "maxLines", 9999);
                animation.setDuration(1000).start();
                reviewsAdapterViewHolder.mReviewShowMoreImageView.setImageResource(R.drawable.ic_expand_less);
            }
        }
    });
}

From source file:com.stepstone.stepper.internal.widget.ColorableProgressBar.java

public void setProgressCompat(int progress, boolean animate) {
    if (animate) {
        final ObjectAnimator animator = ObjectAnimator.ofInt(this, PROGRESS_PROPERTY, getProgress(),
                progress * PROGRESS_RANGE_MULTIPLIER);
        animator.setDuration(PROGRESS_ANIM_DURATION);
        animator.setInterpolator(PROGRESS_ANIM_INTERPOLATOR);
        animator.start();/*from   w w  w  . j av  a  2s  .  co  m*/
    } else {
        setProgress(progress * PROGRESS_RANGE_MULTIPLIER);
    }

}

From source file:com.gigigo.vuforiaimplementation.VuforiaActivity.java

private void startBoringAnimation() {
    scanLine.setVisibility(View.VISIBLE);
    // Create animators for y axe
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        int yMax = 0;
        yMax = getResources().getDisplayMetrics().heightPixels; //mVuforiaView.getDisplay().getHeight();
        yMax = (int) (yMax * 0.9);// 174;

        ObjectAnimator oay = ObjectAnimator.ofFloat(scanLine, "translationY", 0, yMax);
        oay.setRepeatCount(Animation.INFINITE);
        oay.setDuration(ANIM_DURATION);
        oay.setRepeatMode(Animation.REVERSE);

        oay.setInterpolator(new LinearInterpolator());
        oay.start();//  w w w. ja v  a 2  s . co  m

        //for draw points near scanline
        markFakeFeaturePoint.setObjectAnimator(oay);
    }

    //scanAnimation.

}

From source file:com.h6ah4i.android.example.materialshadowninepatch.ZPositionAnimationDemoFragment.java

@Override
public void onClick(View v) {
    if (v == mCompatShadowItem) {
        ObjectAnimator animator = ObjectAnimator.ofFloat(mCompatShadowItemContainer,
                MaterialShadowContainerViewProperties.SHADOW_TRANSLATION_Z, mDisplayDensity * 0.0f,
                mDisplayDensity * 8.0f);
        animator.setDuration(500);
        animator.setInterpolator(new CycleInterpolator(0.5f));
        animator.start();// w  w w  .j av  a 2s .  co m
    }
}

From source file:com.srinath.hcfab.under25hack.media.MediaFragment.java

public void onFabPressed(View view) {
    final float startX = mFab.getX();

    AnimatorPath path = new AnimatorPath();
    path.moveTo(0, 0);/*  w  ww  .  j  a va2  s .  c  o  m*/
    path.curveTo(-200, 200, -400, 100, -600, 50);

    final ObjectAnimator anim = ObjectAnimator.ofObject(this, "fabLoc", new PathEvaluator(),
            path.getPoints().toArray());

    anim.setInterpolator(new AccelerateInterpolator());
    anim.setDuration(ANIMATION_DURATION);
    anim.start();

    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            if (Math.abs(startX - mFab.getX()) > MINIMUN_X_DISTANCE) {
                if (!mRevealFlag) {
                    mFabContainer.setY(mFabContainer.getY() + mFabSize / 2);

                    mFab.animate().scaleXBy(SCALE_FACTOR).scaleYBy(SCALE_FACTOR).setListener(mEndRevealListener)
                            .setDuration(ANIMATION_DURATION);

                    mRevealFlag = true;
                }
            }
        }
    });
}

From source file:com.gigigo.imagerecognition.vuforia.VuforiaActivity.java

private void startBoringAnimation() {
    scanLine.setVisibility(View.VISIBLE);
    // Create animators for y axe
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        int yMax = 0;
        yMax = getResources().getDisplayMetrics().heightPixels; //mVuforiaView.getDisplay().getHeight();
        yMax = (int) (yMax * 0.9);// 174;

        ObjectAnimator oay = ObjectAnimator.ofFloat(scanLine, "translationY", 0, yMax);
        oay.setRepeatCount(Animation.INFINITE);
        oay.setDuration(ANIM_DURATION);
        oay.setRepeatMode(ValueAnimator.REVERSE);

        oay.setInterpolator(new LinearInterpolator());
        oay.start();//  ww w  . j  a va2s.com

        //for draw points near ir_scanline
        markFakeFeaturePoint.setObjectAnimator(oay);
    }

    //scanAnimation.

}

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

public void animate() {
    ObjectAnimator animatorY = ObjectAnimator.ofFloat(displayImage, "translationY", 200, 0);
    ObjectAnimator animatorA = ObjectAnimator.ofFloat(displayImage, "alpha", 0, 1);
    animatorY.setDuration(200);
    animatorA.setDuration(200);//  w w  w .j a  va 2  s .  co m
    animatorY.setInterpolator(new AccelerateInterpolator());
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(animatorY, animatorA);
    animatorSet.start();
}