com.nineoldandroids.animation.Animator Java Examples

The following examples show how to use com.nineoldandroids.animation.Animator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UndoBarController.java    From example with Apache License 2.0 6 votes vote down vote up
public void hideUndoBar(boolean immediate) {
    mHideHandler.removeCallbacks(mHideRunnable);
    if (immediate) {
        mBarView.setVisibility(View.GONE);
        ViewHelper.setAlpha(mBarView, 0);
        mUndoMessage = null;
        mUndoToken = null;

    } else {
        mBarAnimator.cancel();
        mBarAnimator
                .alpha(0)
                .setDuration(mBarView.getResources()
                        .getInteger(android.R.integer.config_shortAnimTime))
                .setListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        mBarView.setVisibility(View.GONE);
                        mUndoMessage = null;
                        mUndoToken = null;
                    }
                });
    }
}
 
Example #2
Source File: YoYo.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
private BaseViewAnimator play() {
    final BaseViewAnimator animator = techniques.getAnimator();

    animator.setDuration(duration)
            .setInterpolator(interpolator)
            .setStartDelay(delay);

    if (callbacks.size() > 0) {
        for (Animator.AnimatorListener callback : callbacks) {
            animator.addAnimatorListener(callback);
        }
    }

    animator.animate(target);
    return animator;
}
 
Example #3
Source File: SimpleAnimation.java    From Android-PullToNextLayout with Apache License 2.0 6 votes vote down vote up
public Animator getPullDownAnimIn(View view) {

        ObjectAnimator in = ObjectAnimator.ofFloat(view, "translationY", -view.getMeasuredHeight(), 0);

        ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 0.6f, 1);
        ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 0.6f, 1);

        AnimatorSet set = new AnimatorSet();
        set.setInterpolator(new DecelerateInterpolator());
        in.setDuration(ANIMATION_DURATION);
        scaleY.setDuration(ANIMATION_DURATION);
        scaleX.setDuration(ANIMATION_DURATION);
        set.setDuration(ANIMATION_DURATION);
        set.playTogether(scaleY, scaleX, in);


        return set;
    }
 
Example #4
Source File: HeaderHolder.java    From HollyViewPager with Apache License 2.0 6 votes vote down vote up
public void animateEnabled(boolean enabled) {
    if(animator != null) {
        animator.cancel();
        animator = null;
    }

    if (enabled) {
        animator = ObjectAnimator.ofFloat(view, "alpha", 1f);
    } else
        animator = ObjectAnimator.ofFloat(view, "alpha", 0.5f);

    animator.setDuration(300);
    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            animator = null;
        }
    });
    animator.start();
}
 
Example #5
Source File: DefaultTransitionController.java    From android-transition with Apache License 2.0 6 votes vote down vote up
private void updateState(long time) {
    if ((time == mLastTime || (!mStarted && !mSetup)) && mUpdateCount != -1) {
        return;
    }

    if (TransitionConfig.isDebug()) {
        appendLog("updateState: \t\ttime=" + time);
    }

    mSetup = false;
    mLastTime = time;
    ArrayList<Animator> animators = mAnimSet.getChildAnimations();
    final int size = animators.size();
    for (int i = 0; i < size; i++) {
        ValueAnimator va = (ValueAnimator) animators.get(i);
        long absTime = time - va.getStartDelay();
        if (absTime >= 0) {
            va.setCurrentPlayTime(absTime);
        }
    }
}
 
Example #6
Source File: AbstractDetailActivity.java    From google-io-2014-compat with Apache License 2.0 6 votes vote down vote up
private void toggleStarView() {
    final AnimatedPathView starContainer = (AnimatedPathView) findViewById(R.id.star_container);

    if (starContainer.getVisibility() == View.INVISIBLE) {
        ViewPropertyAnimator.animate(hero).alpha(0.2f);
        ViewPropertyAnimator.animate(starContainer).alpha(1);
        starContainer.setVisibility(View.VISIBLE);
        starContainer.reveal();
    } else {
        ViewPropertyAnimator.animate(hero).alpha(1);
        ViewPropertyAnimator.animate(starContainer).alpha(0).setListener(new AnimatorListener() {
            @Override
            public void onAnimationEnd(Animator animation) {
                starContainer.setVisibility(View.INVISIBLE);
                ViewPropertyAnimator.animate(starContainer).setListener(null);
            }
        });
    }
}
 
