List of usage examples for android.animation ObjectAnimator setDuration
@Override @NonNull public ObjectAnimator setDuration(long duration)
From source file:com.cyanogenmod.eleven.ui.activities.HomeActivity.java
private void updateStatusBarColor(int color) { final Window window = getWindow(); ObjectAnimator animator = ObjectAnimator.ofInt(window, "statusBarColor", window.getStatusBarColor(), color); animator.setEvaluator(new ArgbEvaluator()); animator.setDuration(300); animator.start();//from ww w . ja va 2s. c om }
From source file:com.example.tt.pullrefresh.widget.CurveLayout.java
private void animateSettle(int initialOffset, final int targetOffset, float initialVelocity) { if (settling) return;// w ww .j av a 2 s . c o m Log.e(TAG, "animateSettle:TopAndBottom :::" + sheetOffsetHelper.getTopAndBottomOffset()); if (sheetOffsetHelper.getTopAndBottomOffset() == targetOffset) { if (targetOffset >= dismissOffset) { dispatchDismissCallback(); } return; } settling = true; final boolean dismissing = targetOffset == dismissOffset; final long duration = computeSettleDuration(initialVelocity, dismissing); final ObjectAnimator settleAnim = ObjectAnimator.ofInt(sheetOffsetHelper, ViewOffsetHelper.OFFSET_Y, initialOffset, targetOffset); settleAnim.setDuration(duration); settleAnim.setInterpolator(getSettleInterpolator(dismissing, initialVelocity)); settleAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { dispatchPositionChangedCallback(); if (dismissing) { dispatchDismissCallback(); } settling = false; } }); if (callbacks != null && !callbacks.isEmpty()) { settleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { if (animation.getAnimatedFraction() > 0f) { dispatchPositionChangedCallback(); } } }); } settleAnim.start(); }
From source file:com.commonsware.cwac.cam2.support.CameraFragment.java
private void changeMenuIconAnimation(final FloatingActionMenu menu) { AnimatorSet set = new AnimatorSet(); final ImageView v = menu.getMenuIconView(); ObjectAnimator scaleOutX = ObjectAnimator.ofFloat(v, "scaleX", 1.0f, 0.2f); ObjectAnimator scaleOutY = ObjectAnimator.ofFloat(v, "scaleY", 1.0f, 0.2f); ObjectAnimator scaleInX = ObjectAnimator.ofFloat(v, "scaleX", 0.2f, 1.0f); ObjectAnimator scaleInY = ObjectAnimator.ofFloat(v, "scaleY", 0.2f, 1.0f); scaleOutX.setDuration(50); scaleOutY.setDuration(50);//from w w w. ja v a 2 s .c o m scaleInX.setDuration(150); scaleInY.setDuration(150); scaleInX.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { v.setImageResource( menu.isOpened() ? R.drawable.cwac_cam2_ic_close : R.drawable.cwac_cam2_ic_action_settings); } }); set.play(scaleOutX).with(scaleOutY); set.play(scaleInX).with(scaleInY).after(scaleOutX); set.setInterpolator(new OvershootInterpolator(2)); menu.setIconToggleAnimatorSet(set); }
From source file:com.microntek.music.MusicActivity.java
private void updateStatusBarColor(int color) { if (color == Color.TRANSPARENT) { color = getResources().getColor(R.color.primary_dark); }// w w w . ja va 2 s .com final Window window = getWindow(); ObjectAnimator animator = ObjectAnimator.ofInt(window, "statusBarColor", window.getStatusBarColor(), color); animator.setEvaluator(new ArgbEvaluator()); animator.setDuration(300); animator.start(); }
From source file:uk.org.crimetalk.fragments.ArticleContentFragment.java
/** * Private method./* w w w. j ava 2 s.c o m*/ * Returns an {@link android.animation.ObjectAnimator} that is used to * hide the {@link android.support.v7.widget.Toolbar}. * * @param view The {@link android.support.v7.widget.Toolbar} View * @return {@link android.animation.ObjectAnimator} */ private ObjectAnimator getHideAnimator(final View view) { final ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view, "translationY", 0f, -view.getHeight()); objectAnimator.setDuration(ANIMATION_DURATION); objectAnimator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { // Do nothing } @Override public void onAnimationEnd(Animator animator) { view.setVisibility(View.GONE); } @Override public void onAnimationCancel(Animator animator) { // Do nothing } @Override public void onAnimationRepeat(Animator animator) { // Do nothing } }); return objectAnimator; }
From source file:uk.org.crimetalk.fragments.ArticleContentFragment.java
/** * Private method./*w ww .ja va 2 s . c om*/ * Returns an {@link android.animation.ObjectAnimator} that is used to * show the {@link android.support.v7.widget.Toolbar}. * * @param view The {@link android.support.v7.widget.Toolbar} View * @return {@link android.animation.ObjectAnimator} */ private ObjectAnimator getShowAnimator(final View view) { final ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view, "translationY", -view.getHeight(), 0f); objectAnimator.setDuration(ANIMATION_DURATION); objectAnimator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { view.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animator) { // Do nothing } @Override public void onAnimationCancel(Animator animator) { // Do nothing } @Override public void onAnimationRepeat(Animator animator) { // Do nothing } }); return objectAnimator; }
From source file:org.namelessrom.devicecontrol.modules.cpu.CpuSettingsFragment.java
private void rotateView(View v) { if (v == null) { return;//from w w w. jav a2s . c o m } v.clearAnimation(); ObjectAnimator animator = ObjectAnimator.ofFloat(v, "rotation", 0.0f, 360.0f); animator.setDuration(500); animator.setInterpolator(new AccelerateDecelerateInterpolator()); animator.start(); }
From source file:io.github.carlorodriguez.morningritual.MainActivity.java
private ObjectAnimator setAnimation(final ProgressBar progressBar, final TextView title, final TextView quote, final MorningRitual morningRitual, final FloatingActionButton fab) { final ObjectAnimator animator = ObjectAnimator.ofInt(progressBar, "progress", 0, 200000); animator.setDuration(getStepDurationInMillis(morningRitual)); animator.setInterpolator(new LinearInterpolator()); animator.addListener(new Animator.AnimatorListener() { @Override//from w w w . j a v a2 s. c o m public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { notifyStepFinish(); morningRitual.nextStep(); setNextMorningRitualStep(progressBar, title, quote, morningRitual, fab); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); return animator; }
From source file:com.ibm.mil.readyapps.physio.fragments.LandingFragment.java
private void animateMetricsIn(boolean isInitial) { int delay = 0; if (isInitial) { delay = INIT_DELAY;//from www. j ava2s . co m } ObjectAnimator heartRateSlideInAnimator = ObjectAnimator.ofFloat(heartRateTab, "translationX", 1f); ObjectAnimator weightSlideInAnimator = ObjectAnimator.ofFloat(weightTab, "translationX", 1f); ObjectAnimator stepsSlideInAnimator = ObjectAnimator.ofFloat(stepsTab, "translationX", 1f); heartRateSlideInAnimator.setDuration(ANIM_SPEED * 2); heartRateSlideInAnimator.setStartDelay(delay); weightSlideInAnimator.setDuration(ANIM_SPEED * 2); weightSlideInAnimator.setStartDelay(delay + (ANIM_SPEED * 2)); stepsSlideInAnimator.setDuration(ANIM_SPEED * 2); stepsSlideInAnimator.setStartDelay(delay + ANIM_SPEED); AnimatorSet slideIn = new AnimatorSet(); slideIn.play(heartRateSlideInAnimator).with(stepsSlideInAnimator).with(weightSlideInAnimator); slideIn.start(); }
From source file:com.google.android.apps.gutenberg.ScannerActivity.java
private void showCheckinAnimation(Checkin checkin) { if (mLastAnimator != null) { mLastAnimator.cancel();/*from w ww .j ava 2 s. c om*/ } final FrameLayout cover = (FrameLayout) findViewById(R.id.item_cover); cover.setVisibility(View.VISIBLE); final FrameLayout layer = (FrameLayout) findViewById(R.id.animation_layer); final CheckinHolder holder = new CheckinHolder(getLayoutInflater(), layer); FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); lp.gravity = Gravity.CENTER_VERTICAL; holder.setWillAnimate(true); holder.bind(checkin, mImageLoader); holder.itemView.setBackgroundColor(Color.rgb(0xf0, 0xf0, 0xf0)); float elevation = getResources().getDimension(R.dimen.popup_elevation); ViewCompat.setTranslationZ(holder.itemView, elevation); holder.setLines(false, false); layer.addView(holder.itemView, lp); // Interpolator for animators FastOutSlowInInterpolator interpolator = new FastOutSlowInInterpolator(); // Pop-up Animator popUpAnim = AnimatorInflater.loadAnimator(this, R.animator.pop_up); popUpAnim.setTarget(holder.itemView); popUpAnim.setInterpolator(interpolator); popUpAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { holder.animateCheckin(); } }); // Wait ObjectAnimator waitAnim = new ObjectAnimator(); waitAnim.setTarget(holder.itemView); waitAnim.setPropertyName("translationY"); waitAnim.setFloatValues(0.f, 0.f); waitAnim.setDuration(2000); // Slide-down ObjectAnimator slideDownAnim = new ObjectAnimator(); slideDownAnim.setTarget(holder.itemView); slideDownAnim.setPropertyName("translationY"); slideDownAnim.setFloatValues(0.f, calcSlideDistance()); slideDownAnim.setInterpolator(interpolator); // Landing anim ObjectAnimator landingAnim = new ObjectAnimator(); landingAnim.setTarget(holder.itemView); landingAnim.setPropertyName("translationZ"); landingAnim.setFloatValues(elevation, 0.f); landingAnim.setInterpolator(interpolator); landingAnim.setDuration(500); // Play the animators AnimatorSet set = new AnimatorSet(); set.setInterpolator(interpolator); set.playSequentially(popUpAnim, waitAnim, slideDownAnim, landingAnim); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { clean(); } @Override public void onAnimationCancel(Animator animation) { clean(); } private void clean() { mLastAnimator = null; layer.removeAllViews(); cover.setVisibility(View.INVISIBLE); } }); mLastAnimator = set; set.start(); }