List of usage examples for android.animation ObjectAnimator ofInt
public static <T> ObjectAnimator ofInt(T target, Property<T, Integer> xProperty, Property<T, Integer> yProperty, Path path)
Path
using two properties. From source file:pl.edu.agh.schedule.ui.BaseActivity.java
protected void onActionBarAutoShowOrHide(boolean shown) { if (mStatusBarColorAnimator != null) { mStatusBarColorAnimator.cancel(); }//from w w w. ja v a2 s. c o m mStatusBarColorAnimator = ObjectAnimator .ofInt((mDrawerLayout != null) ? mDrawerLayout : mLUtils, (mDrawerLayout != null) ? "statusBarBackgroundColor" : "statusBarColor", shown ? Color.BLACK : mNormalStatusBarColor, shown ? mNormalStatusBarColor : Color.BLACK) .setDuration(250); if (mDrawerLayout != null) { mStatusBarColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { ViewCompat.postInvalidateOnAnimation(mDrawerLayout); } }); } mStatusBarColorAnimator.setEvaluator(ARGB_EVALUATOR); mStatusBarColorAnimator.start(); }
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 w w . ja v a2 s. c om 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:io.plaidapp.core.ui.transitions.ReflowText.java
/** * Create Animators to transition each run of text from start to end position and size. *///from w w w. j a v a 2 s . c o m @NonNull private List<Animator> createRunAnimators(View view, ReflowData startData, ReflowData endData, Bitmap startText, Bitmap endText, List<Run> runs) { List<Animator> animators = new ArrayList<>(runs.size()); int dx = startData.bounds.left - endData.bounds.left; int dy = startData.bounds.top - endData.bounds.top; long startDelay = 0L; // move text closest to the destination first i.e. loop forward or backward over the runs boolean upward = startData.bounds.centerY() > endData.bounds.centerY(); boolean first = true; boolean lastRightward = true; LinearInterpolator linearInterpolator = new LinearInterpolator(); for (int i = upward ? 0 : runs.size() - 1; ((upward && i < runs.size()) || (!upward && i >= 0)); i += (upward ? 1 : -1)) { Run run = runs.get(i); // skip text runs which aren't visible in either state if (!run.startVisible && !run.endVisible) continue; // create & position the drawable which displays the run; add it to the overlay. SwitchDrawable drawable = new SwitchDrawable(startText, run.start, startData.textSize, endText, run.end, endData.textSize); drawable.setBounds(run.start.left + dx, run.start.top + dy, run.start.right + dx, run.start.bottom + dy); view.getOverlay().add(drawable); PropertyValuesHolder topLeft = PropertyValuesHolder.ofObject(SwitchDrawable.TOP_LEFT, null, getPathMotion().getPath(run.start.left + dx, run.start.top + dy, run.end.left, run.end.top)); PropertyValuesHolder width = PropertyValuesHolder.ofInt(SwitchDrawable.WIDTH, run.start.width(), run.end.width()); PropertyValuesHolder height = PropertyValuesHolder.ofInt(SwitchDrawable.HEIGHT, run.start.height(), run.end.height()); // the progress property drives the switching behaviour PropertyValuesHolder progress = PropertyValuesHolder.ofFloat(SwitchDrawable.PROGRESS, 0f, 1f); Animator runAnim = ObjectAnimator.ofPropertyValuesHolder(drawable, topLeft, width, height, progress); boolean rightward = run.start.centerX() + dx < run.end.centerX(); if ((run.startVisible && run.endVisible) && !first && rightward != lastRightward) { // increase the start delay (by a decreasing amount) for the next run // (if it's visible throughout) to stagger the movement and try to minimize overlaps startDelay += staggerDelay; staggerDelay *= STAGGER_DECAY; } lastRightward = rightward; first = false; runAnim.setStartDelay(startDelay); long animDuration = Math.max(minDuration, duration - (startDelay / 2)); runAnim.setDuration(animDuration); animators.add(runAnim); if (run.startVisible != run.endVisible) { // if run is appearing/disappearing then fade it in/out ObjectAnimator fade = ObjectAnimator.ofInt(drawable, SwitchDrawable.ALPHA, run.startVisible ? OPAQUE : TRANSPARENT, run.endVisible ? OPAQUE : TRANSPARENT); fade.setDuration((duration + startDelay) / 2); if (!run.startVisible) { drawable.setAlpha(TRANSPARENT); fade.setStartDelay((duration + startDelay) / 2); } else { fade.setStartDelay(startDelay); } animators.add(fade); } else { // slightly fade during transition to minimize movement ObjectAnimator fade = ObjectAnimator.ofInt(drawable, SwitchDrawable.ALPHA, OPAQUE, OPACITY_MID_TRANSITION, OPAQUE); fade.setStartDelay(startDelay); fade.setDuration(duration + startDelay); fade.setInterpolator(linearInterpolator); animators.add(fade); } } return animators; }
From source file:com.ffmpeger.card.ui.BaseNaviActivity.java
protected void onActionBarAutoShowOrHide(boolean shown) { if (mStatusBarColorAnimator != null) { mStatusBarColorAnimator.cancel(); }/*from ww w. j a v a 2s. c o m*/ mStatusBarColorAnimator = ObjectAnimator .ofInt((mDrawerLayout != null) ? mDrawerLayout : getLPreviewUtils(), (mDrawerLayout != null) ? "statusBarBackgroundColor" : "statusBarColor", shown ? Color.BLACK : mNormalStatusBarColor, shown ? mNormalStatusBarColor : Color.BLACK) .setDuration(250); if (mDrawerLayout != null) { mStatusBarColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { ViewCompat.postInvalidateOnAnimation(mDrawerLayout); } }); } mStatusBarColorAnimator.setEvaluator(ARGB_EVALUATOR); mStatusBarColorAnimator.start(); for (View view : mHideableHeaderViews) { if (shown) { view.animate().translationY(0).alpha(1).setDuration(HEADER_HIDE_ANIM_DURATION) .setInterpolator(new DecelerateInterpolator()); } else { view.animate().translationY(-view.getBottom()).alpha(0).setDuration(HEADER_HIDE_ANIM_DURATION) .setInterpolator(new DecelerateInterpolator()); } } }
From source file:org.starfishrespect.myconsumption.android.ui.BaseActivity.java
protected void onActionBarAutoShowOrHide(boolean shown) { if (mStatusBarColorAnimator != null) { mStatusBarColorAnimator.cancel(); }//from w ww. j av a 2 s . c o m mStatusBarColorAnimator = ObjectAnimator .ofInt(mDrawerLayout, (mDrawerLayout != null) ? "statusBarBackgroundColor" : "statusBarColor", shown ? Color.BLACK : mNormalStatusBarColor, shown ? mNormalStatusBarColor : Color.BLACK) .setDuration(250); if (mDrawerLayout != null) { mStatusBarColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { ViewCompat.postInvalidateOnAnimation(mDrawerLayout); } }); } mStatusBarColorAnimator.setEvaluator(ARGB_EVALUATOR); mStatusBarColorAnimator.start(); for (View view : mHideableHeaderViews) { if (shown) { view.animate().translationY(0).alpha(1).setDuration(HEADER_HIDE_ANIM_DURATION) .setInterpolator(new DecelerateInterpolator()); } else { view.animate().translationY(-view.getBottom()).alpha(0).setDuration(HEADER_HIDE_ANIM_DURATION) .setInterpolator(new DecelerateInterpolator()); } } }
From source file:ca.zadrox.dota2esportticker.ui.BaseActivity.java
protected void onActionBarAutoShowOrHide(boolean shown) { if (mStatusBarColorAnimator != null) { mStatusBarColorAnimator.cancel(); }//from w ww . j av a 2 s.c o m mStatusBarColorAnimator = ObjectAnimator .ofInt((mDrawerLayout != null) ? mDrawerLayout : mLUtils, (mDrawerLayout != null) ? "statusBarBackgroundColor" : "statusBarColor", shown ? Color.BLACK : mNormalStatusBarColor, shown ? mNormalStatusBarColor : Color.BLACK) .setDuration(250); if (mDrawerLayout != null) { mStatusBarColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { ViewCompat.postInvalidateOnAnimation(mDrawerLayout); } }); } mStatusBarColorAnimator.setEvaluator(ARGB_EVALUATOR); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.L) { mStatusBarColorAnimator.start(); } updateSwipeRefreshProgressBarTop(); for (View view : mHideableHeaderViews) { if (shown) { view.animate().translationY(0).alpha(1).setDuration(HEADER_HIDE_ANIM_DURATION) .setInterpolator(new DecelerateInterpolator()); } else { view.animate().translationY(-UIUtils.calculateActionBarSize(this)).alpha(1) .setDuration(HEADER_HIDE_ANIM_DURATION).setInterpolator(new DecelerateInterpolator()); } } }
From source file:com.klinker.android.sliding.MultiShrinkScroller.java
/** * Scroll the activity up as the entrace animation. * @param scrollToCurrentPosition if true, will scroll from the bottom of the screen to the * current position. Otherwise, will scroll from the bottom of the screen to the top of the * screen./*from ww w. j a v a 2s. c om*/ */ public void performEntranceAnimation(OpenAnimation animation, boolean scrollToCurrentPosition) { final int currentPosition = getScroll(); final int bottomScrollPosition = currentPosition - (getHeight() - getTransparentViewHeight()) + 1; final int desiredValue = currentPosition + (scrollToCurrentPosition ? currentPosition : getTransparentViewHeight()); if (animation == OpenAnimation.EXPAND_FROM_VIEW) { scrollTo(0, desiredValue); runExpansionAnimation(); openAnimation = animation; } else { final Interpolator interpolator; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { interpolator = AnimationUtils.loadInterpolator(getContext(), android.R.interpolator.linear_out_slow_in); } else { interpolator = new DecelerateInterpolator(); } final ObjectAnimator animator = ObjectAnimator.ofInt(this, "scroll", bottomScrollPosition, desiredValue); animator.setInterpolator(interpolator); animator.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { if (animation.getAnimatedValue().equals(desiredValue) && listener != null) { listener.onEntranceAnimationDone(); } } }); animator.start(); } }
From source file:com.google.android.apps.santatracker.dasherdancer.DasherDancerActivity.java
@Override public void onAnimationEnd(Animator animation) { if (mAnimCanceled) { return;/*from ww w . j a v a2s .c om*/ } mAnimPlaying = false; //yoda if (mPlayingRest) { //We are at rest, so play the idle animation again. FrameAnimationView character = (FrameAnimationView) mPager.findViewWithTag(mPager.getCurrentItem()); mAnimator = ObjectAnimator.ofInt(character, "frameIndex", 0, sCharacters[0].getFrameIndices(Character.ANIM_IDLE).length); mAnimator.setDuration(sCharacters[0].getDuration(Character.ANIM_IDLE)); mAnimator.addListener(DasherDancerActivity.this); mAnimator.start(); } else { //We finished an animation triggered by a gesture, so start the idle animation again. mHandler.sendEmptyMessage(1); } }
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.xandy.calendar.AllInOneActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { Time t = null;/* w ww. j ava 2s. c o m*/ int viewType = ViewType.CURRENT; long extras = CalendarController.EXTRA_GOTO_TIME; final int itemId = item.getItemId(); if (itemId == R.id.action_refresh) { mController.refreshCalendars(); return true; } else if (itemId == R.id.action_today) { viewType = ViewType.CURRENT; t = new Time(mTimeZone); t.setToNow(); extras |= CalendarController.EXTRA_GOTO_TODAY; } else if (itemId == R.id.action_create_event) { t = new Time(); t.set(mController.getTime()); if (t.minute > 30) { t.hour++; t.minute = 0; } else if (t.minute > 0 && t.minute < 30) { t.minute = 30; } mController.sendEventRelatedEvent(this, EventType.CREATE_EVENT, -1, t.toMillis(true), 0, 0, 0, -1); return true; } else if (itemId == R.id.action_select_visible_calendars) { mController.sendEvent(this, EventType.LAUNCH_SELECT_VISIBLE_CALENDARS, null, null, 0, 0); return true; } else if (itemId == R.id.action_settings) { mController.sendEvent(this, EventType.LAUNCH_SETTINGS, null, null, 0, 0); return true; } else if (itemId == R.id.action_hide_controls) { mHideControls = !mHideControls; Utils.setSharedPreference(this, GeneralPreferences.KEY_SHOW_CONTROLS, !mHideControls); item.setTitle(mHideControls ? mShowString : mHideString); if (!mHideControls) { mMiniMonth.setVisibility(View.VISIBLE); mCalendarsList.setVisibility(View.VISIBLE); mMiniMonthContainer.setVisibility(View.VISIBLE); } final ObjectAnimator slideAnimation = ObjectAnimator.ofInt(this, "controlsOffset", mHideControls ? 0 : mControlsAnimateWidth, mHideControls ? mControlsAnimateWidth : 0); slideAnimation.setDuration(mCalendarControlsAnimationTime); ObjectAnimator.setFrameDelay(0); slideAnimation.start(); return true; } else if (itemId == R.id.action_search) { return false; } else { return mExtensions.handleItemSelected(item, this); } mController.sendEvent(this, EventType.GO_TO, t, null, t, -1, viewType, extras, null, null); return true; }