Example #7
Source File: BaseRippleDrawable.java    From android-base-mvp with Apache License 2.0 6 votes vote down vote up
void onFingerUp() {
    if (mCurrentAnimator != null) {
        mCurrentAnimator.end();
        mCurrentAnimator = null;
        createTouchRipple(END_RIPPLE_TOUCH_RADIUS);
    }

    mCurrentAnimator = ObjectAnimator.ofFloat(this, DESTROY_TOUCH_RIPPLE, 0f, 1f);
    mCurrentAnimator.setDuration(DEFAULT_ANIM_DURATION);
    mCurrentAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            mCurrentAnimator = null;
        }
    });
    mCurrentAnimator.start();
}
 
Example #8
Source File: CameraXVideoCaptureHelper.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
CameraXVideoCaptureHelper(@NonNull Fragment fragment,
                          @NonNull CameraButtonView captureButton,
                          @NonNull CameraXView camera,
                          @NonNull MemoryFileDescriptor memoryFileDescriptor,
                          int      maxVideoDurationSec,
                          @NonNull Callback callback)
{
  this.fragment               = fragment;
  this.camera                 = camera;
  this.memoryFileDescriptor   = memoryFileDescriptor;
  this.callback               = callback;
  this.updateProgressAnimator = ValueAnimator.ofFloat(0f, 1f).setDuration(maxVideoDurationSec * 1000);

  updateProgressAnimator.setInterpolator(new LinearInterpolator());
  updateProgressAnimator.addUpdateListener(anim -> captureButton.setProgress(anim.getAnimatedFraction()));
  updateProgressAnimator.addListener(new AnimationEndCallback() {
    @Override
    public void onAnimationEnd(Animator animation) {
      if (isRecording) onVideoCaptureComplete();
    }
  });
}
 
Example #9
Source File: RevealAnimator.java    From WeGit with Apache License 2.0 6 votes vote down vote up
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onAnimationEnd(Animator animation) {
    super.onAnimationEnd(animation);
    ((View) mReference.get()).setLayerType(mLayerType, null);

    RevealAnimator target = mReference.get();

    if(target == null){
        return;
    }

    target.setClipOutlines(false);
    target.setCenter(0, 0);
    target.setTarget(null);
    target.invalidate(mInvalidateBounds);
}
 
Example #10
Source File: RevealAnimator.java    From ExpressHelper with GNU General Public License v3.0 6 votes vote down vote up
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onAnimationEnd(Animator animation) {
    super.onAnimationEnd(animation);
    ((View) mReference.get()).setLayerType(mLayerType, null);

    RevealAnimator target = mReference.get();

    if(target == null){
        return;
    }

    target.setClipOutlines(false);
    target.setCenter(0, 0);
    target.setTarget(null);
    target.invalidate(mInvalidateBounds);
}
 
Example #11
Source File: ViewAnimator.java    From ListViewAnimations with Apache License 2.0 6 votes vote down vote up
/**
 * Animates given View.
 *
 * @param view the View that should be animated.
 */
private void animateView(final int position, @NonNull final View view, @NonNull final Animator[] animators) {
    if (mAnimationStartMillis == -1) {
        mAnimationStartMillis = SystemClock.uptimeMillis();
    }

    ViewHelper.setAlpha(view, 0);

    AnimatorSet set = new AnimatorSet();
    set.playTogether(animators);
    set.setStartDelay(calculateAnimationDelay(position));
    set.setDuration(mAnimationDurationMillis);
    set.start();

    mAnimators.put(view.hashCode(), set);
}
 
Example #12
Source File: FloatingLabelEditText.java    From FloatingLabelLayout with Apache License 2.0 6 votes vote down vote up
/**
 * Hide the label using an animation
 */
private void hideLabel() {
    ViewHelper.setAlpha(mLabel, 1f);
    ViewHelper.setTranslationY(mLabel, 0f);
    ViewPropertyAnimator.animate(mLabel)
            .alpha(0f)
            .translationY(mLabel.getHeight())
            .setDuration(ANIMATION_DURATION)
            .setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    mLabel.setVisibility(View.GONE);
                }
            }).start();

}
 
Example #13
Source File: ScrollAnimator.java    From ButtonMenu with Apache License 2.0 5 votes vote down vote up
/**
 * Show the animated view using a "translationY" animation and configure an AnimatorListener to be notified during
 * the animation.
 */
