List of usage examples for android.animation ObjectAnimator setDuration
@Override @NonNull public ObjectAnimator setDuration(long duration)
From source file:com.mina.breathitout.AnalyzeActivity.java
public void animateProgressBar() { AnalyzeActivity.this.runOnUiThread(new Runnable() { @Override/* w ww . ja v a 2s . c o m*/ public void run() { if (android.os.Build.VERSION.SDK_INT >= 11) { // will update the "progress" propriety of seekbar until it reaches progress ObjectAnimator progressAnimation = ObjectAnimator.ofInt(progressBar, "progress", progressBar.getProgress(), lastMaxTime); progressAnimation.setDuration(1000); // 0.5 second progressAnimation.setInterpolator(new DecelerateInterpolator()); progressAnimation.start(); } else progressBar.setProgress(timerCounter); // no animation on Gingerbread or lower } }); }
From source file:android.improving.utils.views.PagerSlidingTabStrip.java
/** * text animation/*from w ww. j a va 2 s .com*/ * @param view * @param color1 * @param color2 */ private void animTextColor(TextView view, int color1, int color2) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { view.setTextColor(color2); } else { if (color1 == color2) { view.setTextColor(color2); } else { ObjectAnimator backgroundColorAnimator = ObjectAnimator.ofObject(view, CHANGECOLORSTRING, new ArgbEvaluator(), color1, color2); backgroundColorAnimator.setDuration(100); backgroundColorAnimator.start(); } } }
From source file:com.waz.zclient.ui.cursor.CursorLayout.java
private ObjectAnimator getShowToolbarAnimator(View view, float fromValue, float toValue) { ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, fromValue, toValue); animator.setDuration(cursorToolbarAnimationDuration); animator.setStartDelay(getResources().getInteger(R.integer.animation_delay_short)); animator.setInterpolator(new Expo.EaseOut()); return animator; }
From source file:ucsc.hci.rankit.DynamicListView.java
/** * This method determines whether the hover cell has been shifted far enough * to invoke a cell swap. If so, then the respective cell swap candidate is * determined and the data set is changed. Upon posting a notification of the * data set change, a layout is invoked to place the cells in the right place. * Using a ViewTreeObserver and a corresponding OnPreDrawListener, we can * offset the cell being swapped to where it previously was and then animate it to * its new position./* www .j a va 2s. c om*/ */ private void handleCellSwitch() { final int deltaY = mLastEventY - mDownY; int deltaYTotal = mHoverCellOriginalBounds.top + mTotalOffset + deltaY; View belowView = getViewForID(mBelowItemId); View mobileView = getViewForID(mMobileItemId); View aboveView = getViewForID(mAboveItemId); boolean isBelow = (belowView != null) && (deltaYTotal > belowView.getTop()); boolean isAbove = (aboveView != null) && (deltaYTotal < aboveView.getTop()); if (isBelow || isAbove) { final long switchItemID = isBelow ? mBelowItemId : mAboveItemId; View switchView = isBelow ? belowView : aboveView; final int originalItem = getPositionForView(mobileView); if (switchView == null) { updateNeighborViewsForID(mMobileItemId); return; } swapElements(mObjectList, originalItem, getPositionForView(switchView)); ((BaseAdapter) getAdapter()).notifyDataSetChanged(); mDownY = mLastEventY; final int switchViewStartTop = switchView.getTop(); // if (android.os.Build.VERSION.SDK_INT <= android.os.Build.VERSION_CODES.KITKAT) { mobileView.setVisibility(View.VISIBLE); switchView.setVisibility(View.INVISIBLE); // } // else { // mobileView.setVisibility(View.INVISIBLE); // switchView.setVisibility(View.VISIBLE); // } updateNeighborViewsForID(mMobileItemId); final ViewTreeObserver observer = getViewTreeObserver(); observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { public boolean onPreDraw() { observer.removeOnPreDrawListener(this); View switchView = getViewForID(switchItemID); mTotalOffset += deltaY; int switchViewNewTop = switchView.getTop(); int delta = switchViewStartTop - switchViewNewTop; switchView.setTranslationY(delta); ObjectAnimator animator = ObjectAnimator.ofFloat(switchView, View.TRANSLATION_Y, 0); animator.setDuration(MOVE_DURATION); animator.start(); return true; } }); } }
From source file:com.waz.zclient.ui.cursor.CursorLayout.java
private ObjectAnimator getHideToolbarAnimator(final View view, float fromValue, float toValue) { ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, fromValue, toValue); animator.setDuration(cursorToolbarAnimationDuration); animator.setInterpolator(new Expo.EaseIn()); animator.addListener(new AnimatorListenerAdapter() { @Override//from w w w . j a va2 s. c o m public void onAnimationCancel(Animator animation) { if (view == null) { return; } view.setVisibility(GONE); } @Override public void onAnimationEnd(Animator animation) { if (view == null) { return; } view.setVisibility(GONE); } }); return animator; }
From source file:com.google.android.apps.santatracker.village.Village.java
private void setIsDay(final boolean isDay, boolean smoothTransition) { ObjectAnimator sunAnim = ObjectAnimator.ofInt(this, "sunOffset", sunOffset, isDay ? 0 : mViewHeight); sunAnim.setInterpolator(new AnticipateOvershootInterpolator()); sunAnim.setDuration(smoothTransition ? ImageWithAlphaAndSize.ANIM_DURATION : 0); sunAnim.addListener(new Animator.AnimatorListener() { @Override/*from w ww . ja va 2 s . c o m*/ public void onAnimationStart(Animator animation) { if (isDay) { mImageSun.setAlpha(ImageWithAlphaAndSize.OPAQUE); } } @Override public void onAnimationEnd(Animator animation) { if (!isDay) { mImageSun.setAlpha(ImageWithAlphaAndSize.INVISIBLE); } } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); AnimatorSet dayAnims = new AnimatorSet(); dayAnims.playTogether( // Day values mImageSkyDay.fadeTransition(isDay, smoothTransition), mImageMountainsDay.fadeTransition(isDay, smoothTransition), mPaintMountainsDay.fadeTransition(isDay, smoothTransition)); ObjectAnimator moonAnim = ObjectAnimator.ofInt(this, "moonOffset", moonOffset, isDay ? -mViewHeight : 0); moonAnim.setInterpolator(new AnticipateOvershootInterpolator()); moonAnim.setDuration(smoothTransition ? ImageWithAlphaAndSize.ANIM_DURATION : 0); moonAnim.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { if (!isDay) { mImageMoon.setAlpha(ImageWithAlphaAndSize.OPAQUE); } } @Override public void onAnimationEnd(Animator animation) { if (isDay) { mImageMoon.setAlpha(ImageWithAlphaAndSize.INVISIBLE); } } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); AnimatorSet nightAnims = new AnimatorSet(); nightAnims.playTogether( // Night values mImageSkyNight.fadeTransition(!isDay, !isDay && smoothTransition), mImageMountainsNight.fadeTransition(!isDay, !isDay && smoothTransition), mPaintMountainsNight.fadeTransition(!isDay, !isDay && smoothTransition)); // When going to the day, delay night animation till after day time has kicked in if (isDay) { nightAnims.setStartDelay(ImageWithAlphaAndSize.ANIM_DURATION); } mFinalAnimations = nightAnims; sunAnim.start(); dayAnims.start(); moonAnim.start(); nightAnims.start(); }
From source file:com.mediatek.galleryfeature.stereo.segment.background.StereoBackgroundActivity.java
private void loadXML() { setContentView(R.layout.m_stereo_background_activity); mActionBar = getActionBar();//from w ww .j a v a 2 s .c o m mActionBar.setBackgroundDrawable(new ColorDrawable(ACTIONBAR_BACKGROUND_COLOR)); mActionBar.setSubtitle(null); mActionBar.setCustomView(R.layout.m_stereo_actionbar); mSaveButton = mActionBar.getCustomView(); View clickableRegion = mSaveButton.findViewById(R.id.stereo_segment_save); clickableRegion.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { saveSynthedImage(); } }); setActionBarDisplayOptions(mActionBar, true, true); mImageShowBackground = (ImageShow) findViewById(R.id.imageShowBackground); mButtonCollapse = findViewById(R.id.collapse); mBackgroundThumbnailList = findViewById(R.id.main_panel_container); mBackgroundStrip = findViewById(R.id.mainPanel); mButtonCollapse.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mIsBottomStripIn) { ((ImageView) (mButtonCollapse)).setImageBitmap(mBitmapExpand); ObjectAnimator animator = ObjectAnimator.ofFloat(mBackgroundStrip, "translationY", mBackgroundThumbnailList.getHeight()); animator.setDuration(THUMBNAIL_TRACK_ANIMATION_DURATION).start(); mIsBottomStripIn = false; } else { ((ImageView) (mButtonCollapse)).setImageBitmap(mBitmapCollapse); ObjectAnimator animator = ObjectAnimator.ofFloat(mBackgroundStrip, "translationY", 0); animator.setDuration(THUMBNAIL_TRACK_ANIMATION_DURATION).start(); mIsBottomStripIn = true; } } }); }
From source file:com.example.piechart3d.PieChart3DView.java
@Override protected void onAttachedToWindow() { // TODO Auto-generated method stub super.onAttachedToWindow(); ObjectAnimator mXAnimator = ObjectAnimator.ofFloat(mRenderer, "angle_x", 0, maxX); mXAnimator.setDuration(2000); mXAnimator.addListener(new AnimatorListener() { @Override/* www . j a v a2s .c o m*/ public void onAnimationCancel(final Animator animation) { } @Override public void onAnimationEnd(final Animator animation) { // progressBar.setProgress(progress); } @Override public void onAnimationRepeat(final Animator animation) { } @Override public void onAnimationStart(final Animator animation) { } }); mXAnimator.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(final ValueAnimator animation) { } }); LinearInterpolator di = new LinearInterpolator(); mXAnimator.setInterpolator(di); mXAnimator.start(); }
From source file:me.lizheng.deckview.views.DeckChildView.java
/** * Animates this task view as it enters recents *//* w w w . j av a 2 s . c om*/ void startEnterRecentsAnimation(final ViewAnimation.TaskViewEnterContext ctx) { Log.i(getClass().getSimpleName(), "startEnterRecentsAnimation"); final DeckChildViewTransform transform = ctx.currentTaskTransform; int startDelay = 0; if (mConfig.launchedFromHome) { Log.i(getClass().getSimpleName(), "mConfig.launchedFromHome false"); // Animate the tasks up int frontIndex = (ctx.currentStackViewCount - ctx.currentStackViewIndex - 1); int delay = mConfig.transitionEnterFromHomeDelay + frontIndex * mConfig.taskViewEnterFromHomeStaggerDelay; setScaleX(transform.scale); setScaleY(transform.scale); ObjectAnimator animator = ObjectAnimator.ofFloat(this, "TranslationY", getTranslationY(), transform.translationY); animator.addUpdateListener(ctx.updateListener); animator.setDuration( mConfig.taskViewEnterFromHomeDuration + frontIndex * mConfig.taskViewEnterFromHomeStaggerDelay); animator.setStartDelay(delay); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { // Decrement the post animation trigger ctx.postAnimationTrigger.decrement(); } }); animator.start(); ctx.postAnimationTrigger.increment(); startDelay = delay; } // Enable the focus animations from this point onwards so that they aren't affected by the // window transitions postDelayed(new Runnable() { @Override public void run() { enableFocusAnimations(); } }, startDelay); }
From source file:com.waz.zclient.pages.main.participants.ParticipantHeaderFragment.java
public void showCancelButton(boolean show, boolean animate) { if (closeButton == null || headerTopBorder == null) { return;/*from w ww. ja v a2s . c o m*/ } if (show) { if (!animate) { closeButton.setAlpha(1); } else { headerTopBorder.animate().alpha(0) .setDuration( getResources().getInteger(R.integer.open_close_button__alpha__animation_duration)) .setStartDelay(getResources().getInteger(R.integer.open_close_button__alpha__delay)) .start(); ObjectAnimator animator = ObjectAnimator.ofFloat(closeButton, View.ALPHA, 1); animator.setDuration( getResources().getInteger(R.integer.open_close_button__alpha__animation_duration)) .setStartDelay(getResources().getInteger(R.integer.open_close_button__alpha__delay)); animator.start(); } } else { if (!animate) { closeButton.setAlpha(0); } else { ObjectAnimator animator = ObjectAnimator.ofFloat(closeButton, View.ALPHA, 0); animator.setDuration( getResources().getInteger(R.integer.close_close_button__alpha__animation_duration)) .setStartDelay(getResources().getInteger(R.integer.close_close_button__alpha__delay)); animator.start(); headerTopBorder.animate().alpha(1) .setDuration( getResources().getInteger(R.integer.close_close_button__alpha__animation_duration)) .setStartDelay(getResources().getInteger(R.integer.close_close_button__alpha__delay)) .start(); } } }