@SuppressLint("NewApi") public AnimatedZoomJob(ViewPortHandler viewPortHandler, View v, Transformer trans, YAxis axis, float xAxisRange, float scaleX, float scaleY, float xOrigin, float yOrigin, float zoomCenterX, float zoomCenterY, float zoomOriginX, float zoomOriginY, long duration) { super(viewPortHandler, scaleX, scaleY, trans, v, xOrigin, yOrigin, duration); this.zoomCenterX = zoomCenterX; this.zoomCenterY = zoomCenterY; this.zoomOriginX = zoomOriginX; this.zoomOriginY = zoomOriginY; this.animator.addListener(this); this.yAxis = axis; this.xAxisRange = xAxisRange; }
public static void setAutoCancel(final ObjectAnimator animator) { animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { for (WeakReference<ObjectAnimator> wa : sRunningAnimators) { ObjectAnimator a = wa.get(); if (a == null) { continue; } if (hasSameTargetAndProperties(animator, a)) { a.cancel(); } } } }); }
public AnimatedViewPortJob(ViewPortHandler viewPortHandler, float xValue, float yValue, Transformer trans, View v, float xOrigin, float yOrigin, long duration) { super(viewPortHandler, xValue, yValue, trans, v); this.xOrigin = xOrigin; this.yOrigin = yOrigin; animator = ObjectAnimator.ofFloat(this, "phase", 0f, 1f); animator.setDuration(duration); animator.addUpdateListener(this); animator.addListener(this); }
private void setupSimulateProgressAnimator() { simulateProgressAnimator = ObjectAnimator.ofFloat(this, "currentProgress", 0, 100).setDuration(2000); simulateProgressAnimator.setInterpolator(new AccelerateInterpolator()); simulateProgressAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { changeState(STATE_DONE_STARTED); } }); }
void finishSpotlight(long duration, TimeInterpolator animation, AbstractAnimatorListener listener) { ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(this, "alpha", 1f, 0f); objectAnimator.setDuration(duration); objectAnimator.setInterpolator(animation); objectAnimator.addListener(listener); objectAnimator.start(); }
void startSpotlight(long duration, TimeInterpolator animation, AbstractAnimatorListener listener) { ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(this, "alpha", 0f, 1f); objectAnimator.setDuration(duration); objectAnimator.setInterpolator(animation); objectAnimator.addListener(listener); objectAnimator.start(); }
private void setupDoneAnimators() { doneBgAnimator = ObjectAnimator.ofFloat(this, "currentDoneBgOffset", MAX_DONE_BG_OFFSET, 0).setDuration(300); doneBgAnimator.setInterpolator(new DecelerateInterpolator()); checkmarkAnimator = ObjectAnimator.ofFloat(this, "currentCheckmarkOffset", MAX_DONE_IMG_OFFSET, 0).setDuration(300); checkmarkAnimator.setInterpolator(new OvershootInterpolator()); checkmarkAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { changeState(STATE_FINISHED); } }); }
@Override public void onFocus() { int headerHeight = getResources().getDimensionPixelOffset(R.dimen.sliding_search_view_header_height); ObjectAnimator anim = ObjectAnimator.ofFloat(mSearchView, "translationY", headerHeight, 0); anim.setDuration(350); fadeDimBackground(0, 150, null); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { //show suggestions when search bar gains focus (typically history suggestions) mSearchView.swapSuggestions(DataHelper.getHistory(getActivity(), 3)); } }); anim.start(); Log.d(TAG, "onFocus()"); }
private void hideBubble() { if (currentAnimator != null) currentAnimator.cancel(); currentAnimator = ObjectAnimator.ofFloat(bubble, "alpha", 1f, 0f).setDuration(BUBBLE_ANIMATION_DURATION); currentAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); bubble.setVisibility(INVISIBLE); currentAnimator = null; } @Override public void onAnimationCancel(Animator animation) { super.onAnimationCancel(animation); bubble.setVisibility(INVISIBLE); currentAnimator = null; } }); currentAnimator.start(); }
@OnClick(R.id.ratio_fab) public void onRatioClicked() { final float oldRatio = cropView.getImageRatio(); selectedRatio = (selectedRatio + 1) % ASPECT_RATIOS.length; // Since the animation needs to interpolate to the native // ratio, we need to get that instead of using 0 float newRatio = ASPECT_RATIOS[selectedRatio]; if (Float.compare(0, newRatio) == 0) { newRatio = cropView.getImageRatio(); } ObjectAnimator viewportRatioAnimator = ObjectAnimator.ofFloat(cropView, "viewportRatio", oldRatio, newRatio) .setDuration(420); autoCancel(viewportRatioAnimator); viewportRatioAnimator.addListener(animatorListener); viewportRatioAnimator.start(); Toast.makeText(this, ASPECT_LABELS[selectedRatio], Toast.LENGTH_SHORT).show(); }
private void showSlider(View sliderPanel) { if (null != mSeekBarPanelAnimator) { mSeekBarPanelAnimator.cancel(); mSeekBarPanelAnimator = null; } sliderPanel.setTranslationY(sliderPanel.getHeight()); sliderPanel.setVisibility(View.VISIBLE); mSeekBarPanelAnimator = ObjectAnimator.ofFloat(sliderPanel, "translationY", 0.0f); mSeekBarPanelAnimator.setDuration(SLIDER_ANIMATION_DURING); mSeekBarPanelAnimator.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR); mSeekBarPanelAnimator.addUpdateListener(mUpdateSliderListener); mSeekBarPanelAnimator.addListener(mShowSliderListener); mSeekBarPanelAnimator.start(); if (null != mSystemUiHelper) { mSystemUiHelper.show(); mShowSystemUi = true; } }
private void hideSlider(View sliderPanel) { if (null != mSeekBarPanelAnimator) { mSeekBarPanelAnimator.cancel(); mSeekBarPanelAnimator = null; } mSeekBarPanelAnimator = ObjectAnimator.ofFloat(sliderPanel, "translationY", sliderPanel.getHeight()); mSeekBarPanelAnimator.setDuration(SLIDER_ANIMATION_DURING); mSeekBarPanelAnimator.setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR); mSeekBarPanelAnimator.addUpdateListener(mUpdateSliderListener); mSeekBarPanelAnimator.addListener(mHideSliderListener); mSeekBarPanelAnimator.start(); if (null != mSystemUiHelper) { mSystemUiHelper.hide(); mShowSystemUi = false; } }
public void startFromLocation(int[] tapLocationOnScreen) { changeState(STATE_FILL_STARTED); startLocationX = tapLocationOnScreen[0]; startLocationY = tapLocationOnScreen[1]; revealAnimator = ObjectAnimator.ofInt(this, "currentRadius", 0, getWidth() + getHeight()).setDuration(FILL_TIME); revealAnimator.setInterpolator(INTERPOLATOR); revealAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { changeState(STATE_FINISHED); } }); revealAnimator.start(); }
public void displayViewOnLoadFinished(boolean finishProgressBar) { if (!finishProgressBar || !isShowingProgress) { viewAnimator.setDisplayedChild(2); return; } ObjectAnimator animator = ObjectAnimator.ofInt( progressBar, "progress", progressBar.getProgress(), PROGRESS_MAX); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { viewAnimator.setDisplayedChild(2); } }); animator.setDuration(PROGRESS_STEP_DURATION); animator.start(); }
protected void resetAnimator(){ animator.removeAllListeners(); animator.removeAllUpdateListeners(); animator.reverse(); animator.addUpdateListener(this); animator.addListener(this); }
/** * Set the presented sheet to be in a peeked state. */ public void peekSheet() { cancelCurrentAnimation(); setSheetLayerTypeIfEnabled(LAYER_TYPE_HARDWARE); ObjectAnimator anim = ObjectAnimator.ofFloat(this, SHEET_TRANSLATION, getPeekSheetTranslation()); anim.setDuration(ANIMATION_DURATION); anim.setInterpolator(animationInterpolator); anim.addListener(new CancelDetectionAnimationListener() { @Override public void onAnimationEnd(@NonNull Animator animation) { if (!canceled) { currentAnimator = null; } } }); anim.start(); currentAnimator = anim; setState(State.PEEKED); }
/** * Set the presented sheet to be in an expanded state. */ public void expandSheet() { cancelCurrentAnimation(); setSheetLayerTypeIfEnabled(LAYER_TYPE_NONE); ObjectAnimator anim = ObjectAnimator.ofFloat(this, SHEET_TRANSLATION, getMaxSheetTranslation()); anim.setDuration(ANIMATION_DURATION); anim.setInterpolator(animationInterpolator); anim.addListener(new CancelDetectionAnimationListener() { @Override public void onAnimationEnd(@NonNull Animator animation) { if (!canceled) { currentAnimator = null; } } }); anim.start(); currentAnimator = anim; setState(State.EXPANDED); }
private void transitionSecene(int position) { if (transitionAnimator != null) { transitionAnimator.cancel(); } countryView.saveNextPosition(position, dataList.get(position).getCountry() + "-" + position); temperatureView.saveNextPosition(position, dataList.get(position).getTemperature()); addressView.saveNextPosition(position, dataList.get(position).getAddress()); bottomView.saveNextPosition(position, dataList.get(position).getMapImageUrl()); timeView.saveNextPosition(position, dataList.get(position).getTime()); transitionAnimator = ObjectAnimator.ofFloat(this, "transitionValue", 0.0f, 1.0f); transitionAnimator.setDuration(300); transitionAnimator.start(); transitionAnimator.addListener(animatorListener); }
private void createCustomAnimation() { AnimatorSet set = new AnimatorSet(); ObjectAnimator scaleOutX = ObjectAnimator.ofFloat(menuGreen.getMenuIconView(), "scaleX", 1.0f, 0.2f); ObjectAnimator scaleOutY = ObjectAnimator.ofFloat(menuGreen.getMenuIconView(), "scaleY", 1.0f, 0.2f); ObjectAnimator scaleInX = ObjectAnimator.ofFloat(menuGreen.getMenuIconView(), "scaleX", 0.2f, 1.0f); ObjectAnimator scaleInY = ObjectAnimator.ofFloat(menuGreen.getMenuIconView(), "scaleY", 0.2f, 1.0f); scaleOutX.setDuration(50); scaleOutY.setDuration(50); scaleInX.setDuration(150); scaleInY.setDuration(150); scaleInX.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { menuGreen.getMenuIconView().setImageResource(menuGreen.isOpened() ? R.drawable.ic_close : R.drawable.ic_star); } }); set.play(scaleOutX).with(scaleOutY); set.play(scaleInX).with(scaleInY).after(scaleOutX); set.setInterpolator(new OvershootInterpolator(2)); menuGreen.setIconToggleAnimatorSet(set); }
@Test public void start_shouldRunAnimation() { final ObjectAnimator animator = ObjectAnimator.ofInt(target, "transparency", 0, 1, 2, 3, 4); Robolectric.getForegroundThreadScheduler().pause(); animator.setDuration(1000); animator.addListener(listener); animator.start(); assertThat(listenerEvents).containsExactly("started"); assertThat(target.getTransparency()).isEqualTo(0); Robolectric.flushForegroundThreadScheduler(); assertThat(listenerEvents).containsExactly("started", "ended"); assertThat(target.getTransparency()).isEqualTo(4); }