public void showWithAnimationWithListener(Animator.AnimatorListener animatorListener) {
	scrollDirection = SCROLL_TO_TOP;
	ObjectAnimator objectAnimator = objectAnimatorFactory.getObjectAnimator(animatedView, ANIMATION_TYPE, HIDDEN_Y_POSITION);
	if (animatorListener != null) {
		objectAnimator.addListener(animatorListener);
	}
	objectAnimator.setDuration(durationInMillis);
	objectAnimator.start();
}
 
Example #14
Source File: k.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public void onAnimationEnd(Animator animator)
{
    if (i.b(a) != null)
    {
        i.b(a).onAnimationEnd(animator);
    }
    i.c(a).remove(animator);
    if (i.c(a).isEmpty())
    {
        i.a(a, null);
    }
}
 
Example #15
Source File: SupportAnimatorPreL.java    From fab-toolbar with MIT License 5 votes vote down vote up
@Override
public void cancel() {
    Animator a = mAnimator.get();
    if(a != null){
        a.cancel();
    }
}
 
Example #16
Source File: ViewAnimationUtils.java    From Jide-Note with MIT License 5 votes vote down vote up
static Animator.AnimatorListener getRevealFinishListener(RevealAnimator target, Rect bounds){
    if(SDK_INT >= 17){
        return new RevealAnimator.RevealFinishedJellyBeanMr1(target, bounds);
    }else if(SDK_INT >= 14){
        return new RevealAnimator.RevealFinishedIceCreamSandwich(target, bounds);
    }else {
        return new RevealAnimator.RevealFinishedGingerbread(target, bounds);
    }
}
 
Example #17
Source File: ViewAnimationUtils.java    From fab-toolbar with MIT License 5 votes vote down vote up
private static Animator.AnimatorListener getRevealFinishListener(RevealAnimator target){
    if(SDK_INT >= 18){
        return new RevealAnimator.RevealFinishedJellyBeanMr2(target);
    }else if(SDK_INT >= 14){
        return new RevealAnimator.RevealFinishedIceCreamSandwich(target);
    }else {
        return new RevealAnimator.RevealFinishedGingerbread(target);
    }
}
 
Example #18
Source File: SimpleAnimation.java    From Android-PullToNextLayout with Apache License 2.0 5 votes vote down vote up
public Animator getDeleteItemShowAnimation(View view) {
    ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 0.7f, 1);
    ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 0.7f, 1);
    AnimatorSet set = new AnimatorSet();
    set.setInterpolator(new DecelerateInterpolator());
    scaleY.setDuration(ANIMATION_DURATION);
    scaleX.setDuration(ANIMATION_DURATION);
    set.setDuration(ANIMATION_DURATION);
    set.playTogether(scaleY, scaleX);
    return set;
}
 
Example #19
Source File: ResideMenu.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onAnimationEnd(Animator animation) {
	// reset the view;
	if (isOpened()) {
		viewActivity.setTouchDisable(true);
		viewActivity.setOnClickListener(viewActivityOnClickListener);
	} else {
		viewActivity.setTouchDisable(false);
		viewActivity.setOnClickListener(null);
		hideScrollViewMenu(scrollViewLeftMenu);
		hideScrollViewMenu(scrollViewRightMenu);
		if (menuListener != null)
			menuListener.closeMenu();
	}
}
 
Example #20
Source File: CardListView.java    From example with Apache License 2.0 5 votes vote down vote up
/**
 * This method takes some view and the values by which its top and bottom bounds
 * should be changed by. Given these params, an animation which will animate
 * these bound changes is created and returned.
 */
private Animator getAnimation(final View view, float translateTop, float translateBottom) {

    int top = view.getTop();
    int bottom = view.getBottom();

    int endTop = (int)(top + translateTop);
    int endBottom = (int)(bottom + translateBottom);

    PropertyValuesHolder translationTop = PropertyValuesHolder.ofInt("top", top, endTop);
    PropertyValuesHolder translationBottom = PropertyValuesHolder.ofInt("bottom", bottom,
            endBottom);

    return ObjectAnimator.ofPropertyValuesHolder(view, translationTop, translationBottom);
}
 
Example #21
Source File: AnimationAdapter.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private void cancelExistingAnimation(final View convertView) {
    int hashCode = convertView.hashCode();
    Animator animator = mAnimators.get(hashCode);
    if (animator != null) {
        animator.end();
        mAnimators.remove(hashCode);
    }
}
 
Example #22
Source File: AnimatedVectorDrawable.java    From CanDialog with Apache License 2.0 5 votes vote down vote up
private void setupAnimatorsForTarget(String name, Animator animator) {
    Object target = mAnimatedVectorState.mVectorDrawable.getTargetByName(name);
    animator.setTarget(target);
    if (mAnimatedVectorState.mAnimators == null) {
        mAnimatedVectorState.mAnimators = new ArrayList<Animator>();
        mAnimatedVectorState.mTargetNameMap = new ArrayMap<Animator, String>();
    }
    mAnimatedVectorState.mAnimators.add(animator);
    mAnimatedVectorState.mTargetNameMap.put(animator, name);
    if (DBG_ANIMATION_VECTOR_DRAWABLE) {
        Log.v(LOGTAG, "add animator  for target " + name + " " + animator);
    }
}
 
Example #23
Source File: SupportAnimatorPreL.java    From WeGit with Apache License 2.0 5 votes vote down vote up
@Override
public void start() {
    Animator a = mSupportFramework.get();
    if(a != null) {
        a.start();
    }
}
 
Example #24
Source File: AnimatedVectorDrawable.java    From CanDialog with Apache License 2.0 5 votes vote down vote up
private boolean isStarted() {
    final ArrayList<Animator> animators = mAnimatedVectorState.mAnimators;
    final int size = animators.size();
    for (int i = 0; i < size; i++) {
        final Animator animator = animators.get(i);
        if (animator.isStarted()) {
            return true;
        }
    }
    return false;
}
 
Example #25
Source File: SupportAnimatorPreL.java    From WeGit with Apache License 2.0 5 votes vote down vote up
@Override
public void setDuration(int duration) {
    Animator a = mSupportFramework.get();
    if(a != null) {
        a.setDuration(duration);
    }
}
 
Example #26
Source File: SupportAnimatorPreL.java    From material-sheet-fab with MIT License 5 votes vote down vote up
@Override
public void cancel() {
    Animator a = mAnimator.get();
    if(a != null){
        a.cancel();
    }
}
 
Example #27
Source File: SwipeDismissViewTouchListener.java    From example with Apache License 2.0 5 votes vote down vote up
private void performDismiss(final boolean dismissRight) {
    // Animate the dismissed view to zero-height and then fire the dismiss callback.
    // This triggers layout on each animation frame; in the future we may want to do something
    // smarter and more performant.

    final ViewGroup.LayoutParams lp = mCardView.getLayoutParams();
    final int originalHeight = mCardView.getHeight();

    ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1)
            .setDuration(mAnimationTime);

    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {

            mCallbacks.onDismiss(mCardView,mToken, dismissRight);
            // Reset view presentation
            ViewHelper.setAlpha(mCardView,1f);
            ViewHelper.setTranslationX(mCardView, 0);
            //ViewGroup.LayoutParams lp = mCardView.getLayoutParams();
            lp.height = originalHeight;
            mCardView.setLayoutParams(lp);
        }
    });

    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            lp.height = (Integer) valueAnimator.getAnimatedValue();
            mCardView.setLayoutParams(lp);
        }
    });

    animator.start();
}
 
Example #28
Source File: ViewAnimationUtils.java    From WeGit with Apache License 2.0 5 votes vote down vote up
static Animator.AnimatorListener getRevealFinishListener(RevealAnimator target, Rect bounds){
    if(SDK_INT >= 17){
        return new RevealAnimator.RevealFinishedJellyBeanMr1(target, bounds);
    }else if(SDK_INT >= 14){
        return new RevealAnimator.RevealFinishedIceCreamSandwich(target, bounds);
    }else {
        return new RevealAnimator.RevealFinishedGingerbread(target, bounds);
    }
}
 
Example #29
Source File: SupportAnimatorPreL.java    From fab-toolbar with MIT License 5 votes vote down vote up
@Override
public void end() {
    Animator a = mAnimator.get();
    if(a != null){
        a.end();
    }
}
 
Example #30
Source File: SupportAnimatorPreL.java    From Jide-Note with MIT License 4 votes vote down vote up
@Override
public boolean isRunning() {
    Animator a = mSupportFramework.get();
    return a != null && a.isRunning();
}